From a4f48a808876bb063d6eba18b3a520d1db41f84d Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Mon, 3 Feb 2025 19:41:07 +0100 Subject: [PATCH] Add dist for v12.4.1 --- dist/MapboxVectorLayer.d.ts | 278 ++++++++++++++++++++++++++++++++ dist/apply.d.ts | 309 ++++++++++++++++++++++++++++++++++++ dist/index.d.ts | 3 + dist/mapbox.d.ts | 34 ++++ dist/olms.js | 2 + dist/olms.js.map | 1 + dist/shaders.d.ts | 8 + dist/stylefunction.d.ts | 136 ++++++++++++++++ dist/text.d.ts | 9 ++ dist/util.d.ts | 90 +++++++++++ 10 files changed, 870 insertions(+) create mode 100644 dist/MapboxVectorLayer.d.ts create mode 100644 dist/apply.d.ts create mode 100644 dist/index.d.ts create mode 100644 dist/mapbox.d.ts create mode 100644 dist/olms.js create mode 100644 dist/olms.js.map create mode 100644 dist/shaders.d.ts create mode 100644 dist/stylefunction.d.ts create mode 100644 dist/text.d.ts create mode 100644 dist/util.d.ts diff --git a/dist/MapboxVectorLayer.d.ts b/dist/MapboxVectorLayer.d.ts new file mode 100644 index 00000000..1eecd66c --- /dev/null +++ b/dist/MapboxVectorLayer.d.ts @@ -0,0 +1,278 @@ +/** + * @typedef {Object} Options + * @property {string} styleUrl The URL of the Mapbox/MapLibre Style object to use for this layer. For a + * style created with Mapbox Studio and hosted on Mapbox, this will look like + * 'mapbox://styles/you/your-style'. + * @property {string} [accessToken] The access token for your Mapbox/MapLibre style. This has to be provided + * for `mapbox://` style urls. For `https://` and other urls, any access key must be the last query + * parameter of the style url. + * @property {string} [source] If your style uses more than one source, you need to use either the + * `source` property or the `layers` property to limit rendering to a single vector source. The + * `source` property corresponds to the id of a vector source in your Mapbox/MapLibre style. + * @property {Array} [layers] Limit rendering to the list of included layers. All layers + * must share the same vector source. If your style uses more than one source, you need to use + * either the `source` property or the `layers` property to limit rendering to a single vector + * source. + * @property {boolean} [declutter=true] Declutter images and text. Decluttering is applied to all + * image and text styles of all Vector and VectorTile layers that have set this to `true`. The priority + * is defined by the z-index of the layer, the `zIndex` of the style and the render order of features. + * Higher z-index means higher priority. Within the same z-index, a feature rendered before another has + * higher priority. + * + * As an optimization decluttered features from layers with the same `className` are rendered above + * the fill and stroke styles of all of those layers regardless of z-index. To opt out of this + * behavior and place declutterd features with their own layer configure the layer with a `className` + * other than `ol-layer`. + * @property {import("ol/layer/Base.js").BackgroundColor|false} [background] Background color for the layer. + * If not specified, the background from the Mapbox/MapLibre Style object will be used. Set to `false` to prevent + * the Mapbox/MapLibre style's background from being used. + * @property {string} [className='ol-layer'] A CSS class name to set to the layer element. + * @property {number} [opacity=1] Opacity (0, 1). + * @property {boolean} [visible=true] Visibility. + * @property {import("ol/extent.js").Extent} [extent] The bounding extent for layer rendering. The layer will not be + * rendered outside of this extent. + * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers + * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed + * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()` + * method was used. + * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be + * visible. + * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will + * be visible. If neither `maxResolution` nor `minZoom` are defined, the layer's `maxResolution` will + * match the style source's `minzoom`. + * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will + * be visible. If neither `maxResolution` nor `minZoom` are defined, the layer's `minZoom` will match + * the style source's `minzoom`. + * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will + * be visible. + * @property {import("ol/render.js").OrderFunction} [renderOrder] Render order. Function to be used when sorting + * features before rendering. By default features are drawn in the order that they are created. Use + * `null` to avoid the sort, but get an undefined draw order. + * @property {number} [renderBuffer=100] The buffer in pixels around the tile extent used by the + * renderer when getting features from the vector tile for the rendering or hit-detection. + * Recommended value: Vector tiles are usually generated with a buffer, so this value should match + * the largest possible buffer of the used tiles. It should be at least the size of the largest + * point symbol or line width. + * @property {import("ol/layer/VectorTile.js").VectorTileRenderType} [renderMode='hybrid'] Render mode for vector tiles: + * * `'hybrid'`: Polygon and line elements are rendered as images, so pixels are scaled during zoom + * animations. Point symbols and texts are accurately rendered as vectors and can stay upright on + * rotated views. + * * `'vector'`: Everything is rendered as vectors. Use this mode for improved performance on vector + * tile layers with only a few rendered features (e.g. for highlighting a subset of features of + * another layer with the same source). + * @property {import("ol/Map.js").default} [map] Sets the layer as overlay on a map. The map will not manage + * this layer in its layers collection, and the layer will be rendered on top. This is useful for + * temporary layers. The standard way to add a layer to a map and have it managed by the map is to + * use `map.addLayer()`. + * @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will be + * recreated during animations. This means that no vectors will be shown clipped, but the setting + * will have a performance impact for large amounts of vector data. When set to `false`, batches + * will be recreated when no animation is active. + * @property {boolean} [updateWhileInteracting=false] When set to `true`, feature batches will be + * recreated during interactions. See also `updateWhileAnimating`. + * @property {number} [preload=0] Preload. Load low-resolution tiles up to `preload` levels. `0` + * means no preloading. + * @property {boolean} [useInterimTilesOnError=true] Use interim tiles on error. + * @property {Object} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`. + */ +/** + * ```js + * import {MapboxVectorLayer} from 'ol-mapbox-style'; + * ``` + * A vector tile layer based on a Mapbox/MapLibre style that uses a single vector source. Configure + * the layer with the `styleUrl` and `accessToken` shown in Mapbox Studio's share panel. + * If the style uses more than one source, use the `source` property to choose a single + * vector source. If you want to render a subset of the layers in the style, use the `layers` + * property (all layers must share the same vector source). See the constructor options for + * more detail. + * + * const map = new Map({ + * view: new View({ + * center: [0, 0], + * zoom: 1, + * }), + * layers: [ + * new MapboxVectorLayer({ + * styleUrl: 'mapbox://styles/mapbox/bright-v9', + * accessToken: 'your-mapbox-access-token-here', + * }), + * ], + * target: 'map', + * }); + * + * On configuration or loading error, the layer will trigger an `'error'` event. Listeners + * will receive an object with an `error` property that can be used to diagnose the problem. + * + * Instances of this class emit an `error` event when an error occurs during style loading: + * + * layer.on('error', function() { + * console.error('Error loading style'); + * } + * + * **Note for users of the full build**: The `MapboxVectorLayer` requires the + * [ol-mapbox-style](https://github.com/openlayers/ol-mapbox-style) library to be loaded as well. + * + * @param {Options} options Options. + * @extends {VectorTileLayer} + */ +export default class MapboxVectorLayer extends VectorTileLayer, import("ol/render/Feature.js").default> { + /** + * @param {Options} options Layer options. At a minimum, `styleUrl` and `accessToken` + * must be provided. + */ + constructor(options: Options); + accessToken: string | undefined; +} +export type Map = import("ol/Map.js").default; +export type Options = { + /** + * The URL of the Mapbox/MapLibre Style object to use for this layer. For a + * style created with Mapbox Studio and hosted on Mapbox, this will look like + * 'mapbox://styles/you/your-style'. + */ + styleUrl: string; + /** + * The access token for your Mapbox/MapLibre style. This has to be provided + * for `mapbox://` style urls. For `https://` and other urls, any access key must be the last query + * parameter of the style url. + */ + accessToken?: string | undefined; + /** + * If your style uses more than one source, you need to use either the + * `source` property or the `layers` property to limit rendering to a single vector source. The + * `source` property corresponds to the id of a vector source in your Mapbox/MapLibre style. + */ + source?: string | undefined; + /** + * Limit rendering to the list of included layers. All layers + * must share the same vector source. If your style uses more than one source, you need to use + * either the `source` property or the `layers` property to limit rendering to a single vector + * source. + */ + layers?: string[] | undefined; + /** + * Declutter images and text. Decluttering is applied to all + * image and text styles of all Vector and VectorTile layers that have set this to `true`. The priority + * is defined by the z-index of the layer, the `zIndex` of the style and the render order of features. + * Higher z-index means higher priority. Within the same z-index, a feature rendered before another has + * higher priority. + * + * As an optimization decluttered features from layers with the same `className` are rendered above + * the fill and stroke styles of all of those layers regardless of z-index. To opt out of this + * behavior and place declutterd features with their own layer configure the layer with a `className` + * other than `ol-layer`. + */ + declutter?: boolean | undefined; + /** + * Background color for the layer. + * If not specified, the background from the Mapbox/MapLibre Style object will be used. Set to `false` to prevent + * the Mapbox/MapLibre style's background from being used. + */ + background?: false | import("ol/layer/Base.js").BackgroundColor | undefined; + /** + * A CSS class name to set to the layer element. + */ + className?: string | undefined; + /** + * Opacity (0, 1). + */ + opacity?: number | undefined; + /** + * Visibility. + */ + visible?: boolean | undefined; + /** + * The bounding extent for layer rendering. The layer will not be + * rendered outside of this extent. + */ + extent?: import("ol/extent.js").Extent | undefined; + /** + * The z-index for layer rendering. At rendering time, the layers + * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed + * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()` + * method was used. + */ + zIndex?: number | undefined; + /** + * The minimum resolution (inclusive) at which this layer will be + * visible. + */ + minResolution?: number | undefined; + /** + * The maximum resolution (exclusive) below which this layer will + * be visible. If neither `maxResolution` nor `minZoom` are defined, the layer's `maxResolution` will + * match the style source's `minzoom`. + */ + maxResolution?: number | undefined; + /** + * The minimum view zoom level (exclusive) above which this layer will + * be visible. If neither `maxResolution` nor `minZoom` are defined, the layer's `minZoom` will match + * the style source's `minzoom`. + */ + minZoom?: number | undefined; + /** + * The maximum view zoom level (inclusive) at which this layer will + * be visible. + */ + maxZoom?: number | undefined; + /** + * Render order. Function to be used when sorting + * features before rendering. By default features are drawn in the order that they are created. Use + * `null` to avoid the sort, but get an undefined draw order. + */ + renderOrder?: import("ol/render.js").OrderFunction | undefined; + /** + * The buffer in pixels around the tile extent used by the + * renderer when getting features from the vector tile for the rendering or hit-detection. + * Recommended value: Vector tiles are usually generated with a buffer, so this value should match + * the largest possible buffer of the used tiles. It should be at least the size of the largest + * point symbol or line width. + */ + renderBuffer?: number | undefined; + /** + * Render mode for vector tiles: + * * `'hybrid'`: Polygon and line elements are rendered as images, so pixels are scaled during zoom + * animations. Point symbols and texts are accurately rendered as vectors and can stay upright on + * rotated views. + * * `'vector'`: Everything is rendered as vectors. Use this mode for improved performance on vector + * tile layers with only a few rendered features (e.g. for highlighting a subset of features of + * another layer with the same source). + */ + renderMode?: import("ol/layer/VectorTile.js").VectorTileRenderType | undefined; + /** + * Sets the layer as overlay on a map. The map will not manage + * this layer in its layers collection, and the layer will be rendered on top. This is useful for + * temporary layers. The standard way to add a layer to a map and have it managed by the map is to + * use `map.addLayer()`. + */ + map?: import("ol/Map.js").default | undefined; + /** + * When set to `true`, feature batches will be + * recreated during animations. This means that no vectors will be shown clipped, but the setting + * will have a performance impact for large amounts of vector data. When set to `false`, batches + * will be recreated when no animation is active. + */ + updateWhileAnimating?: boolean | undefined; + /** + * When set to `true`, feature batches will be + * recreated during interactions. See also `updateWhileAnimating`. + */ + updateWhileInteracting?: boolean | undefined; + /** + * Preload. Load low-resolution tiles up to `preload` levels. `0` + * means no preloading. + */ + preload?: number | undefined; + /** + * Use interim tiles on error. + */ + useInterimTilesOnError?: boolean | undefined; + /** + * Arbitrary observable properties. Can be accessed with `#get()` and `#set()`. + */ + properties?: { + [x: string]: any; + } | undefined; +}; +import VectorTileSource from 'ol/source/VectorTile.js'; +import VectorTileLayer from 'ol/layer/VectorTile.js'; diff --git a/dist/apply.d.ts b/dist/apply.d.ts new file mode 100644 index 00000000..5e25872e --- /dev/null +++ b/dist/apply.d.ts @@ -0,0 +1,309 @@ +/** + * Applies a style function to an `ol/layer/VectorTile` or `ol/layer/Vector` + * with an `ol/source/VectorTile` or an `ol/source/Vector`. If the layer does not have a source + * yet, it will be created and populated from the information in the `glStyle` (unless `updateSource` is + * set to `false`). + * + * **Example:** + * ```js + * import {applyStyle} from 'ol-mapbox-style'; + * import {VectorTile} from 'ol/layer.js'; + * + * const layer = new VectorTile({declutter: true}); + * applyStyle(layer, 'https://api.maptiler.com/maps/basic/style.json?key=YOUR_OPENMAPTILES_TOKEN'); + * ``` + * + * The style function will render all layers from the `glStyle` object that use the source + * of the first layer, the specified `source`, or a subset of layers from the same source. The + * source needs to be a `"type": "vector"` or `"type": "geojson"` source. + * + * Two additional properties will be set on the provided layer: + * + * * `mapbox-source`: The `id` of the Mapbox/MapLibre Style document's source that the + * OpenLayers layer was created from. Usually `apply()` creates one + * OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has + * layers from different sources in between. + * * `mapbox-layers`: The `id`s of the Mapbox/MapLibre Style document's layers that are + * included in the OpenLayers layer. + * + * @param {VectorTileLayer|VectorLayer} layer OpenLayers layer. When the layer has a source configured, + * it will be modified to use the configuration from the glStyle's `source`. Options specified on the + * layer's source will override those from the glStyle's `source`, except for `url` and + * `tileUrlFunction`. When the source projection is the default (`EPSG:3857`), the `tileGrid` will + * also be overridden. If you'd rather not have ol-mapbox-style modify the source, configure `applyStyle()` + * with the `updateSource: false` option. + * @param {string|Object} glStyle Mapbox/MapLibre Style object. + * @param {string|Array|Options&ApplyStyleOptions} [sourceOrLayersOrOptions] Options or + * `source` key or an array of layer `id`s from the Mapbox/MapLibre Style object. When a `source` key is + * provided, all layers for the specified source will be included in the style function. When layer + * `id`s are provided, they must be from layers that use the same source. When not provided or a falsey + * value, all layers using the first source specified in the glStyle will be rendered. + * @param {Options&ApplyStyleOptions|string} [optionsOrPath] **Deprecated**. Options. Alternatively the path of the style file + * (only required when a relative path is used for the `"sprite"` property of the style). + * @param {Array} [resolutions] **Deprecated**. Resolutions for mapping resolution to zoom level. + * Only needed when working with non-standard tile grids or projections, can also be supplied with + * options. + * @return {Promise} Promise which will be resolved when the style can be used + * for rendering. + */ +export function applyStyle(layer: VectorTileLayer | VectorLayer, glStyle: string | any, sourceOrLayersOrOptions?: string | Array | (Options & ApplyStyleOptions), optionsOrPath?: (Options & ApplyStyleOptions) | string, resolutions?: Array): Promise; +/** + * Applies properties of the Mapbox/MapLibre Style's first `background` layer to the + * provided map or layer (group). + * + * **Example:** + * ```js + * import {applyBackground} from 'ol-mapbox-style'; + * import {Map} from 'ol'; + * + * const map = new Map({target: 'map'}); + * applyBackground(map, 'https://api.maptiler.com/maps/basic/style.json?key=YOUR_OPENMAPTILES_TOKEN'); + * ``` + * @param {Map|import("ol/layer/Base.js").default} mapOrLayer OpenLayers Map or layer (group). + * @param {Object|string} glStyle Mapbox/MapLibre Style object or url. + * @param {Options} options Options. + * @return {Promise} Promise that resolves when the background is applied. + */ +export function applyBackground(mapOrLayer: Map | import("ol/layer/Base.js").default, glStyle: any | string, options?: Options): Promise; +/** + * Creates an OpenLayers VectorTile source for a gl source entry. + * @param {Object} glSource "source" entry from a Mapbox/MapLibre Style object. + * @param {string|undefined} styleUrl URL to use for the source. This is expected to be the complete http(s) url, + * with access key applied. + * @param {Options} options Options. + * @return {Promise} Promise resolving to a VectorTile source. + * @private + */ +export function setupVectorSource(glSource: any, styleUrl: string | undefined, options: Options): Promise; +export function setupLayer(glStyle: any, styleUrl: any, glLayer: any, options: any): Layer> | undefined; +/** + * Loads and applies a Mapbox/MapLibre Style object into an OpenLayers Map or LayerGroup. + * This includes the map background, the layers, and for Map instances that did not + * have a View defined yet also the center and the zoom. + * + * **Example:** + * ```js + * import apply from 'ol-mapbox-style'; + * + * apply('map', 'mapbox://styles/mapbox/bright-v9', {accessToken: 'YOUR_MAPBOX_TOKEN'}); + * ``` + * + * The center and zoom will only be set if present in the Mapbox/MapLibre Style document, + * and if not already set on the OpenLayers map. + * + * Layers will be added to the OpenLayers map, without affecting any layers that + * might already be set on the map. + * + * Layers added by `apply()` will have two additional properties: + * + * * `mapbox-source`: The `id` of the Mapbox/MapLibre Style document's source that the + * OpenLayers layer was created from. Usually `apply()` creates one + * OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has + * layers from different sources in between. + * * `mapbox-layers`: The `id`s of the Mapbox/MapLibre Style document's layers that are + * included in the OpenLayers layer. + * + * This function sets an additional `mapbox-style` property on the OpenLayers + * Map or LayerGroup instance, which holds the Mapbox/MapLibre Style object. + * + * @param {Map|HTMLElement|string|LayerGroup} mapOrGroupOrElement Either an existing + * OpenLayers Map instance, or a HTML element, or the id of a HTML element that will be + * the target of a new OpenLayers Map, or a layer group. If layer group, styles + * releated to the map and view will be ignored. + * @param {string|Object} style JSON style object or style url pointing to a + * Mapbox/MapLibre Style object. When using Mapbox APIs, the url is the `styleUrl` + * shown in Mapbox Studio's "share" panel. In addition, the `accessToken` option + * (see below) must be set. + * When passed as JSON style object, all OpenLayers layers created by `apply()` + * will be immediately available, but they may not have a source yet (i.e. when + * they are defined by a TileJSON url in the Mapbox/MapLibre Style document). When passed + * as style url, layers will be added to the map when the Mapbox/MapLibre Style document + * is loaded and parsed. + * @param {Options} options Options. + * @return {Promise} A promise that resolves after all layers have been added to + * the OpenLayers Map instance or LayerGroup, their sources set, and their styles applied. The + * `resolve` callback will be called with the OpenLayers Map instance or LayerGroup as + * argument. + */ +export function apply(mapOrGroupOrElement: Map | HTMLElement | string | LayerGroup, style: string | any, options?: Options): Promise; +/** + * If layerIds is not empty, applies the style specified in glStyle to the layer, + * and adds the layer to the map. + * + * The layer may not yet have a source when the function is called. If so, the style + * is applied to the layer via a once listener on the 'change:source' event. + * + * @param {Layer} layer An OpenLayers layer instance. + * @param {Array} layerIds Array containing layer ids of already-processed layers. + * @param {Object} glStyle Style as a JSON object. + * @param {string|undefined} styleUrl The original style URL. Only required + * when a relative path is used with the `"sprite"` property of the style. + * @param {Map|LayerGroup} mapOrGroup OpenLayers Map. + * @param {Options} options Options. + * @return {Promise} Returns a promise that resolves after the source has + * been set on the specified layer, and the style has been applied. + */ +export function finalizeLayer(layer: Layer, layerIds: Array, glStyle: any, styleUrl: string | undefined, mapOrGroup: Map | LayerGroup, options?: Options): Promise; +/** + * Get the Mapbox Layer object for the provided `layerId`. + * @param {Map|LayerGroup} mapOrGroup Map or LayerGroup. + * @param {string} layerId Mapbox Layer id. + * @return {Object} Mapbox Layer object. + */ +export function getMapboxLayer(mapOrGroup: Map | LayerGroup, layerId: string): any; +/** + * Add a new Mapbox Layer object to the style. The map will be re-rendered. + * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on. + * @param {Object} mapboxLayer Mapbox Layer object. + * @param {string} [beforeLayerId] Optional id of the Mapbox Layer before the new layer that will be added. + * @return {Promise} Resolves when the added layer is available. + */ +export function addMapboxLayer(mapOrGroup: Map | LayerGroup, mapboxLayer: any, beforeLayerId?: string): Promise; +/** + * Update a Mapbox Layer object in the style. The map will be re-rendered with the new style. + * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on. + * @param {Object} mapboxLayer Updated Mapbox Layer object. + */ +export function updateMapboxLayer(mapOrGroup: Map | LayerGroup, mapboxLayer: any): void; +/** + * Updates a Mapbox source object in the style. The according OpenLayers source will be replaced + * and the map will be re-rendered. + * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on. + * @param {string} id Key of the source in the `sources` object literal. + * @param {Object} mapboxSource Mapbox source object. + * @return {Promise} Promise that resolves when the source has been updated. + */ +export function updateMapboxSource(mapOrGroup: Map | LayerGroup, id: string, mapboxSource: any): Promise; +/** + * Remove a Mapbox Layer object from the style. The map will be re-rendered. + * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on. + * @param {string|Object} mapboxLayerIdOrLayer Mapbox Layer id or Mapbox Layer object. + */ +export function removeMapboxLayer(mapOrGroup: Map | LayerGroup, mapboxLayerIdOrLayer: string | any): void; +/** + * Get the OpenLayers layer instance that contains the provided Mapbox/MapLibre Style + * `layer`. Note that multiple Mapbox/MapLibre Style layers are combined in a single + * OpenLayers layer instance when they use the same Mapbox/MapLibre Style `source`. + * @param {Map|LayerGroup} map OpenLayers Map or LayerGroup. + * @param {string} layerId Mapbox/MapLibre Style layer id. + * @return {Layer} OpenLayers layer instance. + */ +export function getLayer(map: Map | LayerGroup, layerId: string): Layer; +/** + * Get the OpenLayers layer instances for the provided Mapbox/MapLibre Style `source`. + * @param {Map|LayerGroup} map OpenLayers Map or LayerGroup. + * @param {string} sourceId Mapbox/MapLibre Style source id. + * @return {Array} OpenLayers layer instances. + */ +export function getLayers(map: Map | LayerGroup, sourceId: string): Array; +/** + * Get the OpenLayers source instance for the provided Mapbox/MapLibre Style `source`. + * @param {Map|LayerGroup} map OpenLayers Map or LayerGroup. + * @param {string} sourceId Mapbox/MapLibre Style source id. + * @return {Source} OpenLayers source instance. + */ +export function getSource(map: Map | LayerGroup, sourceId: string): Source; +/** + * Sets or removes a feature state. The feature state is taken into account for styling, + * just like the feature's properties, and can be used e.g. to conditionally render selected + * features differently. + * + * The feature state will be stored on the OpenLayers layer matching the feature identifier, in the + * `mapbox-featurestate` property. + * @param {Map|VectorLayer|VectorTileLayer} mapOrLayer OpenLayers Map or layer to set the feature + * state on. + * @param {FeatureIdentifier} feature Feature identifier. + * @param {Object|null} state Feature state. Set to `null` to remove the feature state. + */ +export function setFeatureState(mapOrLayer: Map | VectorLayer | VectorTileLayer, feature: FeatureIdentifier, state: any | null): void; +/** + * Sets or removes a feature state. The feature state is taken into account for styling, + * just like the feature's properties, and can be used e.g. to conditionally render selected + * features differently. + * @param {Map|VectorLayer|VectorTileLayer} mapOrLayer Map or layer to set the feature state on. + * @param {FeatureIdentifier} feature Feature identifier. + * @return {Object|null} Feature state or `null` when no feature state is set for the given + * feature identifier. + */ +export function getFeatureState(mapOrLayer: Map | VectorLayer | VectorTileLayer, feature: FeatureIdentifier): any | null; +export type FeatureIdentifier = { + /** + * The feature id. + */ + id: string | number; + /** + * The source id. + */ + source: string; +}; +export type Options = { + /** + * Access token for 'mapbox://' urls. + */ + accessToken?: string | undefined; + /** + * Function for controlling how `ol-mapbox-style` fetches resources. Can be used for modifying + * the url, adding headers or setting credentials options. Called with the url and the resource + * type as arguments, this function is supposed to return a `Request` or a url `string`, or a promise tehereof. + * Without a return value the original request will not be modified. + */ + transformRequest?: ((arg0: string, arg1: import("./util.js").ResourceType) => (Request | string | Promise | void)) | undefined; + /** + * Only useful when working with non-standard projections. + * Code of a projection registered with OpenLayers. All sources of the style must be provided in this + * projection. The projection must also have a valid extent defined, which will be used to determine the + * origin and resolutions of the tile grid for all tiled sources of the style. When provided, the bbox + * placeholder in tile and geojson urls changes: the default is `{bbox-epsg-3857}`, when projection is e.g. + * set to `EPSG:4326`, the bbox placeholder will be `{bbox-epsg-4326}`. + */ + projection?: string | undefined; + /** + * Only useful when working with non-standard projections. + * Resolutions for mapping resolution to the `zoom` used in the Mapbox/MapLibre style. + */ + resolutions?: number[] | undefined; + /** + * URL of the Mapbox GL style. Required for styles that were provided + * as object, when they contain a relative sprite url, or sources referencing data by relative url. + */ + styleUrl?: string | undefined; + /** + * Template for resolving webfonts. Can be used to specify where to fetch + * web fonts when no `ol:webfonts` metadata is set in the style object. See `getFonts()` and the + * "Font handling" section in `README.md` for details. + */ + webfonts?: string | undefined; + /** + * Function that returns an image for an icon name. If the result is an HTMLImageElement, it must already be + * loaded. The layer can be used to call layer.changed() when the loading and processing of the image has finished. + * This function be used for icons not in the sprite or to override sprite icons. + */ + getImage?: ((arg0: VectorLayer | VectorTileLayer, arg1: string) => HTMLImageElement | HTMLCanvasElement | string | undefined) | undefined; + /** + * Access token param. For internal use. + */ + accessTokenParam?: string | undefined; +}; +export type ApplyStyleOptions = { + /** + * Source. Default is `''`, which causes the first source in the + * style to be used. + */ + source?: string | undefined; + /** + * Layers. If no source is provided, the layers with the + * provided ids will be used from the style's `layers` array. All layers need to use the same source. + */ + layers?: string[] | undefined; + /** + * Update or create vector (tile) layer source with parameters + * specified for the source in the mapbox style definition. + */ + updateSource?: boolean | undefined; +}; +import VectorTileLayer from 'ol/layer/VectorTile.js'; +import VectorLayer from 'ol/layer/Vector.js'; +import Map from 'ol/Map.js'; +import Source from 'ol/source/Source.js'; +import Layer from 'ol/layer/Layer.js'; +import LayerGroup from 'ol/layer/Group.js'; diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 00000000..8c360a22 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +export { default as MapboxVectorLayer } from "./MapboxVectorLayer.js"; +export { getStyleForLayer, recordStyleLayer, renderTransparent, stylefunction } from "./stylefunction.js"; +export { addMapboxLayer, apply, apply as default, applyBackground, applyStyle, getFeatureState, getLayer, getLayers, getMapboxLayer, getSource, removeMapboxLayer, setFeatureState, updateMapboxLayer, updateMapboxSource } from "./apply.js"; diff --git a/dist/mapbox.d.ts b/dist/mapbox.d.ts new file mode 100644 index 00000000..6d4d9c06 --- /dev/null +++ b/dist/mapbox.d.ts @@ -0,0 +1,34 @@ +/** + * Gets the path from a mapbox:// URL. + * @param {string} url The Mapbox URL. + * @return {string} The path. + * @private + */ +export function getMapboxPath(url: string): string; +/** + * Turns mapbox:// sprite URLs into resolvable URLs. + * @param {string} url The sprite URL. + * @param {string} token The access token. + * @param {string} styleUrl The style URL. + * @return {string} A resolvable URL. + * @private + */ +export function normalizeSpriteUrl(url: string, token: string, styleUrl: string): string; +/** + * Turns mapbox:// style URLs into resolvable URLs. + * @param {string} url The style URL. + * @param {string} token The access token. + * @return {string} A resolvable URL. + * @private + */ +export function normalizeStyleUrl(url: string, token: string): string; +/** + * Turns mapbox:// source URLs into vector tile URL templates. + * @param {string} url The source URL. + * @param {string} token The access token. + * @param {string} tokenParam The access token key. + * @param {string} styleUrl The style URL. + * @return {Array} A vector tile template. + * @private + */ +export function normalizeSourceUrl(url: string, token: string, tokenParam: string, styleUrl: string): Array; diff --git a/dist/olms.js b/dist/olms.js new file mode 100644 index 00000000..20137cb5 --- /dev/null +++ b/dist/olms.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ol/functions.js"),require("ol/render/Feature.js"),require("ol/style/Circle.js"),require("ol/style/Fill.js"),require("ol/style/Icon.js"),require("ol/style/Stroke.js"),require("ol/style/Style.js"),require("ol/style/Text.js"),require("ol/render/canvas.js"),require("ol"),require("ol/TileState.js"),require("ol/util.js"),require("ol/Map.js"),require("ol/View.js"),require("ol/extent.js"),require("ol/format/GeoJSON.js"),require("ol/format/MVT.js"),require("ol/layer/Group.js"),require("ol/layer/Image.js"),require("ol/layer/Layer.js"),require("ol/layer/Tile.js"),require("ol/layer/Vector.js"),require("ol/layer/VectorTile.js"),require("ol/loadingstrategy.js"),require("ol/proj/Units.js"),require("ol/proj.js"),require("ol/source/Raster.js"),require("ol/source/Source.js"),require("ol/source/TileJSON.js"),require("ol/source/Vector.js"),require("ol/source/VectorTile.js"),require("ol/tilegrid/TileGrid.js"),require("ol/tilegrid.js"),require("ol/events/Event.js"),require("ol/events/EventType.js")):"function"==typeof define&&define.amd?define(["exports","ol/functions.js","ol/render/Feature.js","ol/style/Circle.js","ol/style/Fill.js","ol/style/Icon.js","ol/style/Stroke.js","ol/style/Style.js","ol/style/Text.js","ol/render/canvas.js","ol","ol/TileState.js","ol/util.js","ol/Map.js","ol/View.js","ol/extent.js","ol/format/GeoJSON.js","ol/format/MVT.js","ol/layer/Group.js","ol/layer/Image.js","ol/layer/Layer.js","ol/layer/Tile.js","ol/layer/Vector.js","ol/layer/VectorTile.js","ol/loadingstrategy.js","ol/proj/Units.js","ol/proj.js","ol/source/Raster.js","ol/source/Source.js","ol/source/TileJSON.js","ol/source/Vector.js","ol/source/VectorTile.js","ol/tilegrid/TileGrid.js","ol/tilegrid.js","ol/events/Event.js","ol/events/EventType.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).olms={},e.ol.functions,e.ol.render.Feature,e.ol.style.Circle,e.ol.style.Fill,e.ol.style.Icon,e.ol.style.Stroke,e.ol.style.Style,e.ol.style.Text,e.ol.render.canvas,e.ol,e.ol.TileState,e.ol.util,e.ol.Map,e.ol.View,e.ol.extent,e.ol.format.GeoJSON,e.ol.format.MVT,e.ol.layer.Group,e.ol.layer.Image,e.ol.layer.Layer,e.ol.layer.Tile,e.ol.layer.Vector,e.ol.layer.VectorTile,e.ol.loadingstrategy,e.ol.proj.Units,e.ol.proj,e.ol.source.Raster,e.ol.source.Source,e.ol.source.TileJSON,e.ol.source.Vector,e.ol.source.VectorTile,e.ol.tilegrid.TileGrid,e.ol.tilegrid,e.ol.events.Event,e.ol.events.EventType)}(this,(function(e,t,r,n,o,i,a,s,l,u,p,c,f,d,y,m,h,g,v,b,x,w,k,M,z,j,S,q,E,$,T,A,_,C,I,P){"use strict";function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var O=N(r),L=N(n),F=N(o),R=N(i),U=N(a),D=N(s),G=N(l),V=N(c),J=N(d),W=N(y),Z=N(h),B=N(g),X=N(v),H=N(b),Y=N(x),K=N(w),Q=N(k),ee=N(M),te=N(q),re=N(E),ne=N($),oe=N(T),ie=N(A),ae=N(_),se=N(I),le=N(P),ue={$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 pe=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ce(e,t){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return pe.forEach((e=>{e in t&&(r[e]=t[e])})),r}function fe(e){e=e.slice();const t=Object.create(null);for(let r=0;r`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Te=[me,he,ge,ve,be,xe,ze,we,Ee(ke),je,Se,qe];function Ae(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Ae(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Te)if(!Ae(e,t))return null}return`Expected ${$e(e)} but found ${$e(t)} instead.`}function _e(e,t){return t.some((t=>t.kind===e.kind))}function Ce(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function Ie(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const Pe=.96422,Ne=1,Oe=.82521,Le=4/29,Fe=6/29,Re=3*Fe*Fe,Ue=Fe*Fe*Fe,De=Math.PI/180,Ge=180/Math.PI;function Ve(e){return(e%=360)<0&&(e+=360),e}function Je([e,t,r,n]){let o,i;const a=Ze((.2225045*(e=We(e))+.7168786*(t=We(t))+.0606169*(r=We(r)))/Ne);e===t&&t===r?o=i=a:(o=Ze((.4360747*e+.3850649*t+.1430804*r)/Pe),i=Ze((.0139322*e+.0971045*t+.7141733*r)/Oe));const s=116*a-16;return[s<0?0:s,500*(o-a),200*(a-i),n]}function We(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ze(e){return e>Ue?Math.pow(e,1/3):e/Re+Le}function Be([e,t,r,n]){let o=(e+16)/116,i=isNaN(t)?o:o+t/500,a=isNaN(r)?o:o-r/200;return o=Ne*He(o),i=Pe*He(i),a=Oe*He(a),[Xe(3.1338561*i-1.6168667*o-.4906146*a),Xe(-.9787684*i+1.9161415*o+.033454*a),Xe(.0719453*i-.2289914*o+1.4052427*a),n]}function Xe(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function He(e){return e>Fe?e*e*e:Re*(e-Le)}function Ye(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=rt[e];if(t){const[e,r,n]=t;return[e/255,r/255,n/255,1]}if(e.startsWith("#")){if(/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let r=1;return[Ke(e.slice(r,r+=t)),Ke(e.slice(r,r+=t)),Ke(e.slice(r,r+=t)),Ke(e.slice(r,r+t)||"ff")]}}if(e.startsWith("rgb")){const t=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/,r=e.match(t);if(r){const[e,t,n,o,i,a,s,l,u,p,c,f]=r,d=[o||" ",s||" ",p].join("");if(" "===d||" /"===d||",,"===d||",,,"===d){const e=[n,a,u].join(""),r="%%%"===e?100:""===e?255:0;if(r){const e=[et(+t/r,0,1),et(+i/r,0,1),et(+l/r,0,1),c?Qe(+c,f):1];if(tt(e))return e}}return}}const r=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[e,t,n,o,i,a,s,l,u]=r,p=[n||" ",i||" ",s].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[+t,et(+o,0,100),et(+a,0,100),l?Qe(+l,u):1];if(tt(e))return function([e,t,r,n]){function o(n){const o=(n+e/30)%12,i=t*Math.min(r,1-r);return r-i*Math.max(-1,Math.min(o-3,9-o,1))}return e=Ve(e),t/=100,r/=100,[o(0),o(8),o(4),n]}(e)}}}function Ke(e){return parseInt(e.padEnd(2,e),16)/255}function Qe(e,t){return et(t?e/100:e,0,1)}function et(e,t,r){return Math.min(Math.max(t,e),r)}function tt(e){return!e.some(Number.isNaN)}const rt={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 nt(e,t,r){return e+r*(t-e)}function ot(e,t,r){return e.map(((e,n)=>nt(e,t[n],r)))}class it{constructor(e,t,r,n=1,o=!0){this.r=e,this.g=t,this.b=r,this.a=n,o||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,r,n]))}static parse(e){if(e instanceof it)return e;if("string"!=typeof e)return;const t=Ye(e);return t?new it(...t,!1):void 0}get rgb(){const{r:e,g:t,b:r,a:n}=this,o=n||1/0;return this.overwriteGetter("rgb",[e/o,t/o,r/o,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,r,n,o]=Je(e),i=Math.sqrt(r*r+n*n);return[Math.round(1e4*i)?Ve(Math.atan2(n,r)*Ge):NaN,i,t,o]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Je(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,r,n]=this.rgb;return`rgba(${[e,t,r].map((e=>Math.round(255*e))).join(",")},${n})`}static interpolate(e,t,r,n="rgb"){switch(n){case"rgb":{const[n,o,i,a]=ot(e.rgb,t.rgb,r);return new it(n,o,i,a,!1)}case"hcl":{const[n,o,i,a]=e.hcl,[s,l,u,p]=t.hcl;let c,f;if(isNaN(n)||isNaN(s))isNaN(n)?isNaN(s)?c=NaN:(c=s,1!==i&&0!==i||(f=l)):(c=n,1!==u&&0!==u||(f=o));else{let e=s-n;s>n&&e>180?e-=360:s180&&(e+=360),c=n+r*e}const[d,y,m,h]=function([e,t,r,n]){return e=isNaN(e)?0:e*De,Be([r,Math.cos(e)*t,Math.sin(e)*t,n])}([c,null!=f?f:nt(o,l,r),nt(i,u,r),nt(a,p,r)]);return new it(d,y,m,h,!1)}case"lab":{const[n,o,i,a]=Be(ot(e.lab,t.lab,r));return new it(n,o,i,a,!1)}}}}it.black=new it(0,0,0,1),it.white=new it(1,1,1,1),it.transparent=new it(0,0,0,0),it.red=new it(1,0,0,1);class at{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const st=["bottom","center","top"];class lt{constructor(e,t,r,n,o,i){this.text=e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=o,this.verticalAlign=i}}class ut{constructor(e){this.sections=e}static fromString(e){return new ut([new lt(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof ut?e:ut.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}}class pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof pt)return e;if("number"==typeof e)return new pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,r){return new pt(ot(e.values,t.values,r))}}class ct{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const ft=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class dt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof dt)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255)){return`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}return void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`}function gt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof mt||e instanceof it||e instanceof at||e instanceof ut||e instanceof pt||e instanceof dt||e instanceof yt)return!0;if(Array.isArray(e)){for(const t of e)if(!gt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!gt(e[t]))return!1;return!0}return!1}function vt(e){if(null===e)return me;if("string"==typeof e)return ge;if("boolean"==typeof e)return ve;if("number"==typeof e)return he;if(e instanceof it)return be;if(e instanceof mt)return xe;if(e instanceof at)return Me;if(e instanceof ut)return ze;if(e instanceof pt)return je;if(e instanceof dt)return qe;if(e instanceof yt)return Se;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=vt(t);if(r){if(r===e)continue;r=ke;break}r=e}return Ee(r||ke,t)}return we}function bt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof it||e instanceof mt||e instanceof ut||e instanceof pt||e instanceof dt||e instanceof yt?e.toString():JSON.stringify(e)}class xt{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!gt(e[1]))return t.error("invalid value");const r=e[1];let n=vt(r);const o=t.expectedType;return"array"!==n.kind||0!==n.N||!o||"array"!==o.kind||"number"==typeof o.N&&0!==o.N||(n=o),new xt(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const wt={string:ge,number:he,boolean:ve,object:we};class kt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const o=e[0];if("array"===o){let o,i;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in wt)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);o=wt[r],n++}else o=ke;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);i=e[2],n++}r=Ee(o,i)}else{if(!wt[o])throw new Error(`Types doesn't contain name = ${o}`);r=wt[o]}const i=[];for(;ne.outputDefined()))}}const Mt={"to-boolean":ve,"to-color":be,"to-number":he,"to-string":ge};class zt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0];if(!Mt[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!==e.length)return t.error("Expected one argument.");const n=Mt[r],o=[];for(let r=1;r4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:ht(t[0],t[1],t[2],t[3]),!r))return new it(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new ct(r||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const r of this.args){t=r.evaluate(e);const n=pt.parse(t);if(n)return n}throw new ct(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const r of this.args){t=r.evaluate(e);const n=dt.parse(t);if(n)return n}throw new ct(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new ct(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return ut.fromString(bt(this.args[0].evaluate(e)));case"resolvedImage":return yt.fromString(bt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return bt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}const jt=["Unknown","Point","LineString","Polygon"];class St{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?jt[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(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=it.parse(e)),t}}class qt{constructor(e,t,r=[],n,o=new ye,i=[]){this.registry=e,this.path=r,this.key=r.map((e=>`[${e}]`)).join(""),this.scope=o,this.errors=i,this.expectedType=n,this._isConstant=t}parse(e,t,r,n,o={}){return t?this.concat(t,r,n)._parse(e,o):this._parse(e,o)}_parse(e,t){function r(e,t,r){return"assert"===r?new kt(t,[e]):"coerce"===r?new zt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=e[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 o=this.registry[n];if(o){let n=o.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,o=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==o.kind)if("projectionDefinition"!==e.kind||"string"!==o.kind&&"array"!==o.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==o.kind&&"string"!==o.kind)if("padding"!==e.kind||"value"!==o.kind&&"number"!==o.kind&&"array"!==o.kind)if("variableAnchorOffsetCollection"!==e.kind||"value"!==o.kind&&"array"!==o.kind){if(this.checkSubtype(e,o))return null}else n=r(n,e,t.typeAnnotation||"coerce");else n=r(n,e,t.typeAnnotation||"coerce");else n=r(n,e,t.typeAnnotation||"coerce");else n=r(n,e,t.typeAnnotation||"coerce");else n=r(n,e,t.typeAnnotation||"assert")}if(!(n instanceof xt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const e=new St;try{n=new xt(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===e?this.error("'undefined' value invalid. Use null instead."):"object"==typeof e?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(e,t,r){const n="number"==typeof e?this.path.concat(e):this.path,o=r?this.scope.concat(r):this.scope;return new qt(this.registry,this._isConstant,n,t||null,o,this.errors)}error(e,...t){const r=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new de(r,e))}checkSubtype(e,t){const r=Ae(e,t);return r&&this.error(r),r}}class Et{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new ct(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t!==Math.floor(t))throw new ct(`Array index must be an integer, but found ${t} instead.`);return r[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class At{constructor(e,t){this.type=ve,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,ke),n=t.parse(e[2],2,ke);return r&&n?_e(r.type,[ve,ge,he,me,ke])?new At(r,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${$e(r.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!r)return!1;if(!Ce(t,["boolean","string","number","null"]))throw new ct(`Expected first argument to be of type boolean, string, number or null, but found ${$e(vt(t))} instead.`);if(!Ce(r,["string","array"]))throw new ct(`Expected second argument to be of type array or string, but found ${$e(vt(r))} instead.`);return r.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class _t{constructor(e,t,r){this.type=he,this.needle=e,this.haystack=t,this.fromIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,ke),n=t.parse(e[2],2,ke);if(!r||!n)return null;if(!_e(r.type,[ve,ge,he,me,ke]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${$e(r.type)} instead`);if(4===e.length){const o=t.parse(e[3],3,he);return o?new _t(r,n,o):null}return new _t(r,n)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Ce(t,["boolean","string","number","null"]))throw new ct(`Expected first argument to be of type boolean, string, number or null, but found ${$e(vt(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),Ce(r,["string"])){const e=r.indexOf(t,n);return-1===e?-1:[...r.slice(0,e)].length}if(Ce(r,["array"]))return r.indexOf(t,n);throw new ct(`Expected second argument to be of type array or string, but found ${$e(vt(r))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class Ct{constructor(e,t,r,n,o,i){this.inputType=e,this.type=t,this.input=r,this.cases=n,this.outputs=o,this.otherwise=i}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const o={},i=[];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 e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,vt(e)))return null}else r=vt(e);if(void 0!==o[String(e)])return u.error("Branch labels must be unique.");o[String(e)]=i.length}const p=t.parse(l,a,n);if(!p)return null;n=n||p.type,i.push(p)}const a=t.parse(e[1],1,ke);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,n);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(r,a.type)?null:new Ct(r,n,a,o,i,s):null}evaluate(e){const t=this.input.evaluate(e);return(vt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}}class It{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n=[];for(let o=1;ot.outputDefined()))&&this.otherwise.outputDefined()}}class Pt{constructor(e,t,r,n){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,ke),n=t.parse(e[2],2,he);if(!r||!n)return null;if(!_e(r.type,[Ee(ke),ge,ke]))return t.error(`Expected first argument to be of type array or string, but found ${$e(r.type)} instead`);if(4===e.length){const o=t.parse(e[3],3,he);return o?new Pt(r.type,r,n,o):null}return new Pt(r.type,r,n)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),Ce(t,["string"]))return[...t].slice(r,n).join("");if(Ce(t,["array"]))return t.slice(r,n);throw new ct(`Expected first argument to be of type array or string, but found ${$e(vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Nt(e,t){const r=e.length-1;let n,o,i=0,a=r,s=0;for(;i<=a;)if(s=Math.floor((i+a)/2),n=e[s],o=e[s+1],n<=t){if(s===r||tt))throw new ct("Input is not a number.");a=s-1}return 0}class Ot{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,he);if(!r)return null;const n=[];let o=null;t.expectedType&&"value"!==t.expectedType.kind&&(o=t.expectedType);for(let r=1;r=i)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(a,l,o);if(!u)return null;o=o||u.type,n.push([i,u])}return new Ot(o,r,n)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const o=t.length;if(n>=t[o-1])return r[o-1].evaluate(e);return r[Nt(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Lt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ft,Rt;var Ut=function(){if(Rt)return Ft;function e(e,t,r,n){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=n}return Rt=1,Ft=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,n=0;n<8;n++){var o=this.sampleCurveX(r)-e;if(Math.abs(o)o?a=r:s=r,r=.5*(s-a)+a;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},Ft}(),Dt=Lt(Ut);class Gt{constructor(e,t,r,n,o){this.type=e,this.operator=t,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of o)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,r,n){let o=0;if("exponential"===e.name)o=Vt(t,e.base,r,n);else if("linear"===e.name)o=Vt(t,1,r,n);else if("cubic-bezier"===e.name){const i=e.controlPoints;o=new Dt(i[0],i[1],i[2],i[3]).solve(Vt(t,1,r,n))}return o}static parse(e,t){let[r,n,o,...i]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(o=t.parse(o,2,he),!o)return null;const a=[];let s=null;"interpolate-hcl"===r||"interpolate-lab"===r?s=be:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const u=t.parse(n,l,s);if(!u)return null;s=s||u.type,a.push([r,u])}return Ie(s,he)||Ie(s,xe)||Ie(s,be)||Ie(s,je)||Ie(s,qe)||Ie(s,Ee(he))?new Gt(s,r,n,o,a):t.error(`Type ${$e(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const o=t.length;if(n>=t[o-1])return r[o-1].evaluate(e);const i=Nt(t,n),a=t[i],s=t[i+1],l=Gt.interpolationFactor(this.interpolation,n,a,s),u=r[i].evaluate(e),p=r[i+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return nt(u,p,l);case"color":return it.interpolate(u,p,l);case"padding":return pt.interpolate(u,p,l);case"variableAnchorOffsetCollection":return dt.interpolate(u,p,l);case"array":return ot(u,p,l);case"projectionDefinition":return mt.interpolate(u,p,l)}case"interpolate-hcl":return it.interpolate(u,p,l,"hcl");case"interpolate-lab":return it.interpolate(u,p,l,"lab")}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}}function Vt(e,t,r,n){const o=n-r,i=e-r;return 0===o?0:1===t?i/o:(Math.pow(t,i)-1)/(Math.pow(t,o)-1)}it.interpolate,pt.interpolate,dt.interpolate;class Jt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r=null;const n=t.expectedType;n&&"value"!==n.kind&&(r=n);const o=[];for(const n of e.slice(1)){const e=t.parse(n,1+o.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,o.push(e)}if(!r)throw new Error("No output type");const i=n&&o.some((e=>Ae(n,e.type)));return new Jt(i?ke:r,o)}evaluate(e){let t,r=null,n=0;for(const o of this.args)if(n++,r=o.evaluate(e),r&&r instanceof yt&&!r.available&&(t||(t=r.name),r=null,n===this.args.length&&(r=t)),null!==r)break;return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}}function Wt(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function Zt(e,t,r,n){return 0===n.compare(t,r)}function Bt(e,t,r){const n="=="!==e&&"!="!==e;return class o{constructor(e,t,r){this.type=ve,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let i=t.parse(e[1],1,ke);if(!i)return null;if(!Wt(r,i.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${$e(i.type)}'.`);let a=t.parse(e[2],2,ke);if(!a)return null;if(!Wt(r,a.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${$e(a.type)}'.`);if(i.type.kind!==a.type.kind&&"value"!==i.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${$e(i.type)}' and '${$e(a.type)}'.`);n&&("value"===i.type.kind&&"value"!==a.type.kind?i=new kt(a.type,[i]):"value"!==i.type.kind&&"value"===a.type.kind&&(a=new kt(i.type,[a])));let s=null;if(4===e.length){if("string"!==i.type.kind&&"string"!==a.type.kind&&"value"!==i.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,Me),!s)return null}return new o(i,a,s)}evaluate(o){const i=this.lhs.evaluate(o),a=this.rhs.evaluate(o);if(n&&this.hasUntypedArgument){const t=vt(i),r=vt(a);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new ct(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=vt(i),r=vt(a);if("string"!==e.kind||"string"!==r.kind)return t(o,i,a)}return this.collator?r(o,i,a,this.collator.evaluate(o)):t(o,i,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const Xt=Bt("==",(function(e,t,r){return t===r}),Zt),Ht=Bt("!=",(function(e,t,r){return t!==r}),(function(e,t,r,n){return!Zt(0,t,r,n)})),Yt=Bt("<",(function(e,t,r){return t",(function(e,t,r){return t>r}),(function(e,t,r,n){return n.compare(t,r)>0})),Qt=Bt("<=",(function(e,t,r){return t<=r}),(function(e,t,r,n){return n.compare(t,r)<=0})),er=Bt(">=",(function(e,t,r){return t>=r}),(function(e,t,r,n){return n.compare(t,r)>=0}));class tr{constructor(e,t,r){this.type=Me,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const r=e[1];if("object"!=typeof r||Array.isArray(r))return t.error("Collator options argument must be an object.");const n=t.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,ve);if(!n)return null;const o=t.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,ve);if(!o)return null;let i=null;return r.locale&&(i=t.parse(r.locale,1,ge),!i)?null:new tr(n,o,i)}evaluate(e){return new at(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class rr{constructor(e,t,r,n,o){this.type=ge,this.number=e,this.locale=t,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,he);if(!r)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let o=null;if(n.locale&&(o=t.parse(n.locale,1,ge),!o))return null;let i=null;if(n.currency&&(i=t.parse(n.currency,1,ge),!i))return null;let a=null;if(n["min-fraction-digits"]&&(a=t.parse(n["min-fraction-digits"],1,he),!a))return null;let s=null;return n["max-fraction-digits"]&&(s=t.parse(n["max-fraction-digits"],1,he),!s)?null:new rr(r,o,i,a,s)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class nr{constructor(e){this.type=ze,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let o=!1;for(let r=1;r<=e.length-1;++r){const i=e[r];if(o&&"object"==typeof i&&!Array.isArray(i)){o=!1;let e=null;if(i["font-scale"]&&(e=t.parse(i["font-scale"],1,he),!e))return null;let r=null;if(i["text-font"]&&(r=t.parse(i["text-font"],1,Ee(ge)),!r))return null;let a=null;if(i["text-color"]&&(a=t.parse(i["text-color"],1,be),!a))return null;let s=null;if(i["vertical-align"]){if("string"==typeof i["vertical-align"]&&!st.includes(i["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${i["vertical-align"]}' instead.`);if(s=t.parse(i["vertical-align"],1,ge),!s)return null}const l=n[n.length-1];l.scale=e,l.font=r,l.textColor=a,l.verticalAlign=s}else{const i=t.parse(e[r],1,ke);if(!i)return null;const a=i.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");o=!0,n.push({content:i,scale:null,font:null,textColor:null,verticalAlign:null})}}return new nr(n)}evaluate(e){return new ut(this.sections.map((t=>{const r=t.content.evaluate(e);return vt(r)===Se?new lt("",r,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new lt(bt(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class or{constructor(e){this.type=Se,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,ge);return r?new or(r):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),r=yt.fromString(t);return r&&e.availableImages&&(r.available=e.availableImages.indexOf(t)>-1),r}eachChild(e){e(this.input)}outputDefined(){return!1}}class ir{constructor(e){this.type=he,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?t.error(`Expected argument of type string or array, but found ${$e(r.type)} instead.`):new ir(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return[...t].length;if(Array.isArray(t))return t.length;throw new ct(`Expected value to be of type string or array, but found ${$e(vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const ar=8192;function sr(e,t){const r=(180+e[0])/360;const n=(o=e[1],(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+o*Math.PI/360)))/360);var o;const i=Math.pow(2,t.z);return[Math.round(r*i*ar),Math.round(n*i*ar)]}function lr(e,t){const r=Math.pow(2,t.z),n=(e[0]/ar+t.x)/r,o=(e[1]/ar+t.y)/r;return[(a=n,360*a-180),(i=o,360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90)];var i,a}function ur(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function pr(e,t){return!(e[0]<=t[0])&&(!(e[2]>=t[2])&&(!(e[1]<=t[1])&&!(e[3]>=t[3])))}function cr(e,t,r){const n=e[0]-t[0],o=e[1]-t[1],i=e[0]-r[0],a=e[1]-r[1];return n*a-i*o==0&&n*i<=0&&o*a<=0}function fr(e,t,r,n){const o=[t[0]-e[0],t[1]-e[1]],i=[n[0]-r[0],n[1]-r[1]];return 0!=(a=i)[0]*(s=o)[1]-a[1]*s[0]&&!(!vr(e,t,r,n)||!vr(r,n,e,t));var a,s}function dr(e,t,r){for(const n of r)for(let r=0;ro[1]!=a[1]>o[1]&&o[0]<(a[0]-i[0])*(o[1]-i[1])/(a[1]-i[1])+i[0]&&(n=!n)}var o,i,a;return n}function mr(e,t){for(const r of t)if(yr(e,r))return!0;return!1}function hr(e,t){for(const r of e)if(!yr(r,t))return!1;for(let r=0;r0&&c<0||p<0&&c>0}function br(e,t,r){const n=[];for(let o=0;or[2]){const t=.5*n;let o=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===o&&(o=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=o}ur(t,e)}function kr(e,t,r,n){const o=Math.pow(2,n.z)*ar,i=[n.x*ar,n.y*ar],a=[];for(const n of e)for(const e of n){const n=[e.x+i[0],e.y+i[1]];wr(n,t,r,o),a.push(n)}return a}function Mr(e,t,r,n){const o=Math.pow(2,n.z)*ar,i=[n.x*ar,n.y*ar],a=[];for(const r of e){const e=[];for(const n of r){const r=[n.x+i[0],n.y+i[1]];ur(t,r),e.push(r)}a.push(e)}if(t[2]-t[0]<=o/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const n of e)wr(n,t,r,o)}var s;return a}class zr{constructor(e,t){this.type=ve,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(gt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const r of t.features){const{type:t,coordinates:n}=r.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length){return new zr(t,{type:"MultiPolygon",coordinates:e})}}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new zr(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new zr(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],o=e.canonicalID();if("Polygon"===t.type){const i=br(t.coordinates,n,o),a=kr(e.geometry(),r,n,o);if(!pr(r,n))return!1;for(const e of a)if(!yr(e,i))return!1}if("MultiPolygon"===t.type){const i=xr(t.coordinates,n,o),a=kr(e.geometry(),r,n,o);if(!pr(r,n))return!1;for(const e of a)if(!mr(e,i))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],o=e.canonicalID();if("Polygon"===t.type){const i=br(t.coordinates,n,o),a=Mr(e.geometry(),r,n,o);if(!pr(r,n))return!1;for(const e of a)if(!hr(e,i))return!1}if("MultiPolygon"===t.type){const i=xr(t.coordinates,n,o),a=Mr(e.geometry(),r,n,o);if(!pr(r,n))return!1;for(const e of a)if(!gr(e,i))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class jr{constructor(e=[],t=((e,t)=>et?1:0)){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=o}}function Sr(e,t,r=0,n=e.length-1,o=Er){for(;n>r;){if(n-r>600){const i=n-r+1,a=t-r+1,s=Math.log(i),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(i-l)/i)*(a-i/2<0?-1:1);Sr(e,t,Math.max(r,Math.floor(t-a*l/i+u)),Math.min(n,Math.floor(t+(i-a)*l/i+u)),o)}const i=e[t];let a=r,s=n;for(qr(e,r,t),o(e[n],i)>0&&qr(e,r,n);a0;)s--}0===o(e[r],i)?qr(e,r,s):(s++,qr(e,s,n)),s<=t&&(r=s+1),t<=s&&(n=s-1)}}function qr(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function Er(e,t){return et?1:0}function $r(e,t){return t.area-e.area}function Tr(e){let t=0;for(let r,n,o=0,i=e.length,a=i-1;o1?(l=e[s+1][0],u=e[s+1][1]):f>0&&(l+=p/this.kx*f,u+=c/this.ky*f)),p=this.wrap(t[0]-l)*this.kx,c=(t[1]-u)*this.ky;const d=p*p+c*c;d180;)e-=360;return e}}const Pr=100,Nr=50;function Or(e,t){return t[0]-e[0]}function Lr(e){return e[1]-e[0]+1}function Fr(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const r=Lr(e);if(t){if(2===r)return[e,null];const t=Math.floor(r/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===r)return[e,null];const n=Math.floor(r/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function Ur(e,t){if(!Fr(t,e.length))return[1/0,1/0,-1/0,-1/0];const r=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)ur(r,e[n]);return r}function Dr(e){const t=[1/0,1/0,-1/0,-1/0];for(const r of e)for(const e of r)ur(t,e);return t}function Gr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function Vr(e,t,r){if(!Gr(e)||!Gr(t))return NaN;let n=0,o=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(o=e[1]-t[3]),e[3]=n)return n;if(pr(o,i)){if(Yr(e,t))return 0}else if(Yr(t,e))return 0;let a=1/0;for(const n of e)for(let e=0,o=n.length,i=o-1;e0;){const o=a.pop();if(o[0]>=i)continue;const l=o[1],u=t?Nr:Pr;if(Lr(l)<=u){if(!Fr(l,e.length))return NaN;if(t){const t=Hr(e,l,r,n);if(isNaN(t)||0===t)return t;i=Math.min(i,t)}else for(let t=l[0];t<=l[1];++t){const o=Xr(e[t],r,n);if(i=Math.min(i,o),0===i)return 0}}else{const r=Rr(l,t);Qr(a,i,n,e,s,r[0]),Qr(a,i,n,e,s,r[1])}}return i}function rn(e,t,r,n,o,i=1/0){let a=Math.min(i,o.distance(e[0],r[0]));if(0===a)return a;const s=new jr([[0,[0,e.length-1],[0,r.length-1]]],Or);for(;s.length>0;){const i=s.pop();if(i[0]>=a)continue;const l=i[1],u=i[2],p=t?Nr:Pr,c=n?Nr:Pr;if(Lr(l)<=p&&Lr(u)<=c){if(!Fr(l,e.length)&&Fr(u,r.length))return NaN;let i;if(t&&n)i=Zr(e,l,r,u,o),a=Math.min(a,i);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=u[0];e<=u[1];++e)if(i=Jr(r[e],t,o),a=Math.min(a,i),0===a)return a}else if(!t&&n){const t=r.slice(u[0],u[1]+1);for(let r=l[0];r<=l[1];++r)if(i=Jr(e[r],t,o),a=Math.min(a,i),0===a)return a}else i=Br(e,l,r,u,o),a=Math.min(a,i)}else{const i=Rr(l,t),p=Rr(u,n);en(s,a,o,e,r,i[0],p[0]),en(s,a,o,e,r,i[0],p[1]),en(s,a,o,e,r,i[1],p[0]),en(s,a,o,e,r,i[1],p[1])}}return a}function nn(e,t){const r=e.geometry();if(0===r.length||0===r[0].length)return NaN;const n=function(e,t){if(e.length<=1)return[e];const r=[];let n,o;for(const t of e){const e=Tr(t);0!==e&&(t.area=Math.abs(e),void 0===o&&(o=e<0),o===e<0?(n&&r.push(n),n=[t]):n.push(t))}if(n&&r.push(n),t>1)for(let e=0;et.map((t=>t.map((t=>lr([t.x,t.y],e.canonical))))))),o=new Ir(n[0][0][0][1]);let i=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":i=Math.min(i,tn([e.coordinates],!1,t,o,i));break;case"LineString":i=Math.min(i,tn(e.coordinates,!0,t,o,i));break;case"Polygon":i=Math.min(i,Kr(t,e.coordinates,o,i))}if(0===i)return i}return i}function on(e){return"MultiPolygon"===e.type?e.coordinates.map((e=>({type:"Polygon",coordinates:e}))):"MultiLineString"===e.type?e.coordinates.map((e=>({type:"LineString",coordinates:e}))):"MultiPoint"===e.type?e.coordinates.map((e=>({type:"Point",coordinates:e}))):[e]}class an{constructor(e,t){this.type=he,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(gt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new an(t,t.features.map((e=>on(e.geometry))).flat());if("Feature"===t.type)return new an(t,on(t.geometry));if("type"in t&&"coordinates"in t)return new an(t,on(t))}return t.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=e.geometry(),n=r.flat().map((t=>lr([t.x,t.y],e.canonical)));if(0===r.length)return NaN;const o=new Ir(n[0][1]);let i=1/0;for(const e of t){switch(e.type){case"Point":i=Math.min(i,rn(n,!1,[e.coordinates],!1,o,i));break;case"LineString":i=Math.min(i,rn(n,!1,e.coordinates,!0,o,i));break;case"Polygon":i=Math.min(i,tn(n,!1,e.coordinates,o,i))}if(0===i)return i}return i}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=e.geometry(),n=r.flat().map((t=>lr([t.x,t.y],e.canonical)));if(0===r.length)return NaN;const o=new Ir(n[0][1]);let i=1/0;for(const e of t){switch(e.type){case"Point":i=Math.min(i,rn(n,!0,[e.coordinates],!1,o,i));break;case"LineString":i=Math.min(i,rn(n,!0,e.coordinates,!0,o,i));break;case"Polygon":i=Math.min(i,tn(n,!0,e.coordinates,o,i))}if(0===i)return i}return i}(e,this.geometries);if("Polygon"===e.geometryType())return nn(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const sn={"==":Xt,"!=":Ht,">":Kt,"<":Yt,">=":er,"<=":Qt,array:kt,at:Tt,boolean:kt,case:It,coalesce:Jt,collator:tr,format:nr,image:or,in:At,"index-of":_t,interpolate:Gt,"interpolate-hcl":Gt,"interpolate-lab":Gt,length:ir,let:Et,literal:xt,match:Ct,number:kt,"number-format":rr,object:kt,slice:Pt,step:Ot,string:kt,"to-boolean":zt,"to-color":zt,"to-number":zt,"to-string":zt,var:$t,within:zr,distance:an};class ln{constructor(e,t,r,n){this.name=e,this.type=t,this._evaluate=r,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const r=e[0],n=ln.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const o=Array.isArray(n)?n[0]:n.type,i=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=i.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let s=null;for(const[n,i]of a){s=new qt(t.registry,dn,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map($e).join(", ")})`:`(${$e(t.type)}...)`;var t})).join(" | "),n=[];for(let r=1;r{r=t?r&&dn(e):r&&e instanceof xt})),!!r&&(yn(e)&&hn(e,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"]))}function yn(e){if(e instanceof ln){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof zr)return!1;if(e instanceof an)return!1;let t=!0;return e.eachChild((e=>{t&&!yn(e)&&(t=!1)})),t}function mn(e){if(e instanceof ln&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!mn(e)&&(t=!1)})),t}function hn(e,t){if(e instanceof ln&&t.indexOf(e.name)>=0)return!1;let r=!0;return e.eachChild((e=>{r&&!hn(e,t)&&(r=!1)})),r}function gn(e){return{result:"success",value:e}}function vn(e){return{result:"error",value:e}}function bn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}ln.register(sn,{error:[{kind:"error"},[ge],(e,[t])=>{throw new ct(t.evaluate(e))}],typeof:[ge,[ke],(e,[t])=>$e(vt(t.evaluate(e)))],"to-rgba":[Ee(he,4),[be],(e,[t])=>{const[r,n,o,i]=t.evaluate(e).rgb;return[255*r,255*n,255*o,i]}],rgb:[be,[he,he,he],un],rgba:[be,[he,he,he,he],un],has:{type:ve,overloads:[[[ge],(e,[t])=>pn(t.evaluate(e),e.properties())],[[ge,we],(e,[t,r])=>pn(t.evaluate(e),r.evaluate(e))]]},get:{type:ke,overloads:[[[ge],(e,[t])=>cn(t.evaluate(e),e.properties())],[[ge,we],(e,[t,r])=>cn(t.evaluate(e),r.evaluate(e))]]},"feature-state":[ke,[ge],(e,[t])=>cn(t.evaluate(e),e.featureState||{})],properties:[we,[],e=>e.properties()],"geometry-type":[ge,[],e=>e.geometryType()],id:[ke,[],e=>e.id()],zoom:[he,[],e=>e.globals.zoom],"heatmap-density":[he,[],e=>e.globals.heatmapDensity||0],"line-progress":[he,[],e=>e.globals.lineProgress||0],accumulated:[ke,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[he,fn(he),(e,t)=>{let r=0;for(const n of t)r+=n.evaluate(e);return r}],"*":[he,fn(he),(e,t)=>{let r=1;for(const n of t)r*=n.evaluate(e);return r}],"-":{type:he,overloads:[[[he,he],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[he],(e,[t])=>-t.evaluate(e)]]},"/":[he,[he,he],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[he,[he,he],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[he,[],()=>Math.LN2],pi:[he,[],()=>Math.PI],e:[he,[],()=>Math.E],"^":[he,[he,he],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[he,[he],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[he,[he],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[he,[he],(e,[t])=>Math.log(t.evaluate(e))],log2:[he,[he],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[he,[he],(e,[t])=>Math.sin(t.evaluate(e))],cos:[he,[he],(e,[t])=>Math.cos(t.evaluate(e))],tan:[he,[he],(e,[t])=>Math.tan(t.evaluate(e))],asin:[he,[he],(e,[t])=>Math.asin(t.evaluate(e))],acos:[he,[he],(e,[t])=>Math.acos(t.evaluate(e))],atan:[he,[he],(e,[t])=>Math.atan(t.evaluate(e))],min:[he,fn(he),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[he,fn(he),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[he,[he],(e,[t])=>Math.abs(t.evaluate(e))],round:[he,[he],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[he,[he],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[he,[he],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[ve,[ge,ke],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[ve,[ke],(e,[t])=>e.id()===t.value],"filter-type-==":[ve,[ge],(e,[t])=>e.geometryType()===t.value],"filter-<":[ve,[ge,ke],(e,[t,r])=>{const n=e.properties()[t.value],o=r.value;return typeof n==typeof o&&n{const r=e.id(),n=t.value;return typeof r==typeof n&&r":[ve,[ge,ke],(e,[t,r])=>{const n=e.properties()[t.value],o=r.value;return typeof n==typeof o&&n>o}],"filter-id->":[ve,[ke],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>n}],"filter-<=":[ve,[ge,ke],(e,[t,r])=>{const n=e.properties()[t.value],o=r.value;return typeof n==typeof o&&n<=o}],"filter-id-<=":[ve,[ke],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<=n}],"filter->=":[ve,[ge,ke],(e,[t,r])=>{const n=e.properties()[t.value],o=r.value;return typeof n==typeof o&&n>=o}],"filter-id->=":[ve,[ke],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>=n}],"filter-has":[ve,[ke],(e,[t])=>t.value in e.properties()],"filter-has-id":[ve,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[ve,[Ee(ge)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[ve,[Ee(ke)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[ve,[ge,Ee(ke)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[ve,[ge,Ee(ke)],(e,[t,r])=>function(e,t,r,n){for(;r<=n;){const o=r+n>>1;if(t[o]===e)return!0;t[o]>e?n=o-1:r=o+1}return!1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:ve,overloads:[[[ve,ve],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[fn(ve),(e,t)=>{for(const r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:ve,overloads:[[[ve,ve],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[fn(ve),(e,t)=>{for(const r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[ve,[ve],(e,[t])=>!t.evaluate(e)],"is-supported-script":[ve,[ge],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return!r||r(t.evaluate(e))}],upcase:[ge,[ge],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[ge,[ge],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[ge,fn(ke),(e,t)=>t.map((t=>bt(t.evaluate(e)))).join("")],"resolved-locale":[ge,[Me],(e,[t])=>t.evaluate(e).resolvedLocale()]});class xn{constructor(e,t){var r;this.expression=e,this._warningHistory={},this._evaluator=new St,this._defaultValue=t?"color"===(r=t).type&&bn(r.default)?new it(0,0,0,0):"color"===r.type?it.parse(r.default)||null:"padding"===r.type?pt.parse(r.default)||null:"variableAnchorOffsetCollection"===r.type?dt.parse(r.default)||null:"projectionDefinition"===r.type?mt.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,r,n,o,i){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=i,this.expression.evaluate(this._evaluator)}evaluate(e,t,r,n,o,i){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=i||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new ct(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function wn(e,t){const r=new qt(sn,dn,[],t?function(e){const t={color:be,string:ge,number:he,enum:ge,boolean:ve,formatted:ze,padding:je,projectionDefinition:xe,resolvedImage:Se,variableAnchorOffsetCollection:qe};if("array"===e.type)return Ee(t[e.value]||ke,e.length);return t[e.type]}(t):void 0),n=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?gn(new xn(n,t)):vn(r.errors)}class kn{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!mn(t.expression)}evaluateWithoutErrorHandling(e,t,r,n,o,i){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,o,i)}evaluate(e,t,r,n,o,i){return this._styleExpression.evaluate(e,t,r,n,o,i)}}class Mn{constructor(e,t,r,n){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!mn(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,r,n,o,i){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,o,i)}evaluate(e,t,r,n,o,i){return this._styleExpression.evaluate(e,t,r,n,o,i)}interpolationFactor(e,t,r){return this.interpolationType?Gt.interpolationFactor(this.interpolationType,e,t,r):0}}function zn(e,t){const r=wn(e,t);if("error"===r.result)return r;const n=r.value.expression,o=yn(n);if(!o&&("data-driven"!==(i=t)["property-type"]&&"cross-faded-data-driven"!==i["property-type"]))return vn([new de("","data expressions not supported")]);var i;const a=hn(n,["zoom"]);if(!a&&!function(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}(t))return vn([new de("","zoom expressions not supported")]);const s=jn(n);if(!s&&!a)return vn([new de("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(s instanceof de)return vn([s]);if(s instanceof Gt&&!function(e){return!!e.expression&&e.expression.interpolated}(t))return vn([new de("",'"interpolate" expressions cannot be used with this property')]);if(!s)return gn(new kn(o?"constant":"source",r.value));const l=s instanceof Gt?s.interpolation:void 0;return gn(new Mn(o?"camera":"composite",r.value,s.labels,l))}function jn(e){let t=null;if(e instanceof Et)t=jn(e.result);else if(e instanceof Jt){for(const r of e.args)if(t=jn(r),t)break}else(e instanceof Ot||e instanceof Gt)&&e.input instanceof ln&&"zoom"===e.input.name&&(t=e);return t instanceof de||e.eachChild((e=>{const r=jn(e);r instanceof de?t=r:!t&&r?t=new de("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&r&&t!==r&&(t=new de("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}function Sn(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Sn(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const qn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function En(e){if(null==e)return{filter:()=>!0,needGeometry:!1};Sn(e)||(e=An(e));const t=wn(e,qn);if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return{filter:(e,r,n)=>t.value.evaluate(e,r,{},n),needGeometry:Tn(e)}}function $n(e,t){return et?1:0}function Tn(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?_n(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(An))):"all"===t?["all"].concat(e.slice(1).map(An)):"none"===t?["all"].concat(e.slice(1).map(An).map(Pn)):"in"===t?Cn(e[1],e.slice(2)):"!in"===t?Pn(Cn(e[1],e.slice(2))):"has"===t?In(e[1]):"!has"!==t||Pn(In(e[1]))}function _n(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function Cn(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort($n)]]:["filter-in-small",e,["literal",t]]}}function In(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Pn(e){return["!",e]}function Nn(e){return"object"==typeof e?["literal",e]:e}function On(e,t){let r=e.stops;if(!r)return function(e,t){const r=["get",e.property];if(void 0===e.default)return"string"===t.type?["string",r]:r;if("enum"===t.type)return["match",r,Object.keys(t.values),r,e.default];{const n=["color"===t.type?"to-color":t.type,r,Nn(e.default)];return"array"===t.type&&n.splice(1,0,t.value,t.length||null),n}}(e,t);const n=r&&"object"==typeof r[0][0],o=n||void 0!==e.property,i=n||!o;return r=r.map((e=>!o&&t.tokens&&"string"==typeof e[1]?[e[0],Vn(e[1])]:[e[0],Nn(e[1])])),n?function(e,t,r){const n={},o={},i=[];for(let t=0;t3&&t===e[e.length-2]||(n&&2===e.length||e.push(t),e.push(r))}function Gn(e,t){return e.type?e.type:t.expression.interpolated?"exponential":"interval"}function Vn(e){const t=["concat"],r=/{([^{}]+)}/g;let n=0;for(let o=r.exec(e);null!==o;o=r.exec(e)){const i=e.slice(n,r.lastIndex-o[0].length);n=r.lastIndex,i.length>0&&t.push(i),t.push(["get",o[1]])}if(1===t.length)return e;if(n1?c[c.length-2].toLowerCase():"";if(f==d||f==d.replace("-","")||y+"-"+f==d){a=o?a:Wn[d],c.pop(),y&&d.startsWith(y)&&c.pop();break}}o||"number"!=typeof f||(a=f,o=!0);var m=c.join(Zn).replace("Klokantech Noto Sans","Noto Sans");-1!==m.indexOf(Zn)&&(m='"'+m+'"'),l.push(m)}n=Xn[e]=[s,a,l]}return n[0]+Zn+n[1]+Zn+t+"px"+(r?"/"+r:"")+Zn+n[2]}const Yn="https://api.mapbox.com";function Kn(e){const t="mapbox://";return 0!==e.indexOf(t)?"":e.slice(9)}function Qn(e,t){const r=Kn(e);if(!r)return decodeURI(new URL(e,location.href).href);const n="styles/";if(0!==r.indexOf(n))throw new Error(`unexpected style url: ${e}`);const o=r.slice(7);return`${Yn}/styles/v1/${o}?&access_token=${t}`}const eo=["a","b","c","d"];function to(e,t,r,n){const o=new URL(e,n),i=Kn(e);if(!i)return t?(o.searchParams.has(r)||o.searchParams.set(r,t),[decodeURI(o.href)]):[decodeURI(o.href)];if("mapbox.satellite"===i){const e=window.devicePixelRatio>=1.5?"@2x":"";return[`https://api.mapbox.com/v4/${i}/{z}/{x}/{y}${e}.webp?access_token=${t}`]}return eo.map((e=>`https://${e}.tiles.mapbox.com/v4/${i}/{z}/{x}/{y}.vector.pbf?access_token=${t}`))}const ro={},no={};let oo=0;function io(e){return e.id||(e.id=oo++),e.id}function ao(e,t){return io(e)+"."+f.getUid(t)}function so(e){let t=ro[e.id];return t||(t={},ro[io(e)]=t),t}function lo(e){let t=no[e.id];return t||(t={},no[io(e)]=t),t}function uo(e){return e*Math.PI/180}const po=function(){const e=[];for(let t=78271.51696402048;e.length<=24;t/=2)e.push(t);return e}();function co(e,t){if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,t);const r=document.createElement("canvas");return r.width=e,r.height=t,r}function fo(e,t){let r=0;const n=t.length;for(;ri)).then((e=>(e instanceof Request||(e=new Request(e)),e.headers.get("Accept")||e.headers.set("Accept","application/json"),o&&(o.request=e),fetch(e).then((function(e){return delete mo[r],e.ok?e.json():Promise.reject(new Error("Error fetching source "+r))})).catch((function(e){return delete mo[r],Promise.reject(new Error("Error fetching source "+r))})))));return mo[r]=[i,a],a}function go(e,t){if("string"!=typeof e)return Promise.resolve(e);if(!e.trim().startsWith("{"))return ho("Style",e=Qn(e,t.accessToken),t);try{const t=JSON.parse(e);return Promise.resolve(t)}catch(e){return Promise.reject(e)}}const vo={};function bo(e,r,n={}){const o=[r,JSON.stringify(e)].toString();let i=vo[o];if(!i||n.transformRequest){let a;n.transformRequest&&(a=(e,r)=>{const o=n.transformRequest&&n.transformRequest(r,"Tiles")||r;if(e instanceof p.VectorTile)e.setLoader(((r,n,i)=>{t.toPromise((()=>o)).then((t=>{fetch(t).then((e=>e.arrayBuffer())).then((t=>{const n=e.getFormat().readFeatures(t,{extent:r,featureProjection:i});e.setFeatures(n)})).catch((t=>e.setState(V.default.ERROR)))}))}));else{const r=e.getImage();t.toPromise((()=>o)).then((t=>{t instanceof Request?fetch(t).then((e=>e.blob())).then((e=>{const t=URL.createObjectURL(e);r.addEventListener("load",(()=>URL.revokeObjectURL(t))),r.addEventListener("error",(()=>URL.revokeObjectURL(t))),r.src=t})).catch((t=>e.setState(V.default.ERROR))):r.src=t}))}});const s=e.url;if(s&&!e.tiles){const t=to(s,n.accessToken,n.accessTokenParam||"access_token",r||location.href);if(s.startsWith("mapbox://"))i=Promise.resolve({tileJson:Object.assign({},e,{url:void 0,tiles:t}),tileLoadFunction:a});else{const e={};i=ho("Source",t[0],n,e).then((function(t){return t.tiles=t.tiles.map((function(r){return"tms"===t.scheme&&(r=r.replace("{y}","{-y}")),to(r,n.accessToken,n.accessTokenParam||"access_token",e.request.url)[0]})),Promise.resolve({tileJson:t,tileLoadFunction:a})}))}}else e=Object.assign({},e,{tiles:e.tiles.map((function(t){return"tms"===e.scheme&&(t=t.replace("{y}","{-y}")),to(t,n.accessToken,n.accessTokenParam||"access_token",r||location.href)[0]}))}),i=Promise.resolve({tileJson:Object.assign({},e),tileLoadFunction:a});vo[o]=i}return i}function xo(e,t,r,n){const o=[2*r*t.pixelRatio+t.width,2*r*t.pixelRatio+t.height],i=co(o[0],o[1]),a=i.getContext("2d");a.drawImage(e,t.x,t.y,t.width,t.height,r*t.pixelRatio,r*t.pixelRatio,t.width,t.height);const s=a.getImageData(0,0,o[0],o[1]);a.globalCompositeOperation="destination-over",a.fillStyle=`rgba(${255*n.r},${255*n.g},${255*n.b},${n.a})`;const l=s.data;for(let e=0,n=s.width;e0&&a.arc(e,o,r*t.pixelRatio,0,2*Math.PI)}return a.fill(),i}function wo(e,t,r){const n=Math.max(0,Math.min(1,(r-e)/(t-e)));return n*n*(3-2*n)}function ko(e,t,r){const n=co(t.width,t.height),o=n.getContext("2d");o.drawImage(e,t.x,t.y,t.width,t.height,0,0,t.width,t.height);const i=o.getImageData(0,0,t.width,t.height),a=i.data;for(let e=0,t=i.width;e0?(a[o+0]=Math.round(255*r.r*l),a[o+1]=Math.round(255*r.g*l),a[o+2]=Math.round(255*r.b*l),a[o+3]=Math.round(255*l)):a[o+3]=0}return o.putImageData(i,0,0),n}const Mo=Array(256).join(" ");function zo(e,t){if(t>=.05){let r="";const n=e.split("\n"),o=Mo.slice(0,Math.round(t/.1));for(let e=0,t=n.length;e0&&(r+="\n"),r+=n[e].split("").join(o);return r}return e}let jo;function So(){return jo||(jo=co(1,1).getContext("2d")),jo}function qo(e,t){return So().measureText(e).width+(e.length-1)*t}const Eo={};function $o(e,t,r,n){if(-1!==e.indexOf("\n")){const o=e.split("\n"),i=[];for(let e=0,a=o.length;e1){const e=So();e.font=t;const o=e.measureText("M").width*r;let s="";const l=[];for(let e=0,t=a.length;e1;++e){const r=l[e];if(qo(r,n)<.35*o){const o=e>0?qo(l[e-1],n):1/0,i=e.7*o&&qo(i,n)<.6*o){const a=r.split(" "),s=a.pop();qo(s,n)<.2*o&&(l[e]=a.join(" "),l[e+1]=s+" "+i),t-=1}}i=l.join("\n")}else i=e;i=zo(i,n),Eo[o]=i}return i}const To=/font-family: ?([^;]*);/,Ao=/("|')/g;let _o;function Co(e){if(!_o){_o={};const e=document.styleSheets;for(let t=0,r=e.length;t`${e.key}: ${e.message}`)).join(", "));return r.value},Lo={},Fo={zoom:0};let Ro,Uo;function Do(e,t,r,n,o,i,a){const s=e.id;i||(i={},console.warn("No functionCache provided to getValue()")),i[s]||(i[s]={});const l=i[s];if(!l[r]){let n=(e[t]||Lo)[r];const o=Jn[`${t}_${e.type}`][r];void 0===n&&(n=o.default);let i=(u=n,Array.isArray(u)&&u.length>0&&"string"==typeof u[0]&&u[0]in sn);if(!i&&bn(n)&&(n=On(n,o),i=!0),i){const e=Oo(n,o);l[r]=e.evaluate.bind(e)}else"color"==o.type&&(n=it.parse(n)),l[r]=function(){return n}}var u;return Fo.zoom=n,l[r](Fo,o,a)}function Go(e,t,r,n,o){if(!Do(e,"layout",`${n}-allow-overlap`,t,r,o))return"declutter";return Do(e,"layout",`${n}-ignore-placement`,t,r,o)?"none":"obstacle"}function Vo(e,t,r,n,o){return o||console.warn("No filterCache provided to evaluateFilter()"),e in o||(o[e]=En(t).filter),Fo.zoom=n,o[e](Fo,r)}let Jo=!1;function Wo(e,t){if(e){if(!Jo&&(0===e.a||0===t))return;const r=e.a;return t=void 0===t?1:t,0===r?"transparent":"rgba("+Math.round(255*e.r/r)+","+Math.round(255*e.g/r)+","+Math.round(255*e.b/r)+","+r*t+")"}return e}const Zo=/\{[^{}}]*\}/g;function Bo(e,t){return e.replace(Zo,(function(e){return t[e.slice(1,-1)]||""}))}let Xo=!1;const Ho={};function Yo(e,r,n,o=po,i=void 0,a=void 0,s=void 0,l=void 0){if("string"==typeof r&&(r=JSON.parse(r)),8!=r.version)throw new Error("glStyle version 8 required.");let u,p,c;if(Ho[ao(r,e)]=Array.from(arguments),a)if("undefined"!=typeof Image){const r=new Image;let n;t.toPromise((()=>a)).then((e=>{e instanceof Request?fetch(e).then((e=>e.blob())).then((e=>{n=URL.createObjectURL(e),r.src=n})).catch((()=>{})):(r.crossOrigin="anonymous",r.src=e,n&&URL.revokeObjectURL(n))})),r.onload=function(){u=r,p=[r.width,r.height],e.changed(),r.onload=null}}else if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){const e=self;e.postMessage({action:"loadImage",src:a}),e.addEventListener("message",(function(e){"imageLoaded"===e.data.action&&e.data.src===a&&(u=e.data.image,p=[u.width,u.height])}))}const f=fe(r.layers),d={},y=[],m={},h={},g=so(r),v=lo(r);let b;for(let e=0,t=f.length;e=E.maxzoom)continue;const _=E.filter;if(!_||Vo($,_,z,b,v)){let o,a,y,v,$,_;S=E;const C=d.index;if(3==M&&("fill"==E.type||"fill-extrusion"==E.type))if(a=Do(E,"paint",E.type+"-opacity",b,z,g,j),E.type+"-pattern"in A){const e=Do(E,"paint",E.type+"-pattern",b,z,g,j);if(e){const t="string"==typeof e?Bo(e,f):e.toString();if(u&&i&&i[t]){++q,_=k[q],_&&_.getFill()&&!_.getStroke()&&!_.getText()||(_=new D.default({fill:new F.default}),k[q]=_),y=_.getFill(),_.setZIndex(C);const e=t+"."+a;let r=h[e];if(!r){const n=i[t],o=co(n.width,n.height),s=o.getContext("2d");s.globalAlpha=a,s.drawImage(u,n.x,n.y,n.width,n.height,0,0,n.width,n.height),r=s.createPattern(o,"repeat"),h[e]=r}y.setColor(r)}}}else o=Wo(Do(E,"paint",E.type+"-color",b,z,g,j),a),E.type+"-outline-color"in A&&($=Wo(Do(E,"paint",E.type+"-outline-color",b,z,g,j),a)),$||($=o),(o||$)&&(++q,_=k[q],(!_||o&&!_.getFill()||!o&&_.getFill()||$&&!_.getStroke()||!$&&_.getStroke()||_.getText())&&(_=new D.default({fill:o?new F.default:void 0,stroke:$?new U.default:void 0}),k[q]=_),o&&(y=_.getFill(),y.setColor(o)),$&&(v=_.getStroke(),v.setColor($),v.setWidth(.5)),_.setZIndex(C));if(1!=M&&"line"==E.type){o="line-pattern"in A?void 0:Wo(Do(E,"paint","line-color",b,z,g,j),Do(E,"paint","line-opacity",b,z,g,j));const e=Do(E,"paint","line-width",b,z,g,j);o&&e>0&&(++q,_=k[q],_&&_.getStroke()&&!_.getFill()&&!_.getText()||(_=new D.default({stroke:new U.default}),k[q]=_),v=_.getStroke(),v.setLineCap(Do(E,"layout","line-cap",b,z,g,j)),v.setLineJoin(Do(E,"layout","line-join",b,z,g,j)),v.setMiterLimit(Do(E,"layout","line-miter-limit",b,z,g,j)),v.setColor(o),v.setWidth(e),v.setLineDash(A["line-dasharray"]?Do(E,"paint","line-dasharray",b,z,g,j).map((function(t){return t*e})):null),_.setZIndex(C))}let I,P,N,V,J,W,Z,B,X,H=!1,Y=null,K=0;if((1==M||2==M)&&"icon-image"in T){const r=Do(E,"layout","icon-image",b,z,g,j);if(r){let o;I="string"==typeof r?Bo(r,f):r.toString();const a=l?l(e,I):void 0;if(u&&i&&i[I]||a){const e=Do(E,"layout","icon-rotation-alignment",b,z,g,j);if(2==M){const r=t.getGeometry();if(r.getFlatMidpoint||r.getFlatMidpoints){const t=r.getExtent();if(Math.sqrt(Math.max(Math.pow((t[2]-t[0])/n,2),Math.pow((t[3]-t[1])/n,2)))>150){const t="MultiLineString"===r.getType()?r.getFlatMidpoints():r.getFlatMidpoint();Uo||(Ro=[NaN,NaN],Uo=new O.default("Point",Ro,[],2,{},void 0)),o=Uo,Ro[0]=t[0],Ro[1]=t[1];if("line"===Do(E,"layout","symbol-placement",b,z,g,j)&&"map"===e){const e=r.getStride(),n=r.getFlatCoordinates();for(let r=0,o=n.length-e;r=l){K=Math.atan2(i-s,a-o);break}}}}}}if(2!==M||o){const t=Do(E,"layout","icon-size",b,z,g,j),r=void 0!==A["icon-color"]?Do(E,"paint","icon-color",b,z,g,j):null;if(!r||0!==r.a){const n=Do(E,"paint","icon-halo-color",b,z,g,j),o=Do(E,"paint","icon-halo-width",b,z,g,j);let s=`${I}.${t}.${o}.${n}`;if(null!==r&&(s+=`.${r}`),P=m[s],!P){const l=Go(E,b,z,"icon",g);let f;"icon-offset"in T&&(f=Do(E,"layout","icon-offset",b,z,g,j).slice(0),f[0]*=t,f[1]*=-t);let d=r?[255*r.r,255*r.g,255*r.b,r.a]:void 0;if(a){const r={color:d,rotateWithView:"map"===e,displacement:f,declutterMode:l,scale:t};"string"==typeof a?r.src=a:(r.img=a,r.imgSize=[a.width,a.height]),P=new R.default(r)}else{const a=i[I];let s,y,m;o?a.sdf?(s=xo(ko(u,a,r||[0,0,0,1]),{x:0,y:0,width:a.width,height:a.height,pixelRatio:a.pixelRatio},o,n),d=void 0):s=xo(u,a,o,n):(a.sdf?(c||(c=ko(u,{x:0,y:0,width:p[0],height:p[1]},{r:1,g:1,b:1,a:1})),s=c):s=u,y=[a.width,a.height],m=[a.x,a.y]),P=new R.default({color:d,img:s,imgSize:p,size:y,offset:m,rotateWithView:"map"===e,scale:t/a.pixelRatio,displacement:f,declutterMode:l})}m[s]=P}}P&&(++q,_=k[q],_&&_.getImage()&&!_.getFill()&&!_.getStroke()||(_=new D.default,k[q]=_),_.setGeometry(o),P.setRotation(K+uo(Do(E,"layout","icon-rotate",b,z,g,j))),P.setOpacity(Do(E,"paint","icon-opacity",b,z,g,j)),P.setAnchor(No[Do(E,"layout","icon-anchor",b,z,g,j)]),_.setImage(P),Y=_.getText(),_.setText(void 0),_.setZIndex(C),H=!0,N=!1)}else N=!0}}}if(1==M&&"circle"===E.type){++q,_=k[q],_&&_.getImage()&&!_.getFill()&&!_.getStroke()||(_=new D.default,k[q]=_);const e="circle-radius"in A?Do(E,"paint","circle-radius",b,z,g,j):5,t=Wo(Do(E,"paint","circle-stroke-color",b,z,g,j),Do(E,"paint","circle-stroke-opacity",b,z,g,j)),r=Do(E,"paint","circle-translate",b,z,g,j),n=Wo(Do(E,"paint","circle-color",b,z,g,j),Do(E,"paint","circle-opacity",b,z,g,j)),o=Do(E,"paint","circle-stroke-width",b,z,g,j),i=e+"."+t+"."+n+"."+o+"."+r[0]+"."+r[1];P=m[i],P||(P=new L.default({radius:e,displacement:[r[0],-r[1]],stroke:t&&o>0?new U.default({width:o,color:t}):void 0,fill:n?new F.default({color:n}):void 0,declutterMode:"none"}),m[i]=P),_.setImage(P),Y=_.getText(),_.setText(void 0),_.setGeometry(void 0),_.setZIndex(C),H=!0}if("text-field"in T){Z=Math.round(Do(E,"layout","text-size",b,z,g,j));const e=Do(E,"layout","text-font",b,z,g,j);W=Do(E,"layout","text-line-height",b,z,g,j),J=Hn(s?s(e,r.metadata?r.metadata["ol:webfonts"]:void 0):e,Z,W),J.includes("sans-serif")||(J+=",sans-serif"),B=Do(E,"layout","text-letter-spacing",b,z,g,j),X=Do(E,"layout","text-max-width",b,z,g,j);const t=Do(E,"layout","text-field",b,z,g,j);V="object"==typeof t&&t.sections?1===t.sections.length?t.toString():t.sections.reduce(((t,r,n)=>{const o=r.fontStack?r.fontStack.split(","):e,i=Hn(s?s(o):o,Z*(r.scale||1),W);let a=r.text;if("\n"===a)return t.push("\n",""),t;if(2==M)return t.push(zo(a,B),i),t;a=$o(a,i,X,B).split("\n");for(let e=0,r=a.length;e0&&t.push("\n",""),t.push(a[e],i);return t}),[]):Bo(t,f).trim(),a=Do(E,"paint","text-opacity",b,z,g,j)}if(V&&a&&!N){H||(++q,_=k[q],_&&_.getText()&&!_.getFill()&&!_.getStroke()||(_=new D.default,k[q]=_),_.setImage(void 0),_.setGeometry(void 0));const e=Go(E,b,z,"text",g);_.getText()||_.setText(Y),Y=_.getText(),(!Y||"getDeclutterMode"in Y&&Y.getDeclutterMode()!==e)&&(Y=new G.default({padding:[2,2,2,2],declutterMode:e}),_.setText(Y));const t=Do(E,"layout","text-transform",b,z,g,j);"uppercase"==t?V=Array.isArray(V)?V.map(((e,t)=>t%2?e:e.toUpperCase())):V.toUpperCase():"lowercase"==t&&(V=Array.isArray(V)?V.map(((e,t)=>t%2?e:e.toLowerCase())):V.toLowerCase());const r=Array.isArray(V)?V:2==M?zo(V,B):$o(V,J,X,B);if(Y.setText(r),Y.setFont(J),Y.setRotation(uo(Do(E,"layout","text-rotate",b,z,g,j))),"function"==typeof Y.setKeepUpright){const e=Do(E,"layout","text-keep-upright",b,z,g,j);Y.setKeepUpright(e)}const n=Do(E,"layout","text-anchor",b,z,g,j),o=H||1==M?"point":Do(E,"layout","symbol-placement",b,z,g,j);let i;if("line-center"===o?(Y.setPlacement("line"),i="center"):Y.setPlacement(o),"line"===o&&"function"==typeof Y.setRepeat){const e=Do(E,"layout","symbol-spacing",b,z,g,j);Y.setRepeat(2*e)}Y.setOverflow("point"===o);let s=Do(E,"paint","text-halo-width",b,z,g,j);const l=Do(E,"layout","text-offset",b,z,g,j),u=Do(E,"paint","text-translate",b,z,g,j);let p=0,c=0;if("point"==o){i="center",-1!==n.indexOf("left")?(i="left",c=s):-1!==n.indexOf("right")&&(i="right",c=-s);const e=Do(E,"layout","text-rotation-alignment",b,z,g,j);Y.setRotateWithView("map"==e)}else Y.setMaxAngle(uo(Do(E,"layout","text-max-angle",b,z,g,j))*V.length/r.length),Y.setRotateWithView(!1);Y.setTextAlign(i);let f="middle";0==n.indexOf("bottom")?(f="bottom",p=-s-.5*(W-1)*Z):0==n.indexOf("top")&&(f="top",p=s+.5*(W-1)*Z),Y.setTextBaseline(f);const d=Do(E,"layout","text-justify",b,z,g,j);Y.setJustify("auto"===d?void 0:d),Y.setOffsetX(l[0]*Z+c+u[0]),Y.setOffsetY(l[1]*Z+p+u[1]),w.setColor(Wo(Do(E,"paint","text-color",b,z,g,j),a)),Y.setFill(w);const y=Wo(Do(E,"paint","text-halo-color",b,z,g,j),a);if(y&&s>0){x.setColor(y),s*=2;const e=.5*Z;x.setWidth(s<=e?s:e),Y.setStroke(x)}else Y.setStroke(void 0);const m=Do(E,"layout","text-padding",b,z,g,j),h=Y.getPadding();m!==h[0]&&(h[0]=m,h[1]=m,h[2]=m,h[3]=m),_.setZIndex(C)}}}return q>-1?(k.length=q+1,Xo&&("set"in t?t.set("mapbox-layer",S):t.getProperties()["mapbox-layer"]=S),k):void 0};return e.setStyle(M),e.set("mapbox-source",b),e.set("mapbox-layers",y),e.set("mapbox-featurestate",e.get("mapbox-featurestate")||{}),M}function Ko(e,t){const r=e[0],n=r.width,o=r.height,i=r.data,a=new Uint8ClampedArray(i.length),s=2*t.resolution,l=n-1,u=o-1,p=[0,0,0,0],c=2*Math.PI,f=Math.PI/2,d=Math.PI*t.sunEl/180,y=Math.PI*t.sunAz/180,m=Math.cos(d),h=Math.sin(d),g=t.highlightColor,v=t.shadowColor,b=t.accentColor,x=t.encoding;let w,k,M,z,j,S,q,E,$,T,A,_,C,I,P,N,O,L,F,R,U,D;function G(e,t="mapbox"){return"mapbox"===t?.1*(256*e[0]*256+256*e[1]+e[2])-1e4:"terrarium"===t?256*e[0]+e[1]+e[2]/256-32768:void 0}for(k=0;k<=u;++k)for(j=0===k?0:k-1,S=k===u?u:k+1,w=0;w<=l;++w)M=0===w?0:w-1,z=w===l?l:w+1,q=4*(k*n+M),p[0]=i[q],p[1]=i[q+1],p[2]=i[q+2],p[3]=i[q+3],E=t.vert*G(p,x),q=4*(k*n+z),p[0]=i[q],p[1]=i[q+1],p[2]=i[q+2],p[3]=i[q+3],$=t.vert*G(p,x),T=($-E)/s,q=4*(j*n+w),p[0]=i[q],p[1]=i[q+1],p[2]=i[q+2],p[3]=i[q+3],E=t.vert*G(p,x),q=4*(S*n+w),p[0]=i[q],p[1]=i[q+1],p[2]=i[q+2],p[3]=i[q+3],$=t.vert*G(p,x),A=($-E)/s,C=Math.atan2(A,-T),C=C<0?f-C:C>f?c-C+f:f-C,_=Math.atan(Math.sqrt(T*T+A*A)),D=h*Math.cos(_)+m*Math.sin(_)*Math.cos(y-C),I=Math.cos(_),P=255*D,F=Math.min(Math.max(2*t.sunEl,0),1),R=1.875-1.75*t.opacity,U=.5!==t.opacity?f*((Math.pow(R,_)-1)/(Math.pow(R,f)-1)):_,O={r:(1-I)*b.r*F*255,g:(1-I)*b.g*F*255,b:(1-I)*b.b*F*255,a:(1-I)*b.a*F*255},N=Math.abs(((C+y)/Math.PI+.5)%2-1),L={r:(g.r*(1-N)+v.r*N)*P,g:(g.g*(1-N)+v.g*N)*P,b:(g.b*(1-N)+v.b*N)*P,a:(g.a*(1-N)+v.a*N)*P},q=4*(k*n+w),a[q]=O.r*(1-N)+L.r,a[q+1]=O.g*(1-N)+L.g,a[q+2]=O.b*(1-N)+L.b,a[q+3]=i[q+3]*t.opacity*F*Math.sin(U);return new ImageData(a,n,o)}function Qo(e,t=512){return e.getExtent()?C.createXYZ({extent:e.getExtent(),tileSize:t,maxZoom:22}).getResolutions():po}function ei(e,t){if(!t.accessToken){t=Object.assign({},t);new URL(e).searchParams.forEach(((e,r)=>{t.accessToken=e,t.accessTokenParam=r}))}return t}function ti(e,t,r="",n={},o=void 0){let i,a,s,l,p=!0;return"string"==typeof r||Array.isArray(r)?l=r:(s=r,l=s.source||s.layers,n=s),"string"==typeof n?(i=n,s={}):(i=n.styleUrl,s=n),!1===s.updateSource&&(p=!1),o||(o=s.resolutions),i||"string"!=typeof t||t.trim().startsWith("{")||(i=t),i&&(i=i.startsWith("data:")?location.href:Qn(i,s.accessToken),s=ei(i,s)),new Promise((function(r,n){go(t,s).then((function(t){if(8!=t.version)return n(new Error("glStyle version 8 required."));if(!(e instanceof Q.default||e instanceof ee.default))return n(new Error("Can only apply to VectorLayer or VectorTileLayer"));const c=e instanceof ee.default?"vector":"geojson";if(l?a=Array.isArray(l)?t.layers.find((function(e){return e.id===l[0]})).source:l:(a=Object.keys(t.sources).find((function(e){return t.sources[e].type===c})),l=a),!a)return n(new Error(`No ${c} source found in the glStyle.`));function f(){if(!p)return Promise.resolve();if(e instanceof ee.default)return li(t.sources[a],i,s).then((function(t){const r=e.getSource();r?t!==r&&(r.setTileUrlFunction(t.getTileUrlFunction()),"function"==typeof r.setUrls&&"function"==typeof t.getUrls&&r.setUrls(t.getUrls()),r.format_||(r.format_=t.format_),r.getAttributions()||r.setAttributions(t.getAttributions()),r.getTileLoadFunction()===A.defaultLoadFunction&&r.setTileLoadFunction(t.getTileLoadFunction()),S.equivalent(r.getProjection(),t.getProjection())&&(r.tileGrid=t.getTileGrid())):e.setSource(t);const n=e.getSource().getTileGrid();!isFinite(e.getMaxResolution())&&!isFinite(e.getMinZoom())&&n.getMinZoom()>0&&e.setMaxResolution(yo(Math.max(0,n.getMinZoom()-1e-12),n.getResolutions()))}));const r=t.sources[a];let n=e.getSource();n&&n.get("mapbox-source")===r||(n=fi(r,i,s));const o=e.getSource();return o?n!==o&&(o.getAttributions()||o.setAttributions(n.getAttributions()),o.format_||(o.format_=n.getFormat()),o.url_=n.getUrl()):e.setSource(n),Promise.resolve()}let d,y,m,h;function g(){if(h||t.sprite&&!y)h?(e.setStyle(h),f().then(r).catch(n)):n(new Error("Something went wrong trying to apply style."));else{if(s.projection&&!o){const e=S.get(s.projection).getUnits();"m"!==e&&(o=po.map((t=>t/j.METERS_PER_UNIT[e])))}h=Yo(e,t,l,o,y,m,((e,t=s.webfonts)=>function(e,t="https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css"){const r=e.toString();if(r in Io)return Io[r];const n=[];for(let t=0,r=e.length;t=1.5?.5:1;const r=.5==d?"@2x":"";let o=e.origin+e.pathname+r+".json"+e.search;new Promise((function(t,r){ho("Sprite",o,s).then(t).catch((function(n){o=e.origin+e.pathname+".json"+e.search,ho("Sprite",o,s).then(t).catch(r)}))})).then((function(t){if(void 0===t&&n(new Error("No sprites found.")),y=t,m=e.origin+e.pathname+r+".png"+e.search,s.transformRequest){const e=s.transformRequest(m,"SpriteImage")||m;(e instanceof Request||e instanceof Promise)&&(m=e)}g()})).catch((function(e){n(new Error(`Sprites cannot be loaded: ${o}: ${e.message}`))}))}else g()})).catch(n)}))}const ri={};function ni(e,t,r={}){return go(t,r).then((function(t){!function(e,t,r){t.layers.some((function(t){if("background"===t.type){if(e instanceof Y.default)return e.setBackground((function(e){return ai(t,e,r,{})})),!0;if(e instanceof J.default||e instanceof X.default)return e.getLayers().insertAt(0,si(t,r,{})),!0}}))}(e,t,r)}))}function oi(e,t){let r;return e.some((function(e){if(e.id==t)return r=e.source,!0})),r}function ii(e,t,r){const n=new ne.default({tileJSON:t,tileSize:e.tileSize||t.tileSize||512}),o=n.getTileJSON(),i=n.getTileGrid(),a=S.get(r.projection||"EPSG:3857"),s=function(e,t){const r=e.bounds;if(r){const e=S.fromLonLat([r[0],r[1]],t),n=S.fromLonLat([r[2],r[3]],t);return[e[0],e[1],n[0],n[1]]}return S.get(t).getExtent()}(o,a),l=a.getExtent(),u=o.minzoom||0,p=o.maxzoom||22,c={attributions:n.getAttributions(),projection:a,tileGrid:new ae.default({origin:l?m.getTopLeft(l):i.getOrigin(0),extent:s||i.getExtent(),minZoom:u,resolutions:Qo(a,t.tileSize).slice(0,p+1),tileSize:i.getTileSize(0)})};return Array.isArray(o.tiles)?c.urls=o.tiles:c.url=o.tiles,c}function ai(e,t,r,n){const o={id:e.id,type:e.type},i=e.layout||{},a=e.paint||{};o.paint=a;const s=fo(t,r.resolutions||po);let l;const u=Do(o,"paint","background-color",s,ri,n);return void 0!==a["background-opacity"]&&(l=Do(o,"paint","background-opacity",s,ri,n)),"none"==i.visibility?void 0:Wo(u,l)}function si(e,t,r){const n=document.createElement("div");return n.className="ol-mapbox-style-background",n.style.position="absolute",n.style.width="100%",n.style.height="100%",new Y.default({source:new re.default({}),render(o){const i=ai(e,o.viewState.resolution,t,r);return n.style.backgroundColor=i,n}})}function li(e,t,r){return new Promise((function(n,o){bo(e,t,r).then((function({tileJson:t,tileLoadFunction:o}){const i=ii(e,t,r);i.tileLoadFunction=o,i.format=new B.default,n(new ie.default(i))})).catch(o)}))}function ui(e){return`{bbox-${(e?e.getCode():"EPSG:3857").toLowerCase().replace(/[^a-z0-9]/g,"-")}}`}function pi(e,t,r){return new Promise((function(n,o){bo(e,t,r).then((function({tileJson:t,tileLoadFunction:o}){const i=new ne.default({interpolate:void 0===r.interpolate||r.interpolate,transition:0,crossOrigin:"anonymous",tileJSON:t});i.tileGrid=ii(e,t,r).tileGrid,r.projection&&(i.projection=S.get(r.projection));const a=i.getTileUrlFunction();o&&i.setTileLoadFunction(o),i.setTileUrlFunction((function(e,t,r){const n=ui(r);let o=a(e,t,r);if(-1!=o.indexOf(n)){const t=i.getTileGrid().getTileCoordExtent(e);o=o.replace(n,t.toString())}return o})),i.set("mapbox-source",e),n(i)})).catch((function(e){o(e)}))}))}function ci(e,t,r){const n=new K.default;return pi(e,t,r).then((function(e){n.setSource(e)})).catch((function(){n.setSource(void 0)})),n}function fi(e,t,r){const n=r.projection?new Z.default({dataProjection:r.projection}):new Z.default,o=e.data,i={};if("string"==typeof o){const[i]=to(o,r.accessToken,r.accessTokenParam||"access_token",t||location.href);if(/\{bbox-[0-9a-z-]+\}/.test(i)){const t=(e,t,r)=>{const n=ui(r);return i.replace(n,`${e.join(",")}`)},o=new oe.default({attributions:e.attribution,format:n,loader:(e,n,i,a,s)=>{ho("GeoJSON","function"==typeof t?t(e,n,i):t,r).then((e=>{const t=o.getFormat().readFeatures(e,{featureProjection:i});o.addFeatures(t),a(t)})).catch((t=>{o.removeLoadedExtent(e),s()}))},strategy:z.bbox});return o.set("mapbox-source",e),o}const a=new oe.default({attributions:e.attribution,format:n,url:i,loader:(e,t,n,o,s)=>{ho("GeoJSON",i,r).then((e=>{const t=a.getFormat().readFeatures(e,{featureProjection:n});a.addFeatures(t),o(t)})).catch((t=>{a.removeLoadedExtent(e),s()}))}});return a}i.features=n.readFeatures(o,{featureProjection:S.getUserProjection()||"EPSG:3857"});const a=new oe.default(Object.assign({attributions:e.attribution,format:n},i));return a.set("mapbox-source",e),a}function di(e,t,r){let n=null;return function(o){e.paint&&"raster-opacity"in e.paint&&o.frameState.viewState.zoom!==n&&(n=o.frameState.viewState.zoom,delete r[e.id],function(e,t,r,n){const o=Do(e,"paint","raster-opacity",r,ri,n);t.setOpacity(o)}(e,t,n,r))}}function yi(e,t,r,n){const o=so(e),i=e.layers,a=r.type,s=r.source||oi(i,r.ref),l=e.sources[s];let u;if("background"==a)u=si(r,n,o);else if("vector"==l.type)u=function(e,t,r){const n=new ee.default({declutter:!0,visible:!1});return li(e,t,r).then((function(t){t.set("mapbox-source",e),n.setSource(t)})).catch((function(e){n.setSource(void 0)})),n}(l,t,n);else if("raster"==l.type)u=ci(l,t,n),u.setVisible(!r.layout||"none"!==r.layout.visibility),u.on("prerender",di(r,u,o));else if("geojson"==l.type)u=function(e,t,r){return new Q.default({declutter:!0,source:fi(e,t,r),visible:!1})}(l,t,n);else if("raster-dem"==l.type&&"hillshade"==r.type){const e=function(e,t,r){const n=ci(e,t,r);return new H.default({source:new te.default({operationType:"image",operation:Ko,sources:[n]})})}(l,t,n);u=e,e.getSource().on("beforeoperations",(function(e){const t=e.data;t.resolution=S.getPointResolution(n.projection||"EPSG:3857",e.resolution,m.getCenter(e.extent),"m");const i=fo(e.resolution,n.resolutions||po);t.encoding=l.encoding,t.vert=5*Do(r,"paint","hillshade-exaggeration",i,ri,o),t.sunAz=Do(r,"paint","hillshade-illumination-direction",i,ri,o),t.sunEl=35,t.opacity=.3,t.highlightColor=Do(r,"paint","hillshade-highlight-color",i,ri,o),t.shadowColor=Do(r,"paint","hillshade-shadow-color",i,ri,o),t.accentColor=Do(r,"paint","hillshade-accent-color",i,ri,o)})),u.setVisible(!r.layout||"none"!==r.layout.visibility)}const p=s;return u&&u.set("mapbox-source",p),u}function mi(e,t,r,n){const o=[];let i=null;if(t instanceof J.default){if(i=t.getView(),!i.isDef()&&!i.getRotation()&&!i.getResolutions()){const e=n.projection?S.get(n.projection):i.getProjection();i=new W.default(Object.assign(i.getProperties(),{maxResolution:po[0]/j.METERS_PER_UNIT[e.getUnits()],projection:n.projection||i.getProjection()})),t.setView(i)}"center"in e&&!i.getCenter()&&i.setCenter(S.fromLonLat(e.center,i.getProjection())),"zoom"in e&&void 0===i.getZoom()&&i.setResolution(po[0]/j.METERS_PER_UNIT[i.getProjection().getUnits()]/Math.pow(2,e.zoom)),i.getCenter()&&void 0!==i.getZoom()||i.fit(i.getProjection().getExtent(),{nearest:!0,size:t.getSize()})}t.set("mapbox-style",e),t.set("mapbox-metadata",{styleUrl:r,options:n});const a=e.layers;let s,l,u,p=[];for(let i=0,c=a.length;i0||r>0)&&e.setMaxResolution(Math.min(yo(Math.max(0,a-1e-12),po),yo(Math.max(0,r-1e-12),t.getResolutions()))),s<24&&e.setMinResolution(yo(s,po))}}else a>0&&e.setMaxResolution(yo(Math.max(0,a-1e-12),po));p instanceof oe.default||p instanceof ie.default?ti(e,r,t,Object.assign({styleUrl:n},i)).then((function(){!function(e,t){function r(){const r=t.get("mapbox-style");if(!r)return;const n=fe(r.layers),o=e.get("mapbox-layers"),i=n.filter((function(e){return o.includes(e.id)})).some((function(e){return!e.layout||!e.layout.visibility||"visible"===e.layout.visibility}));e.get("visible")!==i&&e.setVisible(i)}e.on("change",r),r()}(e,o),l()})).catch(u):l()}else u(new Error("Error accessing data for source "+e.get("mapbox-source")))};e.set("mapbox-layers",t);const c=o.getLayers();-1===c.getArray().indexOf(e)&&c.push(e),e.getSource()?p():e.once("change:source",p)}))}function vi(e,t){const r=e.get("mapbox-style").layers.find((function(e){return e.id===t}));return r}function bi(e,t){const r=e.getLayers().getArray();for(let e=0,n=r.length;e{r.setState("ready")})).catch((e=>{this.dispatchEvent(new ki(e));this.getSource().setState("error")}))}}e.MapboxVectorLayer=Mi,e.addMapboxLayer=function(e,t,r){const n=e.get("mapbox-style"),o=n.layers;let i,a,s=-1;if(void 0!==r){const t=vi(e,r);if(void 0===t)throw new Error(`Layer with id "${r}" not found.`);i=o.indexOf(t)}else i=o.length;if(i>0&&o[i-1].source===t.source?(s=i-1,a=-1):ie.id===t.id)))throw new Error(`Layer with id "${t.id}" already exists.`);const l=o[s].id,u=Ho[ao(e.get("mapbox-style"),bi(e,l))];if(o.splice(i,0,t),u){const[e,r,n,o,i,s,p,c]=u;if(Array.isArray(n)){const e=n.indexOf(l)+a;n.splice(e,0,t.id)}Yo(e,r,n,o,i,s,p,c)}else bi(e,o[s].id).changed();return Promise.resolve()},e.apply=hi,e.applyBackground=ni,e.applyStyle=ti,e.default=hi,e.getFeatureState=function(e,t){const r="getLayers"in e?xi(e,t.source):[e];for(let e=0,n=r.length;ee.id===r)),1);const s=Ho[ao(i,n)];if(s){const[e,t,n,o,i,a,l,u]=s;Array.isArray(n)&&n.splice(n.findIndex((e=>e===r)),1),Yo(e,t,n,o,i,a,l,u)}else bi(e,r).changed()},e.renderTransparent=function(e){e!==Jo&&(!function(){for(const e in ro)delete ro[e]}(),Jo=e)},e.setFeatureState=function(e,t,r){const n="getLayers"in e?xi(e,t.source):[e];for(let e=0,o=n.length;e\": {\n\t\t},\n\t\t\">=\": {\n\t\t},\n\t\t\"<\": {\n\t\t},\n\t\t\"<=\": {\n\t\t},\n\t\t\"in\": {\n\t\t},\n\t\t\"!in\": {\n\t\t},\n\t\tall: {\n\t\t},\n\t\tany: {\n\t\t},\n\t\tnone: {\n\t\t},\n\t\thas: {\n\t\t},\n\t\t\"!has\": {\n\t\t}\n\t}\n};\nvar geometry_type = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tPoint: {\n\t\t},\n\t\tLineString: {\n\t\t},\n\t\tPolygon: {\n\t\t}\n\t}\n};\nvar function_stop = {\n\ttype: \"array\",\n\tminimum: 0,\n\tmaximum: 24,\n\tvalue: [\n\t\t\"number\",\n\t\t\"color\"\n\t],\n\tlength: 2\n};\nvar expression$1 = {\n\ttype: \"array\",\n\tvalue: \"*\",\n\tminimum: 1\n};\nvar light = {\n\tanchor: {\n\t\ttype: \"enum\",\n\t\t\"default\": \"viewport\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tposition: {\n\t\ttype: \"array\",\n\t\t\"default\": [\n\t\t\t1.15,\n\t\t\t210,\n\t\t\t30\n\t\t],\n\t\tlength: 3,\n\t\tvalue: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tcolor: {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\tintensity: {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar sky = {\n\t\"sky-color\": {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#88C6FC\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"horizon-color\": {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"fog-color\": {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"fog-ground-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"horizon-fog-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.8,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"sky-horizon-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.8,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"atmosphere-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.8,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar terrain = {\n\tsource: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\texaggeration: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\t\"default\": 1\n\t}\n};\nvar projection = {\n\ttype: {\n\t\ttype: \"projectionDefinition\",\n\t\t\"default\": \"mercator\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t}\n};\nvar paint = [\n\t\"paint_fill\",\n\t\"paint_line\",\n\t\"paint_circle\",\n\t\"paint_heatmap\",\n\t\"paint_fill-extrusion\",\n\t\"paint_symbol\",\n\t\"paint_raster\",\n\t\"paint_hillshade\",\n\t\"paint_background\"\n];\nvar paint_fill = {\n\t\"fill-antialias\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-outline-color\": {\n\t\ttype: \"color\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fill-antialias\": true\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t}\n};\nvar paint_line = {\n\t\"line-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"line-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-gap-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-offset\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-dasharray\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"line widths\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"line-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-gradient\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-dasharray\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"geojson\",\n\t\t\t\thas: {\n\t\t\t\t\tlineMetrics: true\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"line-progress\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n};\nvar paint_circle = {\n\t\"circle-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 5,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"circle-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-scale\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-stroke-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t}\n};\nvar paint_heatmap = {\n\t\"heatmap-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 30,\n\t\tminimum: 1,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-weight\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-intensity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"heatmap-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": [\n\t\t\t\"interpolate\",\n\t\t\t[\n\t\t\t\t\"linear\"\n\t\t\t],\n\t\t\t[\n\t\t\t\t\"heatmap-density\"\n\t\t\t],\n\t\t\t0,\n\t\t\t\"rgba(0, 0, 255, 0)\",\n\t\t\t0.1,\n\t\t\t\"royalblue\",\n\t\t\t0.3,\n\t\t\t\"cyan\",\n\t\t\t0.5,\n\t\t\t\"lime\",\n\t\t\t0.7,\n\t\t\t\"yellow\",\n\t\t\t1,\n\t\t\t\"red\"\n\t\t],\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"heatmap-density\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t},\n\t\"heatmap-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_symbol = {\n\t\"icon-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"icon-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\toverridable: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"text-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_raster = {\n\t\"raster-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-hue-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\ttransition: true,\n\t\tunits: \"degrees\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-min\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-max\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-saturation\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-contrast\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-resampling\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tlinear: {\n\t\t\t},\n\t\t\tnearest: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"linear\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-fade-duration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\tunits: \"milliseconds\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_hillshade = {\n\t\"hillshade-illumination-direction\": {\n\t\ttype: \"number\",\n\t\t\"default\": 335,\n\t\tminimum: 0,\n\t\tmaximum: 359,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-exaggeration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-shadow-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-highlight-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#FFFFFF\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-accent-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_background = {\n\t\"background-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"background-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"background-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"background-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar transition = {\n\tduration: {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t},\n\tdelay: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t}\n};\nvar promoteId = {\n\t\"*\": {\n\t\ttype: \"string\"\n\t}\n};\nvar v8Spec = {\n\t$version: $version,\n\t$root: $root,\n\tsources: sources,\n\tsource: source,\n\tsource_vector: source_vector,\n\tsource_raster: source_raster,\n\tsource_raster_dem: source_raster_dem,\n\tsource_geojson: source_geojson,\n\tsource_video: source_video,\n\tsource_image: source_image,\n\tlayer: layer,\n\tlayout: layout,\n\tlayout_background: layout_background,\n\tlayout_fill: layout_fill,\n\tlayout_circle: layout_circle,\n\tlayout_heatmap: layout_heatmap,\n\t\"layout_fill-extrusion\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\t\"property-type\": \"constant\"\n\t}\n},\n\tlayout_line: layout_line,\n\tlayout_symbol: layout_symbol,\n\tlayout_raster: layout_raster,\n\tlayout_hillshade: layout_hillshade,\n\tfilter: filter,\n\tfilter_operator: filter_operator,\n\tgeometry_type: geometry_type,\n\t\"function\": {\n\texpression: {\n\t\ttype: \"expression\"\n\t},\n\tstops: {\n\t\ttype: \"array\",\n\t\tvalue: \"function_stop\"\n\t},\n\tbase: {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0\n\t},\n\tproperty: {\n\t\ttype: \"string\",\n\t\t\"default\": \"$zoom\"\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tidentity: {\n\t\t\t},\n\t\t\texponential: {\n\t\t\t},\n\t\t\tinterval: {\n\t\t\t},\n\t\t\tcategorical: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"exponential\"\n\t},\n\tcolorSpace: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\trgb: {\n\t\t\t},\n\t\t\tlab: {\n\t\t\t},\n\t\t\thcl: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"rgb\"\n\t},\n\t\"default\": {\n\t\ttype: \"*\",\n\t\trequired: false\n\t}\n},\n\tfunction_stop: function_stop,\n\texpression: expression$1,\n\tlight: light,\n\tsky: sky,\n\tterrain: terrain,\n\tprojection: projection,\n\tpaint: paint,\n\tpaint_fill: paint_fill,\n\t\"paint_fill-extrusion\": {\n\t\"fill-extrusion-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-extrusion-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-extrusion-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"fill-extrusion-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-base\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"fill-extrusion-height\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-vertical-gradient\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tpaint_line: paint_line,\n\tpaint_circle: paint_circle,\n\tpaint_heatmap: paint_heatmap,\n\tpaint_symbol: paint_symbol,\n\tpaint_raster: paint_raster,\n\tpaint_hillshade: paint_hillshade,\n\tpaint_background: paint_background,\n\ttransition: transition,\n\t\"property-type\": {\n\t\"data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded-data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"color-ramp\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"data-constant\": {\n\t\ttype: \"property-type\"\n\t},\n\tconstant: {\n\t\ttype: \"property-type\"\n\t}\n},\n\tpromoteId: promoteId\n};\n\nconst refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\n\nfunction deref(layer, parent) {\n const result = {};\n for (const k in layer) {\n if (k !== 'ref') {\n result[k] = layer[k];\n }\n }\n refProperties.forEach((k) => {\n if (k in parent) {\n result[k] = parent[k];\n }\n });\n return result;\n}\n/**\n * Given an array of layers, some of which may contain `ref` properties\n * whose value is the `id` of another property, return a new array where\n * such layers have been augmented with the 'type', 'source', etc. properties\n * from the parent layer, and the `ref` property has been removed.\n *\n * The input is not modified. The output may contain references to portions\n * of the input.\n *\n * @private\n * @param {Array} layers\n * @returns {Array}\n */\nfunction derefLayers(layers) {\n layers = layers.slice();\n const map = Object.create(null);\n for (let i = 0; i < layers.length; i++) {\n map[layers[i].id] = layers[i];\n }\n for (let i = 0; i < layers.length; i++) {\n if ('ref' in layers[i]) {\n layers[i] = deref(layers[i], map[layers[i].ref]);\n }\n }\n return layers;\n}\n\n/**\n * Deeply compares two object literals.\n *\n * @private\n */\nfunction deepEqual(a, b) {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object'))\n return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length)\n return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * The main reason for this method is to allow type check when adding a command to the array.\n * @param commands - The commands array to add to\n * @param command - The command to add\n */\nfunction addCommand(commands, command) {\n commands.push(command);\n}\nfunction addSource(sourceId, after, commands) {\n addCommand(commands, { command: 'addSource', args: [sourceId, after[sourceId]] });\n}\nfunction removeSource(sourceId, commands, sourcesRemoved) {\n addCommand(commands, { command: 'removeSource', args: [sourceId] });\n sourcesRemoved[sourceId] = true;\n}\nfunction updateSource(sourceId, after, commands, sourcesRemoved) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\nfunction canUpdateGeoJSON(before, after, sourceId) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\nfunction diffSources(before, after, commands, sourcesRemoved) {\n before = before || {};\n after = after || {};\n let sourceId;\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n }\n else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (before[sourceId].type === 'geojson' && after[sourceId].type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {\n addCommand(commands, { command: 'setGeoJSONSourceData', args: [sourceId, after[sourceId].data] });\n }\n else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\nfunction diffLayerPropertyChanges(before, after, commands, layerId, klass, command) {\n before = before || {};\n after = after || {};\n for (const prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n for (const prop in after) {\n if (!Object.prototype.hasOwnProperty.call(after, prop) || Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n}\nfunction pluckId(layer) {\n return layer.id;\n}\nfunction indexById(group, layer) {\n group[layer.id] = layer;\n return group;\n}\nfunction diffLayers(before, after, commands) {\n before = before || [];\n after = after || [];\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n let layerId;\n let beforeLayer;\n let afterLayer;\n let insertBeforeLayerId;\n let prop;\n // remove layers\n for (let i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n addCommand(commands, { command: 'removeLayer', args: [layerId] });\n tracker.splice(tracker.indexOf(layerId, d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n // add/reorder layers\n for (let i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n if (tracker[tracker.length - 1 - i] === layerId)\n continue;\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n addCommand(commands, { command: 'removeLayer', args: [layerId] });\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n addCommand(commands, { command: 'addLayer', args: [afterIndex[layerId], insertBeforeLayerId] });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n // update layers\n for (let i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer))\n continue;\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {\n addCommand(commands, { command: 'removeLayer', args: [layerId] });\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n addCommand(commands, { command: 'addLayer', args: [afterLayer, insertBeforeLayerId] });\n continue;\n }\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, 'setLayoutProperty');\n diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, 'setPaintProperty');\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n addCommand(commands, { command: 'setFilter', args: [layerId, afterLayer.filter] });\n }\n if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) || !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) {\n addCommand(commands, { command: 'setLayerZoomRange', args: [layerId, afterLayer.minzoom, afterLayer.maxzoom] });\n }\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), 'setPaintProperty');\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n addCommand(commands, { command: 'setLayerProperty', args: [layerId, prop, afterLayer[prop]] });\n }\n }\n for (prop in afterLayer) {\n if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) || Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||\n prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), 'setPaintProperty');\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n addCommand(commands, { command: 'setLayerProperty', args: [layerId, prop, afterLayer[prop]] });\n }\n }\n }\n}\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nfunction diff(before, after) {\n if (!before)\n return [{ command: 'setStyle', args: [after] }];\n let commands = [];\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{ command: 'setStyle', args: [after] }];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({ command: 'setCenter', args: [after.center] });\n }\n if (!deepEqual(before.centerAltitude, after.centerAltitude)) {\n commands.push({ command: 'setCenterAltitude', args: [after.centerAltitude] });\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({ command: 'setZoom', args: [after.zoom] });\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({ command: 'setBearing', args: [after.bearing] });\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({ command: 'setPitch', args: [after.pitch] });\n }\n if (!deepEqual(before.roll, after.roll)) {\n commands.push({ command: 'setRoll', args: [after.roll] });\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({ command: 'setSprite', args: [after.sprite] });\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({ command: 'setGlyphs', args: [after.glyphs] });\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({ command: 'setTransition', args: [after.transition] });\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({ command: 'setLight', args: [after.light] });\n }\n if (!deepEqual(before.terrain, after.terrain)) {\n commands.push({ command: 'setTerrain', args: [after.terrain] });\n }\n if (!deepEqual(before.sky, after.sky)) {\n commands.push({ command: 'setSky', args: [after.sky] });\n }\n if (!deepEqual(before.projection, after.projection)) {\n commands.push({ command: 'setProjection', args: [after.projection] });\n }\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if ('source' in layer && sourcesRemoved[layer.source]) {\n commands.push({ command: 'removeLayer', args: [layer.id] });\n }\n else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n }\n catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{ command: 'setStyle', args: [after] }];\n }\n return commands;\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ValidationError {\n constructor(key, value, message, identifier) {\n this.message = (key ? `${key}: ` : '') + message;\n if (identifier)\n this.identifier = identifier;\n if (value !== null && value !== undefined && value.__line__) {\n this.line = value.__line__;\n }\n }\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ParsingError {\n constructor(error) {\n this.error = error;\n this.message = error.message;\n const match = error.message.match(/line (\\d+)/);\n this.line = match ? parseInt(match[1], 10) : 0;\n }\n}\n\nfunction extendBy(output, ...inputs) {\n for (const input of inputs) {\n for (const k in input) {\n output[k] = input[k];\n }\n }\n return output;\n}\n\nclass ExpressionParsingError extends Error {\n constructor(key, message) {\n super(message);\n this.message = message;\n this.key = key;\n }\n}\n\n/**\n * Tracks `let` bindings during expression parsing.\n * @private\n */\nclass Scope {\n constructor(parent, bindings = []) {\n this.parent = parent;\n this.bindings = {};\n for (const [name, expression] of bindings) {\n this.bindings[name] = expression;\n }\n }\n concat(bindings) {\n return new Scope(this, bindings);\n }\n get(name) {\n if (this.bindings[name]) {\n return this.bindings[name];\n }\n if (this.parent) {\n return this.parent.get(name);\n }\n throw new Error(`${name} not found in scope.`);\n }\n has(name) {\n if (this.bindings[name])\n return true;\n return this.parent ? this.parent.has(name) : false;\n }\n}\n\nconst NullType = { kind: 'null' };\nconst NumberType = { kind: 'number' };\nconst StringType = { kind: 'string' };\nconst BooleanType = { kind: 'boolean' };\nconst ColorType = { kind: 'color' };\nconst ProjectionDefinitionType = { kind: 'projectionDefinition' };\nconst ObjectType = { kind: 'object' };\nconst ValueType = { kind: 'value' };\nconst ErrorType = { kind: 'error' };\nconst CollatorType = { kind: 'collator' };\nconst FormattedType = { kind: 'formatted' };\nconst PaddingType = { kind: 'padding' };\nconst ResolvedImageType = { kind: 'resolvedImage' };\nconst VariableAnchorOffsetCollectionType = { kind: 'variableAnchorOffsetCollection' };\nfunction array(itemType, N) {\n return {\n kind: 'array',\n itemType,\n N\n };\n}\nfunction typeToString(type) {\n if (type.kind === 'array') {\n const itemType = typeToString(type.itemType);\n return typeof type.N === 'number' ?\n `array<${itemType}, ${type.N}>` :\n type.itemType.kind === 'value' ? 'array' : `array<${itemType}>`;\n }\n else {\n return type.kind;\n }\n}\nconst valueMemberTypes = [\n NullType,\n NumberType,\n StringType,\n BooleanType,\n ColorType,\n ProjectionDefinitionType,\n FormattedType,\n ObjectType,\n array(ValueType),\n PaddingType,\n ResolvedImageType,\n VariableAnchorOffsetCollectionType\n];\n/**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message.\n * @private\n */\nfunction checkSubtype(expected, t) {\n if (t.kind === 'error') {\n // Error is a subtype of every type\n return null;\n }\n else if (expected.kind === 'array') {\n if (t.kind === 'array' &&\n ((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) &&\n (typeof expected.N !== 'number' || expected.N === t.N)) {\n return null;\n }\n }\n else if (expected.kind === t.kind) {\n return null;\n }\n else if (expected.kind === 'value') {\n for (const memberType of valueMemberTypes) {\n if (!checkSubtype(memberType, t)) {\n return null;\n }\n }\n }\n return `Expected ${typeToString(expected)} but found ${typeToString(t)} instead.`;\n}\nfunction isValidType(provided, allowedTypes) {\n return allowedTypes.some(t => t.kind === provided.kind);\n}\nfunction isValidNativeType(provided, allowedTypes) {\n return allowedTypes.some(t => {\n if (t === 'null') {\n return provided === null;\n }\n else if (t === 'array') {\n return Array.isArray(provided);\n }\n else if (t === 'object') {\n return provided && !Array.isArray(provided) && typeof provided === 'object';\n }\n else {\n return t === typeof provided;\n }\n });\n}\n/**\n * Verify whether the specified type is of the same type as the specified sample.\n *\n * @param provided Type to verify\n * @param sample Sample type to reference\n * @returns `true` if both objects are of the same type, `false` otherwise\n * @example basic types\n * if (verifyType(outputType, ValueType)) {\n * // type narrowed to:\n * outputType.kind; // 'value'\n * }\n * @example array types\n * if (verifyType(outputType, array(NumberType))) {\n * // type narrowed to:\n * outputType.kind; // 'array'\n * outputType.itemType; // NumberTypeT\n * outputType.itemType.kind; // 'number'\n * }\n */\nfunction verifyType(provided, sample) {\n if (provided.kind === 'array' && sample.kind === 'array') {\n return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number';\n }\n return provided.kind === sample.kind;\n}\n\n// See https://observablehq.com/@mbostock/lab-and-rgb\nconst Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;\nfunction constrainAngle(angle) {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\nfunction rgbToLab([r, g, b, alpha]) {\n r = rgb2xyz(r);\n g = rgb2xyz(g);\n b = rgb2xyz(b);\n let x, z;\n const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn);\n if (r === g && g === b) {\n x = z = y;\n }\n else {\n x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);\n z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);\n }\n const l = 116 * y - 16;\n return [(l < 0) ? 0 : l, 500 * (x - y), 200 * (y - z), alpha];\n}\nfunction rgb2xyz(x) {\n return (x <= 0.04045) ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);\n}\nfunction xyz2lab(t) {\n return (t > t3) ? Math.pow(t, 1 / 3) : t / t2 + t0;\n}\nfunction labToRgb([l, a, b, alpha]) {\n let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200;\n y = Yn * lab2xyz(y);\n x = Xn * lab2xyz(x);\n z = Zn * lab2xyz(z);\n return [\n xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), // D50 -> sRGB\n xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z),\n xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),\n alpha,\n ];\n}\nfunction xyz2rgb(x) {\n x = (x <= 0.00304) ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;\n return (x < 0) ? 0 : (x > 1) ? 1 : x; // clip to 0..1 range\n}\nfunction lab2xyz(t) {\n return (t > t1) ? t * t * t : t2 * (t - t0);\n}\nfunction rgbToHcl(rgbColor) {\n const [l, a, b, alpha] = rgbToLab(rgbColor);\n const c = Math.sqrt(a * a + b * b);\n const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN;\n return [h, c, l, alpha];\n}\nfunction hclToRgb([h, c, l, alpha]) {\n h = isNaN(h) ? 0 : h * deg2rad;\n return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]);\n}\n// https://drafts.csswg.org/css-color-4/#hsl-to-rgb\nfunction hslToRgb([h, s, l, alpha]) {\n h = constrainAngle(h);\n s /= 100;\n l /= 100;\n function f(n) {\n const k = (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n return [f(0), f(8), f(4), alpha];\n}\n\n/**\n * CSS color parser compliant with CSS Color 4 Specification.\n * Supports: named colors, `transparent` keyword, all rgb hex notations,\n * rgb(), rgba(), hsl() and hsla() functions.\n * Does not round the parsed values to integers from the range 0..255.\n *\n * Syntax:\n *\n * = | \n * = | \n *\n * rgb() = rgb( {3} [ / ]? ) | rgb( {3} [ / ]? )\n * rgb() = rgb( #{3} , ? ) | rgb( #{3} , ? )\n *\n * hsl() = hsl( [ / ]? )\n * hsl() = hsl( , , , ? )\n *\n * Caveats:\n * - - with optional `deg` suffix; `grad`, `rad`, `turn` are not supported\n * - `none` keyword is not supported\n * - comments inside rgb()/hsl() are not supported\n * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb()\n * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl()\n *\n * @param input CSS color string to parse.\n * @returns Color in sRGB color space, with `red`, `green`, `blue`\n * and `alpha` channels normalized to the range 0..1,\n * or `undefined` if the input is not a valid color string.\n */\nfunction parseCssColor(input) {\n input = input.toLowerCase().trim();\n if (input === 'transparent') {\n return [0, 0, 0, 0];\n }\n // 'white', 'black', 'blue'\n const namedColorsMatch = namedColors[input];\n if (namedColorsMatch) {\n const [r, g, b] = namedColorsMatch;\n return [r / 255, g / 255, b / 255, 1];\n }\n // #f0c, #f0cf, #ff00cc, #ff00ccff\n if (input.startsWith('#')) {\n const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n if (hexRegexp.test(input)) {\n const step = input.length < 6 ? 1 : 2;\n let i = 1;\n return [\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i += step)),\n parseHex(input.slice(i, i + step) || 'ff'),\n ];\n }\n }\n // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6)\n if (input.startsWith('rgb')) {\n const rgbRegExp = /^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const rgbMatch = input.match(rgbRegExp);\n if (rgbMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n r, // \n rp, // % (optional)\n f1, // , (optional)\n g, // \n gp, // % (optional)\n f2, // , (optional)\n b, // \n bp, // % (optional)\n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = rgbMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const valFormat = [rp, gp, bp].join('');\n const maxValue = (valFormat === '%%%') ? 100 :\n (valFormat === '') ? 255 : 0;\n if (maxValue) {\n const rgba = [\n clamp(+r / maxValue, 0, 1),\n clamp(+g / maxValue, 0, 1),\n clamp(+b / maxValue, 0, 1),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(rgba)) {\n return rgba;\n }\n // invalid numbers\n }\n // values must be all numbers or all percentages\n }\n return; // comma optional syntax requires no commas at all\n }\n }\n // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%)\n const hslRegExp = /^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const hslMatch = input.match(hslRegExp);\n if (hslMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n h, // \n f1, // , (optional)\n s, // \n f2, // , (optional)\n l, // \n f3, // ,|/ (optional)\n a, // (optional)\n ap, // % (optional)\n ] = hslMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const hsla = [\n +h,\n clamp(+s, 0, 100),\n clamp(+l, 0, 100),\n a ? parseAlpha(+a, ap) : 1,\n ];\n if (validateNumbers(hsla)) {\n return hslToRgb(hsla);\n }\n // invalid numbers\n }\n // comma optional syntax requires no commas at all\n }\n}\nfunction parseHex(hex) {\n return parseInt(hex.padEnd(2, hex), 16) / 255;\n}\nfunction parseAlpha(a, asPercentage) {\n return clamp(asPercentage ? (a / 100) : a, 0, 1);\n}\nfunction clamp(n, min, max) {\n return Math.min(Math.max(min, n), max);\n}\n/**\n * The regular expression for numeric values is not super specific, and it may\n * happen that it will accept a value that is not a valid number. In order to\n * detect and eliminate such values this function exists.\n *\n * @param array Array of uncertain numbers.\n * @returns `true` if the specified array contains only valid numbers, `false` otherwise.\n */\nfunction validateNumbers(array) {\n return !array.some(Number.isNaN);\n}\n/**\n * To generate:\n * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors}\n * - run in the console:\n * @example\n * copy(`{\\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\\s+/).join(', ')}],`).join('\\n')}\\n}`);\n */\nconst namedColors = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50],\n};\n\nfunction interpolateNumber(from, to, t) {\n return from + t * (to - from);\n}\nfunction interpolateArray(from, to, t) {\n return from.map((d, i) => {\n return interpolateNumber(d, to[i], t);\n });\n}\n\n/**\n * Checks whether the specified color space is one of the supported interpolation color spaces.\n *\n * @param colorSpace Color space key to verify.\n * @returns `true` if the specified color space is one of the supported\n * interpolation color spaces, `false` otherwise\n */\nfunction isSupportedInterpolationColorSpace(colorSpace) {\n return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab';\n}\n/**\n * Color representation used by WebGL.\n * Defined in sRGB color space and pre-blended with alpha.\n * @private\n */\nclass Color {\n /**\n * @param r Red component premultiplied by `alpha` 0..1\n * @param g Green component premultiplied by `alpha` 0..1\n * @param b Blue component premultiplied by `alpha` 0..1\n * @param [alpha=1] Alpha component 0..1\n * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already\n * been multiplied by alpha. If `true` nothing happens if `false` then they will\n * be multiplied automatically.\n */\n constructor(r, g, b, alpha = 1, premultiplied = true) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = alpha;\n if (!premultiplied) {\n this.r *= alpha;\n this.g *= alpha;\n this.b *= alpha;\n if (!alpha) {\n // alpha = 0 erases completely rgb channels. This behavior is not desirable\n // if this particular color is later used in color interpolation.\n // Because of that, a reference to original color is saved.\n this.overwriteGetter('rgb', [r, g, b, alpha]);\n }\n }\n }\n /**\n * Parses CSS color strings and converts colors to sRGB color space if needed.\n * Officially supported color formats:\n * - keyword, e.g. 'aquamarine' or 'steelblue'\n * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'\n * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'\n * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'\n *\n * @param input CSS color string to parse.\n * @returns A `Color` instance, or `undefined` if the input is not a valid color string.\n */\n static parse(input) {\n // in zoom-and-property function input could be an instance of Color class\n if (input instanceof Color) {\n return input;\n }\n if (typeof input !== 'string') {\n return;\n }\n const rgba = parseCssColor(input);\n if (rgba) {\n return new Color(...rgba, false);\n }\n }\n /**\n * Used in color interpolation and by 'to-rgba' expression.\n *\n * @returns Gien color, with reversed alpha blending, in sRGB color space.\n */\n get rgb() {\n const { r, g, b, a } = this;\n const f = a || Infinity; // reverse alpha blending factor\n return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]);\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in HCL color space.\n */\n get hcl() {\n return this.overwriteGetter('hcl', rgbToHcl(this.rgb));\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in LAB color space.\n */\n get lab() {\n return this.overwriteGetter('lab', rgbToLab(this.rgb));\n }\n /**\n * Lazy getter pattern. When getter is called for the first time lazy value\n * is calculated and then overwrites getter function in given object instance.\n *\n * @example:\n * const redColor = Color.parse('red');\n * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate\n * // the value of red in HCL space and invoke this `overwriteGetter` function\n * // which in turn will set a field with a key 'hcl' in the `redColor` object.\n * // In other words it will override `get hcl()` from its `Color` prototype\n * // with its own property: hcl = [calculated red value in hcl].\n * let y = redColor.hcl; // next call will no longer invoke getter but simply\n * // return the previously calculated value\n * x === y; // true - `x` is exactly the same object as `y`\n *\n * @param getterKey Getter key\n * @param lazyValue Lazily calculated value to be memoized by current instance\n * @private\n */\n overwriteGetter(getterKey, lazyValue) {\n Object.defineProperty(this, getterKey, { value: lazyValue });\n return lazyValue;\n }\n /**\n * Used by 'to-string' expression.\n *\n * @returns Serialized color in format `rgba(r,g,b,a)`\n * where r,g,b are numbers within 0..255 and alpha is number within 1..0\n *\n * @example\n * var purple = new Color.parse('purple');\n * purple.toString; // = \"rgba(128,0,128,1)\"\n * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');\n * translucentGreen.toString(); // = \"rgba(26,207,26,0.73)\"\n */\n toString() {\n const [r, g, b, a] = this.rgb;\n return `rgba(${[r, g, b].map(n => Math.round(n * 255)).join(',')},${a})`;\n }\n static interpolate(from, to, t, spaceKey = 'rgb') {\n switch (spaceKey) {\n case 'rgb': {\n const [r, g, b, alpha] = interpolateArray(from.rgb, to.rgb, t);\n return new Color(r, g, b, alpha, false);\n }\n case 'hcl': {\n const [hue0, chroma0, light0, alphaF] = from.hcl;\n const [hue1, chroma1, light1, alphaT] = to.hcl;\n // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js\n let hue, chroma;\n if (!isNaN(hue0) && !isNaN(hue1)) {\n let dh = hue1 - hue0;\n if (hue1 > hue0 && dh > 180) {\n dh -= 360;\n }\n else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh += 360;\n }\n hue = hue0 + t * dh;\n }\n else if (!isNaN(hue0)) {\n hue = hue0;\n if (light1 === 1 || light1 === 0)\n chroma = chroma0;\n }\n else if (!isNaN(hue1)) {\n hue = hue1;\n if (light0 === 1 || light0 === 0)\n chroma = chroma1;\n }\n else {\n hue = NaN;\n }\n const [r, g, b, alpha] = hclToRgb([\n hue,\n chroma !== null && chroma !== undefined ? chroma : interpolateNumber(chroma0, chroma1, t),\n interpolateNumber(light0, light1, t),\n interpolateNumber(alphaF, alphaT, t),\n ]);\n return new Color(r, g, b, alpha, false);\n }\n case 'lab': {\n const [r, g, b, alpha] = labToRgb(interpolateArray(from.lab, to.lab, t));\n return new Color(r, g, b, alpha, false);\n }\n }\n }\n}\nColor.black = new Color(0, 0, 0, 1);\nColor.white = new Color(1, 1, 1, 1);\nColor.transparent = new Color(0, 0, 0, 0);\nColor.red = new Color(1, 0, 0, 1);\n\n// Flow type declarations for Intl cribbed from\n// https://github.com/facebook/flow/issues/1270\nclass Collator {\n constructor(caseSensitive, diacriticSensitive, locale) {\n if (caseSensitive)\n this.sensitivity = diacriticSensitive ? 'variant' : 'case';\n else\n this.sensitivity = diacriticSensitive ? 'accent' : 'base';\n this.locale = locale;\n this.collator = new Intl.Collator(this.locale ? this.locale : [], { sensitivity: this.sensitivity, usage: 'search' });\n }\n compare(lhs, rhs) {\n return this.collator.compare(lhs, rhs);\n }\n resolvedLocale() {\n // We create a Collator without \"usage: search\" because we don't want\n // the search options encoded in our result (e.g. \"en-u-co-search\")\n return new Intl.Collator(this.locale ? this.locale : [])\n .resolvedOptions().locale;\n }\n}\n\nconst VERTICAL_ALIGN_OPTIONS = ['bottom', 'center', 'top'];\nclass FormattedSection {\n constructor(text, image, scale, fontStack, textColor, verticalAlign) {\n this.text = text;\n this.image = image;\n this.scale = scale;\n this.fontStack = fontStack;\n this.textColor = textColor;\n this.verticalAlign = verticalAlign;\n }\n}\nclass Formatted {\n constructor(sections) {\n this.sections = sections;\n }\n static fromString(unformatted) {\n return new Formatted([new FormattedSection(unformatted, null, null, null, null, null)]);\n }\n isEmpty() {\n if (this.sections.length === 0)\n return true;\n return !this.sections.some(section => section.text.length !== 0 ||\n (section.image && section.image.name.length !== 0));\n }\n static factory(text) {\n if (text instanceof Formatted) {\n return text;\n }\n else {\n return Formatted.fromString(text);\n }\n }\n toString() {\n if (this.sections.length === 0)\n return '';\n return this.sections.map(section => section.text).join('');\n }\n}\n\n/**\n * A set of four numbers representing padding around a box. Create instances from\n * bare arrays or numeric values using the static method `Padding.parse`.\n * @private\n */\nclass Padding {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric padding values\n * @param input A padding value\n * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value.\n */\n static parse(input) {\n if (input instanceof Padding) {\n return input;\n }\n // Backwards compatibility: bare number is treated the same as array with single value.\n // Padding applies to all four sides.\n if (typeof input === 'number') {\n return new Padding([input, input, input, input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n if (input.length < 1 || input.length > 4) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n // Expand shortcut properties into explicit 4-sided values\n switch (input.length) {\n case 1:\n input = [input[0], input[0], input[0], input[0]];\n break;\n case 2:\n input = [input[0], input[1], input[0], input[1]];\n break;\n case 3:\n input = [input[0], input[1], input[2], input[1]];\n break;\n }\n return new Padding(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n static interpolate(from, to, t) {\n return new Padding(interpolateArray(from.values, to.values, t));\n }\n}\n\nclass RuntimeError {\n constructor(message) {\n this.name = 'ExpressionEvaluationError';\n this.message = message;\n }\n toJSON() {\n return this.message;\n }\n}\n\n/** Set of valid anchor positions, as a set for validation */\nconst anchors = new Set(['center', 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right']);\n/**\n * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from\n * bare arrays using the static method `VariableAnchorOffsetCollection.parse`.\n * @private\n */\nclass VariableAnchorOffsetCollection {\n constructor(values) {\n this.values = values.slice();\n }\n static parse(input) {\n if (input instanceof VariableAnchorOffsetCollection) {\n return input;\n }\n if (!Array.isArray(input) ||\n input.length < 1 ||\n input.length % 2 !== 0) {\n return undefined;\n }\n for (let i = 0; i < input.length; i += 2) {\n // Elements in even positions should be anchor positions; Elements in odd positions should be offset values\n const anchorValue = input[i];\n const offsetValue = input[i + 1];\n if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) {\n return undefined;\n }\n if (!Array.isArray(offsetValue) || offsetValue.length !== 2 || typeof offsetValue[0] !== 'number' || typeof offsetValue[1] !== 'number') {\n return undefined;\n }\n }\n return new VariableAnchorOffsetCollection(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n static interpolate(from, to, t) {\n const fromValues = from.values;\n const toValues = to.values;\n if (fromValues.length !== toValues.length) {\n throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`);\n }\n const output = [];\n for (let i = 0; i < fromValues.length; i += 2) {\n // Anchor entries must match\n if (fromValues[i] !== toValues[i]) {\n throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`);\n }\n output.push(fromValues[i]);\n // Interpolate the offset values for each anchor\n const [fx, fy] = fromValues[i + 1];\n const [tx, ty] = toValues[i + 1];\n output.push([interpolateNumber(fx, tx, t), interpolateNumber(fy, ty, t)]);\n }\n return new VariableAnchorOffsetCollection(output);\n }\n}\n\nclass ResolvedImage {\n constructor(options) {\n this.name = options.name;\n this.available = options.available;\n }\n toString() {\n return this.name;\n }\n static fromString(name) {\n if (!name)\n return null; // treat empty values as no image\n return new ResolvedImage({ name, available: false });\n }\n}\n\nclass ProjectionDefinition {\n constructor(from, to, transition) {\n this.from = from;\n this.to = to;\n this.transition = transition;\n }\n static interpolate(from, to, t) {\n return new ProjectionDefinition(from, to, t);\n }\n static parse(input) {\n if (input instanceof ProjectionDefinition) {\n return input;\n }\n if (Array.isArray(input) && input.length === 3 && typeof input[0] === 'string' && typeof input[1] === 'string' && typeof input[2] === 'number') {\n return new ProjectionDefinition(input[0], input[1], input[2]);\n }\n if (typeof input === 'object' && typeof input.from === 'string' && typeof input.to === 'string' && typeof input.transition === 'number') {\n return new ProjectionDefinition(input.from, input.to, input.transition);\n }\n if (typeof input === 'string') {\n return new ProjectionDefinition(input, input, 1);\n }\n return undefined;\n }\n}\n\nfunction validateRGBA(r, g, b, a) {\n if (!(typeof r === 'number' && r >= 0 && r <= 255 &&\n typeof g === 'number' && g >= 0 && g <= 255 &&\n typeof b === 'number' && b >= 0 && b <= 255)) {\n const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];\n return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;\n }\n if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) {\n return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;\n }\n return null;\n}\nfunction isValue(mixed) {\n if (mixed === null ||\n typeof mixed === 'string' ||\n typeof mixed === 'boolean' ||\n typeof mixed === 'number' ||\n mixed instanceof ProjectionDefinition ||\n mixed instanceof Color ||\n mixed instanceof Collator ||\n mixed instanceof Formatted ||\n mixed instanceof Padding ||\n mixed instanceof VariableAnchorOffsetCollection ||\n mixed instanceof ResolvedImage) {\n return true;\n }\n else if (Array.isArray(mixed)) {\n for (const item of mixed) {\n if (!isValue(item)) {\n return false;\n }\n }\n return true;\n }\n else if (typeof mixed === 'object') {\n for (const key in mixed) {\n if (!isValue(mixed[key])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\nfunction typeOf(value) {\n if (value === null) {\n return NullType;\n }\n else if (typeof value === 'string') {\n return StringType;\n }\n else if (typeof value === 'boolean') {\n return BooleanType;\n }\n else if (typeof value === 'number') {\n return NumberType;\n }\n else if (value instanceof Color) {\n return ColorType;\n }\n else if (value instanceof ProjectionDefinition) {\n return ProjectionDefinitionType;\n }\n else if (value instanceof Collator) {\n return CollatorType;\n }\n else if (value instanceof Formatted) {\n return FormattedType;\n }\n else if (value instanceof Padding) {\n return PaddingType;\n }\n else if (value instanceof VariableAnchorOffsetCollection) {\n return VariableAnchorOffsetCollectionType;\n }\n else if (value instanceof ResolvedImage) {\n return ResolvedImageType;\n }\n else if (Array.isArray(value)) {\n const length = value.length;\n let itemType;\n for (const item of value) {\n const t = typeOf(item);\n if (!itemType) {\n itemType = t;\n }\n else if (itemType === t) {\n continue;\n }\n else {\n itemType = ValueType;\n break;\n }\n }\n return array(itemType || ValueType, length);\n }\n else {\n return ObjectType;\n }\n}\nfunction valueToString(value) {\n const type = typeof value;\n if (value === null) {\n return '';\n }\n else if (type === 'string' || type === 'number' || type === 'boolean') {\n return String(value);\n }\n else if (value instanceof Color || value instanceof ProjectionDefinition || value instanceof Formatted || value instanceof Padding || value instanceof VariableAnchorOffsetCollection || value instanceof ResolvedImage) {\n return value.toString();\n }\n else {\n return JSON.stringify(value);\n }\n}\n\nclass Literal {\n constructor(type, value) {\n this.type = type;\n this.value = value;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (!isValue(args[1]))\n return context.error('invalid value');\n const value = args[1];\n let type = typeOf(value);\n // special case: infer the item type if possible for zero-length arrays\n const expected = context.expectedType;\n if (type.kind === 'array' &&\n type.N === 0 &&\n expected &&\n expected.kind === 'array' &&\n (typeof expected.N !== 'number' || expected.N === 0)) {\n type = expected;\n }\n return new Literal(type, value);\n }\n evaluate() {\n return this.value;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nconst types$1 = {\n string: StringType,\n number: NumberType,\n boolean: BooleanType,\n object: ObjectType\n};\nclass Assertion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n let i = 1;\n let type;\n const name = args[0];\n if (name === 'array') {\n let itemType;\n if (args.length > 2) {\n const type = args[1];\n if (typeof type !== 'string' || !(type in types$1) || type === 'object')\n return context.error('The item type argument of \"array\" must be one of string, number, boolean', 1);\n itemType = types$1[type];\n i++;\n }\n else {\n itemType = ValueType;\n }\n let N;\n if (args.length > 3) {\n if (args[2] !== null &&\n (typeof args[2] !== 'number' ||\n args[2] < 0 ||\n args[2] !== Math.floor(args[2]))) {\n return context.error('The length argument to \"array\" must be a positive integer literal', 2);\n }\n N = args[2];\n i++;\n }\n type = array(itemType, N);\n }\n else {\n if (!types$1[name])\n throw new Error(`Types doesn't contain name = ${name}`);\n type = types$1[name];\n }\n const parsed = [];\n for (; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Assertion(type, parsed);\n }\n evaluate(ctx) {\n for (let i = 0; i < this.args.length; i++) {\n const value = this.args[i].evaluate(ctx);\n const error = checkSubtype(this.type, typeOf(value));\n if (!error) {\n return value;\n }\n else if (i === this.args.length - 1) {\n throw new RuntimeError(`Expected value to be of type ${typeToString(this.type)}, but found ${typeToString(typeOf(value))} instead.`);\n }\n }\n throw new Error();\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst types = {\n 'to-boolean': BooleanType,\n 'to-color': ColorType,\n 'to-number': NumberType,\n 'to-string': StringType\n};\n/**\n * Special form for error-coalescing coercion expressions \"to-number\",\n * \"to-color\". Since these coercions can fail at runtime, they accept multiple\n * arguments, only evaluating one at a time until one succeeds.\n *\n * @private\n */\nclass Coercion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n const name = args[0];\n if (!types[name])\n throw new Error(`Can't parse ${name} as it is not part of the known types`);\n if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2)\n return context.error('Expected one argument.');\n const type = types[name];\n const parsed = [];\n for (let i = 1; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Coercion(type, parsed);\n }\n evaluate(ctx) {\n switch (this.type.kind) {\n case 'boolean':\n return Boolean(this.args[0].evaluate(ctx));\n case 'color': {\n let input;\n let error;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n error = null;\n if (input instanceof Color) {\n return input;\n }\n else if (typeof input === 'string') {\n const c = ctx.parseColor(input);\n if (c)\n return c;\n }\n else if (Array.isArray(input)) {\n if (input.length < 3 || input.length > 4) {\n error = `Invalid rgba value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`;\n }\n else {\n error = validateRGBA(input[0], input[1], input[2], input[3]);\n }\n if (!error) {\n return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);\n }\n }\n }\n throw new RuntimeError(error || `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'padding': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const pad = Padding.parse(input);\n if (pad) {\n return pad;\n }\n }\n throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'variableAnchorOffsetCollection': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const coll = VariableAnchorOffsetCollection.parse(input);\n if (coll) {\n return coll;\n }\n }\n throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'number': {\n let value = null;\n for (const arg of this.args) {\n value = arg.evaluate(ctx);\n if (value === null)\n return 0;\n const num = Number(value);\n if (isNaN(num))\n continue;\n return num;\n }\n throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`);\n }\n case 'formatted':\n // There is no explicit 'to-formatted' but this coercion can be implicitly\n // created by properties that expect the 'formatted' type.\n return Formatted.fromString(valueToString(this.args[0].evaluate(ctx)));\n case 'resolvedImage':\n return ResolvedImage.fromString(valueToString(this.args[0].evaluate(ctx)));\n case 'projectionDefinition':\n return this.args[0].evaluate(ctx);\n default:\n return valueToString(this.args[0].evaluate(ctx));\n }\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\nclass EvaluationContext {\n constructor() {\n this.globals = null;\n this.feature = null;\n this.featureState = null;\n this.formattedSection = null;\n this._parseColorCache = {};\n this.availableImages = null;\n this.canonical = null;\n }\n id() {\n return this.feature && 'id' in this.feature ? this.feature.id : null;\n }\n geometryType() {\n return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;\n }\n geometry() {\n return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n }\n canonicalID() {\n return this.canonical;\n }\n properties() {\n return this.feature && this.feature.properties || {};\n }\n parseColor(input) {\n let cached = this._parseColorCache[input];\n if (!cached) {\n cached = this._parseColorCache[input] = Color.parse(input);\n }\n return cached;\n }\n}\n\n/**\n * State associated parsing at a given point in an expression tree.\n * @private\n */\nclass ParsingContext {\n constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) {\n this.registry = registry;\n this.path = path;\n this.key = path.map(part => `[${part}]`).join('');\n this.scope = scope;\n this.errors = errors;\n this.expectedType = expectedType;\n this._isConstant = isConstantFunc;\n }\n /**\n * @param expr the JSON expression to parse\n * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed\n * @param options\n * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.\n * @private\n */\n parse(expr, index, expectedType, bindings, options = {}) {\n if (index) {\n return this.concat(index, expectedType, bindings)._parse(expr, options);\n }\n return this._parse(expr, options);\n }\n _parse(expr, options) {\n if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {\n expr = ['literal', expr];\n }\n function annotate(parsed, type, typeAnnotation) {\n if (typeAnnotation === 'assert') {\n return new Assertion(type, [parsed]);\n }\n else if (typeAnnotation === 'coerce') {\n return new Coercion(type, [parsed]);\n }\n else {\n return parsed;\n }\n }\n if (Array.isArray(expr)) {\n if (expr.length === 0) {\n return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');\n }\n const op = expr[0];\n if (typeof op !== 'string') {\n this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use [\"literal\", [...]].`, 0);\n return null;\n }\n const Expr = this.registry[op];\n if (Expr) {\n let parsed = Expr.parse(expr, this);\n if (!parsed)\n return null;\n if (this.expectedType) {\n const expected = this.expectedType;\n const actual = parsed.type;\n // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.\n // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.\n // Otherwise, we do static type-checking.\n //\n // These behaviors are overridable for:\n // * The \"coalesce\" operator, which needs to omit type annotations.\n // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.\n //\n if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');\n }\n else if ((expected.kind === 'projectionDefinition') && (actual.kind === 'string' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'padding' && (actual.kind === 'value' || actual.kind === 'number' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (expected.kind === 'variableAnchorOffsetCollection' && (actual.kind === 'value' || actual.kind === 'array')) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (this.checkSubtype(expected, actual)) {\n return null;\n }\n }\n // If an expression's arguments are all literals, we can evaluate\n // it immediately and replace it with a literal value in the\n // parsed/compiled result. Expressions that expect an image should\n // not be resolved here so we can later get the available images.\n if (!(parsed instanceof Literal) && (parsed.type.kind !== 'resolvedImage') && this._isConstant(parsed)) {\n const ec = new EvaluationContext();\n try {\n parsed = new Literal(parsed.type, parsed.evaluate(ec));\n }\n catch (e) {\n this.error(e.message);\n return null;\n }\n }\n return parsed;\n }\n return this.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n else if (typeof expr === 'undefined') {\n return this.error('\\'undefined\\' value invalid. Use null instead.');\n }\n else if (typeof expr === 'object') {\n return this.error('Bare objects invalid. Use [\"literal\", {...}] instead.');\n }\n else {\n return this.error(`Expected an array, but found ${typeof expr} instead.`);\n }\n }\n /**\n * Returns a copy of this context suitable for parsing the subexpression at\n * index `index`, optionally appending to 'let' binding map.\n *\n * Note that `errors` property, intended for collecting errors while\n * parsing, is copied by reference rather than cloned.\n * @private\n */\n concat(index, expectedType, bindings) {\n const path = typeof index === 'number' ? this.path.concat(index) : this.path;\n const scope = bindings ? this.scope.concat(bindings) : this.scope;\n return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors);\n }\n /**\n * Push a parsing (or type checking) error into the `this.errors`\n * @param error The message\n * @param keys Optionally specify the source of the error at a child\n * of the current expression at `this.key`.\n * @private\n */\n error(error, ...keys) {\n const key = `${this.key}${keys.map(k => `[${k}]`).join('')}`;\n this.errors.push(new ExpressionParsingError(key, error));\n }\n /**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message and also pushes it to `this.errors`.\n * @param expected The expected type\n * @param t The actual type\n * @returns null if `t` is a subtype of `expected`; otherwise returns an error message\n */\n checkSubtype(expected, t) {\n const error = checkSubtype(expected, t);\n if (error)\n this.error(error);\n return error;\n }\n}\n\nclass Let {\n constructor(bindings, result) {\n this.type = result.type;\n this.bindings = [].concat(bindings);\n this.result = result;\n }\n evaluate(ctx) {\n return this.result.evaluate(ctx);\n }\n eachChild(fn) {\n for (const binding of this.bindings) {\n fn(binding[1]);\n }\n fn(this.result);\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);\n const bindings = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const name = args[i];\n if (typeof name !== 'string') {\n return context.error(`Expected string, but found ${typeof name} instead.`, i);\n }\n if (/[^a-zA-Z0-9_]/.test(name)) {\n return context.error('Variable names must contain only alphanumeric characters or \\'_\\'.', i);\n }\n const value = context.parse(args[i + 1], i + 1);\n if (!value)\n return null;\n bindings.push([name, value]);\n }\n const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);\n if (!result)\n return null;\n return new Let(bindings, result);\n }\n outputDefined() {\n return this.result.outputDefined();\n }\n}\n\nclass Var {\n constructor(name, boundExpression) {\n this.type = boundExpression.type;\n this.name = name;\n this.boundExpression = boundExpression;\n }\n static parse(args, context) {\n if (args.length !== 2 || typeof args[1] !== 'string')\n return context.error('\\'var\\' expression requires exactly one string literal argument.');\n const name = args[1];\n if (!context.scope.has(name)) {\n return context.error(`Unknown variable \"${name}\". Make sure \"${name}\" has been bound in an enclosing \"let\" expression before using it.`, 1);\n }\n return new Var(name, context.scope.get(name));\n }\n evaluate(ctx) {\n return this.boundExpression.evaluate(ctx);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nclass At {\n constructor(type, index, input) {\n this.type = type;\n this.index = index;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n const index = context.parse(args[1], 1, NumberType);\n const input = context.parse(args[2], 2, array(context.expectedType || ValueType));\n if (!index || !input)\n return null;\n const t = input.type;\n return new At(t.itemType, index, input);\n }\n evaluate(ctx) {\n const index = this.index.evaluate(ctx);\n const array = this.input.evaluate(ctx);\n if (index < 0) {\n throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);\n }\n if (index >= array.length) {\n throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);\n }\n if (index !== Math.floor(index)) {\n throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);\n }\n return array[index];\n }\n eachChild(fn) {\n fn(this.index);\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nclass In {\n constructor(needle, haystack) {\n this.type = BooleanType;\n this.needle = needle;\n this.haystack = haystack;\n }\n static parse(args, context) {\n if (args.length !== 3) {\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(needle.type)} instead`);\n }\n return new In(needle, haystack);\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!haystack)\n return false;\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${typeToString(typeOf(haystack))} instead.`);\n }\n return haystack.indexOf(needle) >= 0;\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n }\n outputDefined() {\n return true;\n }\n}\n\nclass IndexOf {\n constructor(needle, haystack, fromIndex) {\n this.type = NumberType;\n this.needle = needle;\n this.haystack = haystack;\n this.fromIndex = fromIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(needle.type)} instead`);\n }\n if (args.length === 4) {\n const fromIndex = context.parse(args[3], 3, NumberType);\n if (!fromIndex)\n return null;\n return new IndexOf(needle, haystack, fromIndex);\n }\n else {\n return new IndexOf(needle, haystack);\n }\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(typeOf(needle))} instead.`);\n }\n let fromIndex;\n if (this.fromIndex) {\n fromIndex = this.fromIndex.evaluate(ctx);\n }\n if (isValidNativeType(haystack, ['string'])) {\n const rawIndex = haystack.indexOf(needle, fromIndex);\n if (rawIndex === -1) {\n return -1;\n }\n else {\n // The index may be affected by surrogate pairs, so get the length of the preceding substring.\n return [...haystack.slice(0, rawIndex)].length;\n }\n }\n else if (isValidNativeType(haystack, ['array'])) {\n return haystack.indexOf(needle, fromIndex);\n }\n else {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${typeToString(typeOf(haystack))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n if (this.fromIndex) {\n fn(this.fromIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass Match {\n constructor(inputType, outputType, input, cases, outputs, otherwise) {\n this.inputType = inputType;\n this.type = outputType;\n this.input = input;\n this.cases = cases;\n this.outputs = outputs;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 5)\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 1)\n return context.error('Expected an even number of arguments.');\n let inputType;\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const cases = {};\n const outputs = [];\n for (let i = 2; i < args.length - 1; i += 2) {\n let labels = args[i];\n const value = args[i + 1];\n if (!Array.isArray(labels)) {\n labels = [labels];\n }\n const labelContext = context.concat(i);\n if (labels.length === 0) {\n return labelContext.error('Expected at least one branch label.');\n }\n for (const label of labels) {\n if (typeof label !== 'number' && typeof label !== 'string') {\n return labelContext.error('Branch labels must be numbers or strings.');\n }\n else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {\n return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);\n }\n else if (typeof label === 'number' && Math.floor(label) !== label) {\n return labelContext.error('Numeric branch labels must be integer values.');\n }\n else if (!inputType) {\n inputType = typeOf(label);\n }\n else if (labelContext.checkSubtype(inputType, typeOf(label))) {\n return null;\n }\n if (typeof cases[String(label)] !== 'undefined') {\n return labelContext.error('Branch labels must be unique.');\n }\n cases[String(label)] = outputs.length;\n }\n const result = context.parse(value, i, outputType);\n if (!result)\n return null;\n outputType = outputType || result.type;\n outputs.push(result);\n }\n const input = context.parse(args[1], 1, ValueType);\n if (!input)\n return null;\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {\n return null;\n }\n return new Match(inputType, outputType, input, cases, outputs, otherwise);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;\n return output.evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n this.outputs.forEach(fn);\n fn(this.otherwise);\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Case {\n constructor(type, branches, otherwise) {\n this.type = type;\n this.branches = branches;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 0)\n return context.error('Expected an odd number of arguments.');\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const branches = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const test = context.parse(args[i], i, BooleanType);\n if (!test)\n return null;\n const result = context.parse(args[i + 1], i + 1, outputType);\n if (!result)\n return null;\n branches.push([test, result]);\n outputType = outputType || result.type;\n }\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (!outputType)\n throw new Error('Can\\'t infer output type');\n return new Case(outputType, branches, otherwise);\n }\n evaluate(ctx) {\n for (const [test, expression] of this.branches) {\n if (test.evaluate(ctx)) {\n return expression.evaluate(ctx);\n }\n }\n return this.otherwise.evaluate(ctx);\n }\n eachChild(fn) {\n for (const [test, expression] of this.branches) {\n fn(test);\n fn(expression);\n }\n fn(this.otherwise);\n }\n outputDefined() {\n return this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Slice {\n constructor(type, input, beginIndex, endIndex) {\n this.type = type;\n this.input = input;\n this.beginIndex = beginIndex;\n this.endIndex = endIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);\n }\n const input = context.parse(args[1], 1, ValueType);\n const beginIndex = context.parse(args[2], 2, NumberType);\n if (!input || !beginIndex)\n return null;\n if (!isValidType(input.type, [array(ValueType), StringType, ValueType])) {\n return context.error(`Expected first argument to be of type array or string, but found ${typeToString(input.type)} instead`);\n }\n if (args.length === 4) {\n const endIndex = context.parse(args[3], 3, NumberType);\n if (!endIndex)\n return null;\n return new Slice(input.type, input, beginIndex, endIndex);\n }\n else {\n return new Slice(input.type, input, beginIndex);\n }\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const beginIndex = this.beginIndex.evaluate(ctx);\n let endIndex;\n if (this.endIndex) {\n endIndex = this.endIndex.evaluate(ctx);\n }\n if (isValidNativeType(input, ['string'])) {\n // Indices may be affected by surrogate pairs.\n return [...input].slice(beginIndex, endIndex).join('');\n }\n else if (isValidNativeType(input, ['array'])) {\n return input.slice(beginIndex, endIndex);\n }\n else {\n throw new RuntimeError(`Expected first argument to be of type array or string, but found ${typeToString(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n fn(this.beginIndex);\n if (this.endIndex) {\n fn(this.endIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\n/**\n * Returns the index of the last stop <= input, or 0 if it doesn't exist.\n * @private\n */\nfunction findStopLessThanOrEqualTo(stops, input) {\n const lastIndex = stops.length - 1;\n let lowerIndex = 0;\n let upperIndex = lastIndex;\n let currentIndex = 0;\n let currentValue, nextValue;\n while (lowerIndex <= upperIndex) {\n currentIndex = Math.floor((lowerIndex + upperIndex) / 2);\n currentValue = stops[currentIndex];\n nextValue = stops[currentIndex + 1];\n if (currentValue <= input) {\n if (currentIndex === lastIndex || input < nextValue) { // Search complete\n return currentIndex;\n }\n lowerIndex = currentIndex + 1;\n }\n else if (currentValue > input) {\n upperIndex = currentIndex - 1;\n }\n else {\n throw new RuntimeError('Input is not a number.');\n }\n }\n return 0;\n}\n\nclass Step {\n constructor(type, input, stops) {\n this.type = type;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static parse(args, context) {\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n const input = context.parse(args[1], 1, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 1; i < args.length; i += 2) {\n const label = i === 1 ? -Infinity : args[i];\n const value = args[i + 1];\n const labelKey = i;\n const valueKey = i + 1;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"step\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n return new Step(outputType, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n return outputs[index].evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nvar unitbezier;\nvar hasRequiredUnitbezier;\n\nfunction requireUnitbezier () {\n\tif (hasRequiredUnitbezier) return unitbezier;\n\thasRequiredUnitbezier = 1;\n\n\tunitbezier = UnitBezier;\n\n\tfunction UnitBezier(p1x, p1y, p2x, p2y) {\n\t // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n\t this.cx = 3.0 * p1x;\n\t this.bx = 3.0 * (p2x - p1x) - this.cx;\n\t this.ax = 1.0 - this.cx - this.bx;\n\n\t this.cy = 3.0 * p1y;\n\t this.by = 3.0 * (p2y - p1y) - this.cy;\n\t this.ay = 1.0 - this.cy - this.by;\n\n\t this.p1x = p1x;\n\t this.p1y = p1y;\n\t this.p2x = p2x;\n\t this.p2y = p2y;\n\t}\n\n\tUnitBezier.prototype = {\n\t sampleCurveX: function (t) {\n\t // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n\t return ((this.ax * t + this.bx) * t + this.cx) * t;\n\t },\n\n\t sampleCurveY: function (t) {\n\t return ((this.ay * t + this.by) * t + this.cy) * t;\n\t },\n\n\t sampleCurveDerivativeX: function (t) {\n\t return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n\t },\n\n\t solveCurveX: function (x, epsilon) {\n\t if (epsilon === undefined) epsilon = 1e-6;\n\n\t if (x < 0.0) return 0.0;\n\t if (x > 1.0) return 1.0;\n\n\t var t = x;\n\n\t // First try a few iterations of Newton's method - normally very fast.\n\t for (var i = 0; i < 8; i++) {\n\t var x2 = this.sampleCurveX(t) - x;\n\t if (Math.abs(x2) < epsilon) return t;\n\n\t var d2 = this.sampleCurveDerivativeX(t);\n\t if (Math.abs(d2) < 1e-6) break;\n\n\t t = t - x2 / d2;\n\t }\n\n\t // Fall back to the bisection method for reliability.\n\t var t0 = 0.0;\n\t var t1 = 1.0;\n\t t = x;\n\n\t for (i = 0; i < 20; i++) {\n\t x2 = this.sampleCurveX(t);\n\t if (Math.abs(x2 - x) < epsilon) break;\n\n\t if (x > x2) {\n\t t0 = t;\n\t } else {\n\t t1 = t;\n\t }\n\n\t t = (t1 - t0) * 0.5 + t0;\n\t }\n\n\t return t;\n\t },\n\n\t solve: function (x, epsilon) {\n\t return this.sampleCurveY(this.solveCurveX(x, epsilon));\n\t }\n\t};\n\treturn unitbezier;\n}\n\nvar unitbezierExports = requireUnitbezier();\nvar UnitBezier = /*@__PURE__*/getDefaultExportFromCjs(unitbezierExports);\n\nclass Interpolate {\n constructor(type, operator, interpolation, input, stops) {\n this.type = type;\n this.operator = operator;\n this.interpolation = interpolation;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static interpolationFactor(interpolation, input, lower, upper) {\n let t = 0;\n if (interpolation.name === 'exponential') {\n t = exponentialInterpolation(input, interpolation.base, lower, upper);\n }\n else if (interpolation.name === 'linear') {\n t = exponentialInterpolation(input, 1, lower, upper);\n }\n else if (interpolation.name === 'cubic-bezier') {\n const c = interpolation.controlPoints;\n const ub = new UnitBezier(c[0], c[1], c[2], c[3]);\n t = ub.solve(exponentialInterpolation(input, 1, lower, upper));\n }\n return t;\n }\n static parse(args, context) {\n let [operator, interpolation, input, ...rest] = args;\n if (!Array.isArray(interpolation) || interpolation.length === 0) {\n return context.error('Expected an interpolation type expression.', 1);\n }\n if (interpolation[0] === 'linear') {\n interpolation = { name: 'linear' };\n }\n else if (interpolation[0] === 'exponential') {\n const base = interpolation[1];\n if (typeof base !== 'number')\n return context.error('Exponential interpolation requires a numeric base.', 1, 1);\n interpolation = {\n name: 'exponential',\n base\n };\n }\n else if (interpolation[0] === 'cubic-bezier') {\n const controlPoints = interpolation.slice(1);\n if (controlPoints.length !== 4 ||\n controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)) {\n return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);\n }\n interpolation = {\n name: 'cubic-bezier',\n controlPoints: controlPoints\n };\n }\n else {\n return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);\n }\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n input = context.parse(input, 2, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {\n outputType = ColorType;\n }\n else if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 0; i < rest.length; i += 2) {\n const label = rest[i];\n const value = rest[i + 1];\n const labelKey = i + 3;\n const valueKey = i + 4;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"interpolate\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n if (!verifyType(outputType, NumberType) &&\n !verifyType(outputType, ProjectionDefinitionType) &&\n !verifyType(outputType, ColorType) &&\n !verifyType(outputType, PaddingType) &&\n !verifyType(outputType, VariableAnchorOffsetCollectionType) &&\n !verifyType(outputType, array(NumberType))) {\n return context.error(`Type ${typeToString(outputType)} is not interpolatable.`);\n }\n return new Interpolate(outputType, operator, interpolation, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n const lower = labels[index];\n const upper = labels[index + 1];\n const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);\n const outputLower = outputs[index].evaluate(ctx);\n const outputUpper = outputs[index + 1].evaluate(ctx);\n switch (this.operator) {\n case 'interpolate':\n switch (this.type.kind) {\n case 'number':\n return interpolateNumber(outputLower, outputUpper, t);\n case 'color':\n return Color.interpolate(outputLower, outputUpper, t);\n case 'padding':\n return Padding.interpolate(outputLower, outputUpper, t);\n case 'variableAnchorOffsetCollection':\n return VariableAnchorOffsetCollection.interpolate(outputLower, outputUpper, t);\n case 'array':\n return interpolateArray(outputLower, outputUpper, t);\n case 'projectionDefinition':\n return ProjectionDefinition.interpolate(outputLower, outputUpper, t);\n }\n case 'interpolate-hcl':\n return Color.interpolate(outputLower, outputUpper, t, 'hcl');\n case 'interpolate-lab':\n return Color.interpolate(outputLower, outputUpper, t, 'lab');\n }\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every(out => out.outputDefined());\n }\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n*/\nfunction exponentialInterpolation(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\nconst interpolateFactory = {\n color: Color.interpolate,\n number: interpolateNumber,\n padding: Padding.interpolate,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollection.interpolate,\n array: interpolateArray\n};\n\nclass Coalesce {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n let outputType = null;\n const expectedType = context.expectedType;\n if (expectedType && expectedType.kind !== 'value') {\n outputType = expectedType;\n }\n const parsedArgs = [];\n for (const arg of args.slice(1)) {\n const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' });\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n parsedArgs.push(parsed);\n }\n if (!outputType)\n throw new Error('No output type');\n // Above, we parse arguments without inferred type annotation so that\n // they don't produce a runtime error for `null` input, which would\n // preempt the desired null-coalescing behavior.\n // Thus, if any of our arguments would have needed an annotation, we\n // need to wrap the enclosing coalesce expression with it instead.\n const needsAnnotation = expectedType &&\n parsedArgs.some(arg => checkSubtype(expectedType, arg.type));\n return needsAnnotation ?\n new Coalesce(ValueType, parsedArgs) :\n new Coalesce(outputType, parsedArgs);\n }\n evaluate(ctx) {\n let result = null;\n let argCount = 0;\n let requestedImageName;\n for (const arg of this.args) {\n argCount++;\n result = arg.evaluate(ctx);\n // we need to keep track of the first requested image in a coalesce statement\n // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire\n if (result && result instanceof ResolvedImage && !result.available) {\n if (!requestedImageName) {\n requestedImageName = result.name;\n }\n result = null;\n if (argCount === this.args.length) {\n result = requestedImageName;\n }\n }\n if (result !== null)\n break;\n }\n return result;\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every(arg => arg.outputDefined());\n }\n}\n\nfunction isComparableType(op, type) {\n if (op === '==' || op === '!=') {\n // equality operator\n return type.kind === 'boolean' ||\n type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'null' ||\n type.kind === 'value';\n }\n else {\n // ordering operator\n return type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'value';\n }\n}\nfunction eq(ctx, a, b) { return a === b; }\nfunction neq(ctx, a, b) { return a !== b; }\nfunction lt(ctx, a, b) { return a < b; }\nfunction gt(ctx, a, b) { return a > b; }\nfunction lteq(ctx, a, b) { return a <= b; }\nfunction gteq(ctx, a, b) { return a >= b; }\nfunction eqCollate(ctx, a, b, c) { return c.compare(a, b) === 0; }\nfunction neqCollate(ctx, a, b, c) { return !eqCollate(ctx, a, b, c); }\nfunction ltCollate(ctx, a, b, c) { return c.compare(a, b) < 0; }\nfunction gtCollate(ctx, a, b, c) { return c.compare(a, b) > 0; }\nfunction lteqCollate(ctx, a, b, c) { return c.compare(a, b) <= 0; }\nfunction gteqCollate(ctx, a, b, c) { return c.compare(a, b) >= 0; }\n/**\n * Special form for comparison operators, implementing the signatures:\n * - (T, T, ?Collator) => boolean\n * - (T, value, ?Collator) => boolean\n * - (value, T, ?Collator) => boolean\n *\n * For inequalities, T must be either value, string, or number. For ==/!=, it\n * can also be boolean or null.\n *\n * Equality semantics are equivalent to Javascript's strict equality (===/!==)\n * -- i.e., when the arguments' types don't match, == evaluates to false, != to\n * true.\n *\n * When types don't match in an ordering comparison, a runtime error is thrown.\n *\n * @private\n */\nfunction makeComparison(op, compareBasic, compareWithCollator) {\n const isOrderComparison = op !== '==' && op !== '!=';\n return class Comparison {\n constructor(lhs, rhs, collator) {\n this.type = BooleanType;\n this.lhs = lhs;\n this.rhs = rhs;\n this.collator = collator;\n this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';\n }\n static parse(args, context) {\n if (args.length !== 3 && args.length !== 4)\n return context.error('Expected two or three arguments.');\n const op = args[0];\n let lhs = context.parse(args[1], 1, ValueType);\n if (!lhs)\n return null;\n if (!isComparableType(op, lhs.type)) {\n return context.concat(1).error(`\"${op}\" comparisons are not supported for type '${typeToString(lhs.type)}'.`);\n }\n let rhs = context.parse(args[2], 2, ValueType);\n if (!rhs)\n return null;\n if (!isComparableType(op, rhs.type)) {\n return context.concat(2).error(`\"${op}\" comparisons are not supported for type '${typeToString(rhs.type)}'.`);\n }\n if (lhs.type.kind !== rhs.type.kind &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error(`Cannot compare types '${typeToString(lhs.type)}' and '${typeToString(rhs.type)}'.`);\n }\n if (isOrderComparison) {\n // typing rules specific to less/greater than operators\n if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {\n // (value, T)\n lhs = new Assertion(rhs.type, [lhs]);\n }\n else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {\n // (T, value)\n rhs = new Assertion(lhs.type, [rhs]);\n }\n }\n let collator = null;\n if (args.length === 4) {\n if (lhs.type.kind !== 'string' &&\n rhs.type.kind !== 'string' &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error('Cannot use collator to compare non-string types.');\n }\n collator = context.parse(args[3], 3, CollatorType);\n if (!collator)\n return null;\n }\n return new Comparison(lhs, rhs, collator);\n }\n evaluate(ctx) {\n const lhs = this.lhs.evaluate(ctx);\n const rhs = this.rhs.evaluate(ctx);\n if (isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n // check that type is string or number, and equal\n if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {\n throw new RuntimeError(`Expected arguments for \"${op}\" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`);\n }\n }\n if (this.collator && !isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n if (lt.kind !== 'string' || rt.kind !== 'string') {\n return compareBasic(ctx, lhs, rhs);\n }\n }\n return this.collator ?\n compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx)) :\n compareBasic(ctx, lhs, rhs);\n }\n eachChild(fn) {\n fn(this.lhs);\n fn(this.rhs);\n if (this.collator) {\n fn(this.collator);\n }\n }\n outputDefined() {\n return true;\n }\n };\n}\nconst Equals = makeComparison('==', eq, eqCollate);\nconst NotEquals = makeComparison('!=', neq, neqCollate);\nconst LessThan = makeComparison('<', lt, ltCollate);\nconst GreaterThan = makeComparison('>', gt, gtCollate);\nconst LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);\nconst GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);\n\nclass CollatorExpression {\n constructor(caseSensitive, diacriticSensitive, locale) {\n this.type = CollatorType;\n this.locale = locale;\n this.caseSensitive = caseSensitive;\n this.diacriticSensitive = diacriticSensitive;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error('Expected one argument.');\n const options = args[1];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('Collator options argument must be an object.');\n const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);\n if (!caseSensitive)\n return null;\n const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);\n if (!diacriticSensitive)\n return null;\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n return new CollatorExpression(caseSensitive, diacriticSensitive, locale);\n }\n evaluate(ctx) {\n return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);\n }\n eachChild(fn) {\n fn(this.caseSensitive);\n fn(this.diacriticSensitive);\n if (this.locale) {\n fn(this.locale);\n }\n }\n outputDefined() {\n // Technically the set of possible outputs is the combinatoric set of Collators produced\n // by all possible outputs of locale/caseSensitive/diacriticSensitive\n // But for the primary use of Collators in comparison operators, we ignore the Collator's\n // possible outputs anyway, so we can get away with leaving this false for now.\n return false;\n }\n}\n\nclass NumberFormat {\n constructor(number, locale, currency, minFractionDigits, maxFractionDigits) {\n this.type = StringType;\n this.number = number;\n this.locale = locale;\n this.currency = currency;\n this.minFractionDigits = minFractionDigits;\n this.maxFractionDigits = maxFractionDigits;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error('Expected two arguments.');\n const number = context.parse(args[1], 1, NumberType);\n if (!number)\n return null;\n const options = args[2];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('NumberFormat options argument must be an object.');\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n let currency = null;\n if (options['currency']) {\n currency = context.parse(options['currency'], 1, StringType);\n if (!currency)\n return null;\n }\n let minFractionDigits = null;\n if (options['min-fraction-digits']) {\n minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);\n if (!minFractionDigits)\n return null;\n }\n let maxFractionDigits = null;\n if (options['max-fraction-digits']) {\n maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);\n if (!maxFractionDigits)\n return null;\n }\n return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);\n }\n evaluate(ctx) {\n return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {\n style: this.currency ? 'currency' : 'decimal',\n currency: this.currency ? this.currency.evaluate(ctx) : undefined,\n minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,\n maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined,\n }).format(this.number.evaluate(ctx));\n }\n eachChild(fn) {\n fn(this.number);\n if (this.locale) {\n fn(this.locale);\n }\n if (this.currency) {\n fn(this.currency);\n }\n if (this.minFractionDigits) {\n fn(this.minFractionDigits);\n }\n if (this.maxFractionDigits) {\n fn(this.maxFractionDigits);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass FormatExpression {\n constructor(sections) {\n this.type = FormattedType;\n this.sections = sections;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n const firstArg = args[1];\n if (!Array.isArray(firstArg) && typeof firstArg === 'object') {\n return context.error('First argument must be an image or text section.');\n }\n const sections = [];\n let nextTokenMayBeObject = false;\n for (let i = 1; i <= args.length - 1; ++i) {\n const arg = args[i];\n if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) {\n nextTokenMayBeObject = false;\n let scale = null;\n if (arg['font-scale']) {\n scale = context.parse(arg['font-scale'], 1, NumberType);\n if (!scale)\n return null;\n }\n let font = null;\n if (arg['text-font']) {\n font = context.parse(arg['text-font'], 1, array(StringType));\n if (!font)\n return null;\n }\n let textColor = null;\n if (arg['text-color']) {\n textColor = context.parse(arg['text-color'], 1, ColorType);\n if (!textColor)\n return null;\n }\n let verticalAlign = null;\n if (arg['vertical-align']) {\n if (typeof arg['vertical-align'] === 'string' && !VERTICAL_ALIGN_OPTIONS.includes(arg['vertical-align'])) {\n return context.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${arg['vertical-align']}' instead.`);\n }\n verticalAlign = context.parse(arg['vertical-align'], 1, StringType);\n if (!verticalAlign)\n return null;\n }\n const lastExpression = sections[sections.length - 1];\n lastExpression.scale = scale;\n lastExpression.font = font;\n lastExpression.textColor = textColor;\n lastExpression.verticalAlign = verticalAlign;\n }\n else {\n const content = context.parse(args[i], 1, ValueType);\n if (!content)\n return null;\n const kind = content.type.kind;\n if (kind !== 'string' && kind !== 'value' && kind !== 'null' && kind !== 'resolvedImage')\n return context.error('Formatted text type must be \\'string\\', \\'value\\', \\'image\\' or \\'null\\'.');\n nextTokenMayBeObject = true;\n sections.push({ content, scale: null, font: null, textColor: null, verticalAlign: null });\n }\n }\n return new FormatExpression(sections);\n }\n evaluate(ctx) {\n const evaluateSection = section => {\n const evaluatedContent = section.content.evaluate(ctx);\n if (typeOf(evaluatedContent) === ResolvedImageType) {\n return new FormattedSection('', evaluatedContent, null, null, null, section.verticalAlign ? section.verticalAlign.evaluate(ctx) : null);\n }\n return new FormattedSection(valueToString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null, section.verticalAlign ? section.verticalAlign.evaluate(ctx) : null);\n };\n return new Formatted(this.sections.map(evaluateSection));\n }\n eachChild(fn) {\n for (const section of this.sections) {\n fn(section.content);\n if (section.scale) {\n fn(section.scale);\n }\n if (section.font) {\n fn(section.font);\n }\n if (section.textColor) {\n fn(section.textColor);\n }\n if (section.verticalAlign) {\n fn(section.verticalAlign);\n }\n }\n }\n outputDefined() {\n // Technically the combinatoric set of all children\n // Usually, this.text will be undefined anyway\n return false;\n }\n}\n\nclass ImageExpression {\n constructor(input) {\n this.type = ResolvedImageType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error('Expected two arguments.');\n }\n const name = context.parse(args[1], 1, StringType);\n if (!name)\n return context.error('No image name provided.');\n return new ImageExpression(name);\n }\n evaluate(ctx) {\n const evaluatedImageName = this.input.evaluate(ctx);\n const value = ResolvedImage.fromString(evaluatedImageName);\n if (value && ctx.availableImages)\n value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;\n return value;\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n // The output of image is determined by the list of available images in the evaluation context\n return false;\n }\n}\n\nclass Length {\n constructor(input) {\n this.type = NumberType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n const input = context.parse(args[1], 1);\n if (!input)\n return null;\n if (input.type.kind !== 'array' && input.type.kind !== 'string' && input.type.kind !== 'value')\n return context.error(`Expected argument of type string or array, but found ${typeToString(input.type)} instead.`);\n return new Length(input);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n if (typeof input === 'string') {\n // The length may be affected by surrogate pairs.\n return [...input].length;\n }\n else if (Array.isArray(input)) {\n return input.length;\n }\n else {\n throw new RuntimeError(`Expected value to be of type string or array, but found ${typeToString(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nconst EXTENT = 8192;\nfunction getTileCoordinates(p, canonical) {\n const x = mercatorXfromLng(p[0]);\n const y = mercatorYfromLat(p[1]);\n const tilesAtZoom = Math.pow(2, canonical.z);\n return [Math.round(x * tilesAtZoom * EXTENT), Math.round(y * tilesAtZoom * EXTENT)];\n}\nfunction getLngLatFromTileCoord(coord, canonical) {\n const tilesAtZoom = Math.pow(2, canonical.z);\n const x = (coord[0] / EXTENT + canonical.x) / tilesAtZoom;\n const y = (coord[1] / EXTENT + canonical.y) / tilesAtZoom;\n return [lngFromMercatorXfromLng(x), latFromMercatorY(y)];\n}\nfunction mercatorXfromLng(lng) {\n return (180 + lng) / 360;\n}\nfunction lngFromMercatorXfromLng(mercatorX) {\n return mercatorX * 360 - 180;\n}\nfunction mercatorYfromLat(lat) {\n return (180 - (180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360)))) / 360;\n}\nfunction latFromMercatorY(mercatorY) {\n return 360 / Math.PI * Math.atan(Math.exp((180 - mercatorY * 360) * Math.PI / 180)) - 90;\n}\nfunction updateBBox(bbox, coord) {\n bbox[0] = Math.min(bbox[0], coord[0]);\n bbox[1] = Math.min(bbox[1], coord[1]);\n bbox[2] = Math.max(bbox[2], coord[0]);\n bbox[3] = Math.max(bbox[3], coord[1]);\n}\nfunction boxWithinBox(bbox1, bbox2) {\n if (bbox1[0] <= bbox2[0])\n return false;\n if (bbox1[2] >= bbox2[2])\n return false;\n if (bbox1[1] <= bbox2[1])\n return false;\n if (bbox1[3] >= bbox2[3])\n return false;\n return true;\n}\nfunction rayIntersect(p, p1, p2) {\n return ((p1[1] > p[1]) !== (p2[1] > p[1])) && (p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0]);\n}\nfunction pointOnBoundary(p, p1, p2) {\n const x1 = p[0] - p1[0];\n const y1 = p[1] - p1[1];\n const x2 = p[0] - p2[0];\n const y2 = p[1] - p2[1];\n return (x1 * y2 - x2 * y1 === 0) && (x1 * x2 <= 0) && (y1 * y2 <= 0);\n}\n// a, b are end points for line segment1, c and d are end points for line segment2\nfunction segmentIntersectSegment(a, b, c, d) {\n // check if two segments are parallel or not\n // precondition is end point a, b is inside polygon, if line a->b is\n // parallel to polygon edge c->d, then a->b won't intersect with c->d\n const vectorP = [b[0] - a[0], b[1] - a[1]];\n const vectorQ = [d[0] - c[0], d[1] - c[1]];\n if (perp(vectorQ, vectorP) === 0)\n return false;\n // If lines are intersecting with each other, the relative location should be:\n // a and b lie in different sides of segment c->d\n // c and d lie in different sides of segment a->b\n if (twoSided(a, b, c, d) && twoSided(c, d, a, b))\n return true;\n return false;\n}\nfunction lineIntersectPolygon(p1, p2, polygon) {\n for (const ring of polygon) {\n // loop through every edge of the ring\n for (let j = 0; j < ring.length - 1; ++j) {\n if (segmentIntersectSegment(p1, p2, ring[j], ring[j + 1])) {\n return true;\n }\n }\n }\n return false;\n}\n// ray casting algorithm for detecting if point is in polygon\nfunction pointWithinPolygon(point, rings, trueIfOnBoundary = false) {\n let inside = false;\n for (const ring of rings) {\n for (let j = 0; j < ring.length - 1; j++) {\n if (pointOnBoundary(point, ring[j], ring[j + 1]))\n return trueIfOnBoundary;\n if (rayIntersect(point, ring[j], ring[j + 1]))\n inside = !inside;\n }\n }\n return inside;\n}\nfunction pointWithinPolygons(point, polygons) {\n for (const polygon of polygons) {\n if (pointWithinPolygon(point, polygon))\n return true;\n }\n return false;\n}\nfunction lineStringWithinPolygon(line, polygon) {\n // First, check if geometry points of line segments are all inside polygon\n for (const point of line) {\n if (!pointWithinPolygon(point, polygon)) {\n return false;\n }\n }\n // Second, check if there is line segment intersecting polygon edge\n for (let i = 0; i < line.length - 1; ++i) {\n if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {\n return false;\n }\n }\n return true;\n}\nfunction lineStringWithinPolygons(line, polygons) {\n for (const polygon of polygons) {\n if (lineStringWithinPolygon(line, polygon))\n return true;\n }\n return false;\n}\nfunction perp(v1, v2) {\n return (v1[0] * v2[1] - v1[1] * v2[0]);\n}\n// check if p1 and p2 are in different sides of line segment q1->q2\nfunction twoSided(p1, p2, q1, q2) {\n // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)\n const x1 = p1[0] - q1[0];\n const y1 = p1[1] - q1[1];\n const x2 = p2[0] - q1[0];\n const y2 = p2[1] - q1[1];\n const x3 = q2[0] - q1[0];\n const y3 = q2[1] - q1[1];\n const det1 = (x1 * y3 - x3 * y1);\n const det2 = (x2 * y3 - x3 * y2);\n if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0))\n return true;\n return false;\n}\n\nfunction getTilePolygon(coordinates, bbox, canonical) {\n const polygon = [];\n for (let i = 0; i < coordinates.length; i++) {\n const ring = [];\n for (let j = 0; j < coordinates[i].length; j++) {\n const coord = getTileCoordinates(coordinates[i][j], canonical);\n updateBBox(bbox, coord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n return polygon;\n}\nfunction getTilePolygons(coordinates, bbox, canonical) {\n const polygons = [];\n for (let i = 0; i < coordinates.length; i++) {\n const polygon = getTilePolygon(coordinates[i], bbox, canonical);\n polygons.push(polygon);\n }\n return polygons;\n}\nfunction updatePoint(p, bbox, polyBBox, worldSize) {\n if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {\n const halfWorldSize = worldSize * 0.5;\n let shift = (p[0] - polyBBox[0] > halfWorldSize) ? -worldSize : (polyBBox[0] - p[0] > halfWorldSize) ? worldSize : 0;\n if (shift === 0) {\n shift = (p[0] - polyBBox[2] > halfWorldSize) ? -worldSize : (polyBBox[2] - p[0] > halfWorldSize) ? worldSize : 0;\n }\n p[0] += shift;\n }\n updateBBox(bbox, p);\n}\nfunction resetBBox(bbox) {\n bbox[0] = bbox[1] = Infinity;\n bbox[2] = bbox[3] = -Infinity;\n}\nfunction getTilePoints(geometry, pointBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tilePoints = [];\n for (const points of geometry) {\n for (const point of points) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updatePoint(p, pointBBox, polyBBox, worldSize);\n tilePoints.push(p);\n }\n }\n return tilePoints;\n}\nfunction getTileLines(geometry, lineBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tileLines = [];\n for (const line of geometry) {\n const tileLine = [];\n for (const point of line) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updateBBox(lineBBox, p);\n tileLine.push(p);\n }\n tileLines.push(tileLine);\n }\n if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {\n resetBBox(lineBBox);\n for (const line of tileLines) {\n for (const p of line) {\n updatePoint(p, lineBBox, polyBBox, worldSize);\n }\n }\n }\n return tileLines;\n}\nfunction pointsWithinPolygons(ctx, polygonGeometry) {\n const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygon(point, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygons(point, tilePolygons))\n return false;\n }\n }\n return true;\n}\nfunction linesWithinPolygons(ctx, polygonGeometry) {\n const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygon(line, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygons(line, tilePolygons))\n return false;\n }\n }\n return true;\n}\nclass Within {\n constructor(geojson, geometries) {\n this.type = BooleanType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n const polygonsCoords = [];\n for (const polygon of geojson.features) {\n const { type, coordinates } = polygon.geometry;\n if (type === 'Polygon') {\n polygonsCoords.push(coordinates);\n }\n if (type === 'MultiPolygon') {\n polygonsCoords.push(...coordinates);\n }\n }\n if (polygonsCoords.length) {\n const multipolygonWrapper = {\n type: 'MultiPolygon',\n coordinates: polygonsCoords\n };\n return new Within(geojson, multipolygonWrapper);\n }\n }\n else if (geojson.type === 'Feature') {\n const type = geojson.geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.geometry);\n }\n }\n else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {\n return new Within(geojson, geojson);\n }\n }\n return context.error('\\'within\\' expression requires valid geojson object that contains polygon geometry type.');\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointsWithinPolygons(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return linesWithinPolygons(ctx, this.geometries);\n }\n }\n return false;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass TinyQueue {\n constructor(data = [], compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0)) {\n this.data = data;\n this.length = this.data.length;\n this.compare = compare;\n\n if (this.length > 0) {\n for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);\n }\n }\n\n push(item) {\n this.data.push(item);\n this._up(this.length++);\n }\n\n pop() {\n if (this.length === 0) return undefined;\n\n const top = this.data[0];\n const bottom = this.data.pop();\n\n if (--this.length > 0) {\n this.data[0] = bottom;\n this._down(0);\n }\n\n return top;\n }\n\n peek() {\n return this.data[0];\n }\n\n _up(pos) {\n const {data, compare} = this;\n const item = data[pos];\n\n while (pos > 0) {\n const parent = (pos - 1) >> 1;\n const current = data[parent];\n if (compare(item, current) >= 0) break;\n data[pos] = current;\n pos = parent;\n }\n\n data[pos] = item;\n }\n\n _down(pos) {\n const {data, compare} = this;\n const halfLength = this.length >> 1;\n const item = data[pos];\n\n while (pos < halfLength) {\n let bestChild = (pos << 1) + 1; // initially it is the left child\n const right = bestChild + 1;\n\n if (right < this.length && compare(data[right], data[bestChild]) < 0) {\n bestChild = right;\n }\n if (compare(data[bestChild], item) >= 0) break;\n\n data[pos] = data[bestChild];\n pos = bestChild;\n }\n\n data[pos] = item;\n }\n}\n\n/**\n * Rearranges items so that all items in the [left, k] are the smallest.\n * The k-th element will have the (k - left + 1)-th smallest value in [left, right].\n *\n * @template T\n * @param {T[]} arr the array to partially sort (in place)\n * @param {number} k middle index for partial sorting (as defined above)\n * @param {number} [left=0] left index of the range to sort\n * @param {number} [right=arr.length-1] right index\n * @param {(a: T, b: T) => number} [compare = (a, b) => a - b] compare function\n */\nfunction quickselect(arr, k, left = 0, right = arr.length - 1, compare = defaultCompare) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselect(arr, k, newLeft, newRight, compare);\n }\n\n const t = arr[k];\n let i = left;\n /** @type {number} */\n let j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @template T\n * @param {T[]} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @template T\n * @param {T} a\n * @param {T} b\n * @returns {number}\n */\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * @param rings - the rings to classify\n * @param maxRings - the maximum number of rings to include in a polygon, use 0 to include all rings\n * @returns an array of polygons with internal rings as holes\n */\nfunction classifyRings(rings, maxRings) {\n const len = rings.length;\n if (len <= 1)\n return [rings];\n const polygons = [];\n let polygon;\n let ccw;\n for (const ring of rings) {\n const area = calculateSignedArea(ring);\n if (area === 0)\n continue;\n ring.area = Math.abs(area);\n if (ccw === undefined)\n ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon)\n polygons.push(polygon);\n polygon = [ring];\n }\n else {\n polygon.push(ring);\n }\n }\n if (polygon)\n polygons.push(polygon);\n // Earcut performance degrades with the # of rings in a polygon. For this\n // reason, we limit strip out all but the `maxRings` largest rings.\n if (maxRings > 1) {\n for (let j = 0; j < polygons.length; j++) {\n if (polygons[j].length <= maxRings)\n continue;\n quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);\n polygons[j] = polygons[j].slice(0, maxRings);\n }\n }\n return polygons;\n}\nfunction compareAreas(a, b) {\n return b.area - a.area;\n}\n/**\n * Returns the signed area for the polygon ring. Positive areas are exterior rings and\n * have a clockwise winding. Negative areas are interior rings and have a counter clockwise\n * ordering.\n *\n * @param ring - Exterior or interior ring\n * @returns Signed area\n */\nfunction calculateSignedArea(ring) {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\n// This is taken from https://github.com/mapbox/cheap-ruler/ in order to take only the relevant parts\n// Values that define WGS84 ellipsoid model of the Earth\nconst RE = 6378.137; // equatorial radius\nconst FE = 1 / 298.257223563; // flattening\nconst E2 = FE * (2 - FE);\nconst RAD = Math.PI / 180;\nclass CheapRuler {\n constructor(lat) {\n // Curvature formulas from https://en.wikipedia.org/wiki/Earth_radius#Meridional\n const m = RAD * RE * 1000;\n const coslat = Math.cos(lat * RAD);\n const w2 = 1 / (1 - E2 * (1 - coslat * coslat));\n const w = Math.sqrt(w2);\n // multipliers for converting longitude and latitude degrees into distance\n this.kx = m * w * coslat; // based on normal radius of curvature\n this.ky = m * w * w2 * (1 - E2); // based on meridional radius of curvature\n }\n /**\n * Given two points of the form [longitude, latitude], returns the distance.\n *\n * @param a - point [longitude, latitude]\n * @param b - point [longitude, latitude]\n * @returns distance\n * @example\n * const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);\n * //=distance\n */\n distance(a, b) {\n const dx = this.wrap(a[0] - b[0]) * this.kx;\n const dy = (a[1] - b[1]) * this.ky;\n return Math.sqrt(dx * dx + dy * dy);\n }\n /**\n * Returns an object of the form {point, index, t}, where point is closest point on the line\n * from the given point, index is the start index of the segment with the closest point,\n * and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.\n *\n * @param line - an array of points that form the line\n * @param p - point [longitude, latitude]\n * @returns the nearest point, its index in the array and the proportion along the line\n * @example\n * const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;\n * //=point\n */\n pointOnLine(line, p) {\n let minDist = Infinity;\n let minX, minY, minI, minT;\n for (let i = 0; i < line.length - 1; i++) {\n let x = line[i][0];\n let y = line[i][1];\n let dx = this.wrap(line[i + 1][0] - x) * this.kx;\n let dy = (line[i + 1][1] - y) * this.ky;\n let t = 0;\n if (dx !== 0 || dy !== 0) {\n t = (this.wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x = line[i + 1][0];\n y = line[i + 1][1];\n }\n else if (t > 0) {\n x += (dx / this.kx) * t;\n y += (dy / this.ky) * t;\n }\n }\n dx = this.wrap(p[0] - x) * this.kx;\n dy = (p[1] - y) * this.ky;\n const sqDist = dx * dx + dy * dy;\n if (sqDist < minDist) {\n minDist = sqDist;\n minX = x;\n minY = y;\n minI = i;\n minT = t;\n }\n }\n return {\n point: [minX, minY],\n index: minI,\n t: Math.max(0, Math.min(1, minT))\n };\n }\n wrap(deg) {\n while (deg < -180)\n deg += 360;\n while (deg > 180)\n deg -= 360;\n return deg;\n }\n}\n\nconst MinPointsSize = 100;\nconst MinLinePointsSize = 50;\nfunction compareDistPair(a, b) {\n return b[0] - a[0];\n}\nfunction getRangeSize(range) {\n return range[1] - range[0] + 1;\n}\nfunction isRangeSafe(range, threshold) {\n return range[1] >= range[0] && range[1] < threshold;\n}\nfunction splitRange(range, isLine) {\n if (range[0] > range[1]) {\n return [null, null];\n }\n const size = getRangeSize(range);\n if (isLine) {\n if (size === 2) {\n return [range, null];\n }\n const size1 = Math.floor(size / 2);\n return [[range[0], range[0] + size1],\n [range[0] + size1, range[1]]];\n }\n if (size === 1) {\n return [range, null];\n }\n const size1 = Math.floor(size / 2) - 1;\n return [[range[0], range[0] + size1],\n [range[0] + size1 + 1, range[1]]];\n}\nfunction getBBox(coords, range) {\n if (!isRangeSafe(range, coords.length)) {\n return [Infinity, Infinity, -Infinity, -Infinity];\n }\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (let i = range[0]; i <= range[1]; ++i) {\n updateBBox(bbox, coords[i]);\n }\n return bbox;\n}\nfunction getPolygonBBox(polygon) {\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (const ring of polygon) {\n for (const coord of ring) {\n updateBBox(bbox, coord);\n }\n }\n return bbox;\n}\nfunction isValidBBox(bbox) {\n return bbox[0] !== -Infinity && bbox[1] !== -Infinity && bbox[2] !== Infinity && bbox[3] !== Infinity;\n}\n// Calculate the distance between two bounding boxes.\n// Calculate the delta in x and y direction, and use two fake points {0.0, 0.0}\n// and {dx, dy} to calculate the distance. Distance will be 0.0 if bounding box are overlapping.\nfunction bboxToBBoxDistance(bbox1, bbox2, ruler) {\n if (!isValidBBox(bbox1) || !isValidBBox(bbox2)) {\n return NaN;\n }\n let dx = 0.0;\n let dy = 0.0;\n // bbox1 in left side\n if (bbox1[2] < bbox2[0]) {\n dx = bbox2[0] - bbox1[2];\n }\n // bbox1 in right side\n if (bbox1[0] > bbox2[2]) {\n dx = bbox1[0] - bbox2[2];\n }\n // bbox1 in above side\n if (bbox1[1] > bbox2[3]) {\n dy = bbox1[1] - bbox2[3];\n }\n // bbox1 in down side\n if (bbox1[3] < bbox2[1]) {\n dy = bbox2[1] - bbox1[3];\n }\n return ruler.distance([0.0, 0.0], [dx, dy]);\n}\nfunction pointToLineDistance(point, line, ruler) {\n const nearestPoint = ruler.pointOnLine(line, point);\n return ruler.distance(point, nearestPoint.point);\n}\nfunction segmentToSegmentDistance(p1, p2, q1, q2, ruler) {\n const dist1 = Math.min(pointToLineDistance(p1, [q1, q2], ruler), pointToLineDistance(p2, [q1, q2], ruler));\n const dist2 = Math.min(pointToLineDistance(q1, [p1, p2], ruler), pointToLineDistance(q2, [p1, p2], ruler));\n return Math.min(dist1, dist2);\n}\nfunction lineToLineDistance(line1, range1, line2, range2, ruler) {\n const rangeSafe = isRangeSafe(range1, line1.length) && isRangeSafe(range2, line2.length);\n if (!rangeSafe) {\n return Infinity;\n }\n let dist = Infinity;\n for (let i = range1[0]; i < range1[1]; ++i) {\n const p1 = line1[i];\n const p2 = line1[i + 1];\n for (let j = range2[0]; j < range2[1]; ++j) {\n const q1 = line2[j];\n const q2 = line2[j + 1];\n if (segmentIntersectSegment(p1, p2, q1, q2)) {\n return 0.0;\n }\n dist = Math.min(dist, segmentToSegmentDistance(p1, p2, q1, q2, ruler));\n }\n }\n return dist;\n}\nfunction pointsToPointsDistance(points1, range1, points2, range2, ruler) {\n const rangeSafe = isRangeSafe(range1, points1.length) && isRangeSafe(range2, points2.length);\n if (!rangeSafe) {\n return NaN;\n }\n let dist = Infinity;\n for (let i = range1[0]; i <= range1[1]; ++i) {\n for (let j = range2[0]; j <= range2[1]; ++j) {\n dist = Math.min(dist, ruler.distance(points1[i], points2[j]));\n if (dist === 0.0) {\n return dist;\n }\n }\n }\n return dist;\n}\nfunction pointToPolygonDistance(point, polygon, ruler) {\n if (pointWithinPolygon(point, polygon, true)) {\n return 0.0;\n }\n let dist = Infinity;\n for (const ring of polygon) {\n const front = ring[0];\n const back = ring[ring.length - 1];\n if (front !== back) {\n dist = Math.min(dist, pointToLineDistance(point, [back, front], ruler));\n if (dist === 0.0) {\n return dist;\n }\n }\n const nearestPoint = ruler.pointOnLine(ring, point);\n dist = Math.min(dist, ruler.distance(point, nearestPoint.point));\n if (dist === 0.0) {\n return dist;\n }\n }\n return dist;\n}\nfunction lineToPolygonDistance(line, range, polygon, ruler) {\n if (!isRangeSafe(range, line.length)) {\n return NaN;\n }\n for (let i = range[0]; i <= range[1]; ++i) {\n if (pointWithinPolygon(line[i], polygon, true)) {\n return 0.0;\n }\n }\n let dist = Infinity;\n for (let i = range[0]; i < range[1]; ++i) {\n const p1 = line[i];\n const p2 = line[i + 1];\n for (const ring of polygon) {\n for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {\n const q1 = ring[k];\n const q2 = ring[j];\n if (segmentIntersectSegment(p1, p2, q1, q2)) {\n return 0.0;\n }\n dist = Math.min(dist, segmentToSegmentDistance(p1, p2, q1, q2, ruler));\n }\n }\n }\n return dist;\n}\nfunction polygonIntersect(poly1, poly2) {\n for (const ring of poly1) {\n for (const point of ring) {\n if (pointWithinPolygon(point, poly2, true)) {\n return true;\n }\n }\n }\n return false;\n}\nfunction polygonToPolygonDistance(polygon1, polygon2, ruler, currentMiniDist = Infinity) {\n const bbox1 = getPolygonBBox(polygon1);\n const bbox2 = getPolygonBBox(polygon2);\n if (currentMiniDist !== Infinity && bboxToBBoxDistance(bbox1, bbox2, ruler) >= currentMiniDist) {\n return currentMiniDist;\n }\n if (boxWithinBox(bbox1, bbox2)) {\n if (polygonIntersect(polygon1, polygon2)) {\n return 0.0;\n }\n }\n else if (polygonIntersect(polygon2, polygon1)) {\n return 0.0;\n }\n let dist = Infinity;\n for (const ring1 of polygon1) {\n for (let i = 0, len1 = ring1.length, l = len1 - 1; i < len1; l = i++) {\n const p1 = ring1[l];\n const p2 = ring1[i];\n for (const ring2 of polygon2) {\n for (let j = 0, len2 = ring2.length, k = len2 - 1; j < len2; k = j++) {\n const q1 = ring2[k];\n const q2 = ring2[j];\n if (segmentIntersectSegment(p1, p2, q1, q2)) {\n return 0.0;\n }\n dist = Math.min(dist, segmentToSegmentDistance(p1, p2, q1, q2, ruler));\n }\n }\n }\n }\n return dist;\n}\nfunction updateQueue(distQueue, miniDist, ruler, points, polyBBox, rangeA) {\n if (!rangeA) {\n return;\n }\n const tempDist = bboxToBBoxDistance(getBBox(points, rangeA), polyBBox, ruler);\n // Insert new pair to the queue if the bbox distance is less than\n // miniDist, The pair with biggest distance will be at the top\n if (tempDist < miniDist) {\n distQueue.push([tempDist, rangeA, [0, 0]]);\n }\n}\nfunction updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, range1, range2) {\n if (!range1 || !range2) {\n return;\n }\n const tempDist = bboxToBBoxDistance(getBBox(pointSet1, range1), getBBox(pointSet2, range2), ruler);\n // Insert new pair to the queue if the bbox distance is less than\n // miniDist, The pair with biggest distance will be at the top\n if (tempDist < miniDist) {\n distQueue.push([tempDist, range1, range2]);\n }\n}\n// Divide and conquer, the time complexity is O(n*lgn), faster than Brute force\n// O(n*n) Most of the time, use index for in-place processing.\nfunction pointsToPolygonDistance(points, isLine, polygon, ruler, currentMiniDist = Infinity) {\n let miniDist = Math.min(ruler.distance(points[0], polygon[0][0]), currentMiniDist);\n if (miniDist === 0.0) {\n return miniDist;\n }\n const distQueue = new TinyQueue([[0, [0, points.length - 1], [0, 0]]], compareDistPair);\n const polyBBox = getPolygonBBox(polygon);\n while (distQueue.length > 0) {\n const distPair = distQueue.pop();\n if (distPair[0] >= miniDist) {\n continue;\n }\n const range = distPair[1];\n // In case the set size are relatively small, we could use brute-force directly\n const threshold = isLine ? MinLinePointsSize : MinPointsSize;\n if (getRangeSize(range) <= threshold) {\n if (!isRangeSafe(range, points.length)) {\n return NaN;\n }\n if (isLine) {\n const tempDist = lineToPolygonDistance(points, range, polygon, ruler);\n if (isNaN(tempDist) || tempDist === 0.0) {\n return tempDist;\n }\n miniDist = Math.min(miniDist, tempDist);\n }\n else {\n for (let i = range[0]; i <= range[1]; ++i) {\n const tempDist = pointToPolygonDistance(points[i], polygon, ruler);\n miniDist = Math.min(miniDist, tempDist);\n if (miniDist === 0.0) {\n return 0.0;\n }\n }\n }\n }\n else {\n const newRangesA = splitRange(range, isLine);\n updateQueue(distQueue, miniDist, ruler, points, polyBBox, newRangesA[0]);\n updateQueue(distQueue, miniDist, ruler, points, polyBBox, newRangesA[1]);\n }\n }\n return miniDist;\n}\nfunction pointSetToPointSetDistance(pointSet1, isLine1, pointSet2, isLine2, ruler, currentMiniDist = Infinity) {\n let miniDist = Math.min(currentMiniDist, ruler.distance(pointSet1[0], pointSet2[0]));\n if (miniDist === 0.0) {\n return miniDist;\n }\n const distQueue = new TinyQueue([[0, [0, pointSet1.length - 1], [0, pointSet2.length - 1]]], compareDistPair);\n while (distQueue.length > 0) {\n const distPair = distQueue.pop();\n if (distPair[0] >= miniDist) {\n continue;\n }\n const rangeA = distPair[1];\n const rangeB = distPair[2];\n const threshold1 = isLine1 ? MinLinePointsSize : MinPointsSize;\n const threshold2 = isLine2 ? MinLinePointsSize : MinPointsSize;\n // In case the set size are relatively small, we could use brute-force directly\n if (getRangeSize(rangeA) <= threshold1 && getRangeSize(rangeB) <= threshold2) {\n if (!isRangeSafe(rangeA, pointSet1.length) && isRangeSafe(rangeB, pointSet2.length)) {\n return NaN;\n }\n let tempDist;\n if (isLine1 && isLine2) {\n tempDist = lineToLineDistance(pointSet1, rangeA, pointSet2, rangeB, ruler);\n miniDist = Math.min(miniDist, tempDist);\n }\n else if (isLine1 && !isLine2) {\n const sublibe = pointSet1.slice(rangeA[0], rangeA[1] + 1);\n for (let i = rangeB[0]; i <= rangeB[1]; ++i) {\n tempDist = pointToLineDistance(pointSet2[i], sublibe, ruler);\n miniDist = Math.min(miniDist, tempDist);\n if (miniDist === 0.0) {\n return miniDist;\n }\n }\n }\n else if (!isLine1 && isLine2) {\n const sublibe = pointSet2.slice(rangeB[0], rangeB[1] + 1);\n for (let i = rangeA[0]; i <= rangeA[1]; ++i) {\n tempDist = pointToLineDistance(pointSet1[i], sublibe, ruler);\n miniDist = Math.min(miniDist, tempDist);\n if (miniDist === 0.0) {\n return miniDist;\n }\n }\n }\n else {\n tempDist = pointsToPointsDistance(pointSet1, rangeA, pointSet2, rangeB, ruler);\n miniDist = Math.min(miniDist, tempDist);\n }\n }\n else {\n const newRangesA = splitRange(rangeA, isLine1);\n const newRangesB = splitRange(rangeB, isLine2);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[0]);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[1]);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[0]);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[1]);\n }\n }\n return miniDist;\n}\nfunction pointToGeometryDistance(ctx, geometries) {\n const tilePoints = ctx.geometry();\n const pointPosition = tilePoints.flat().map(p => getLngLatFromTileCoord([p.x, p.y], ctx.canonical));\n if (tilePoints.length === 0) {\n return NaN;\n }\n const ruler = new CheapRuler(pointPosition[0][1]);\n let dist = Infinity;\n for (const geometry of geometries) {\n switch (geometry.type) {\n case 'Point':\n dist = Math.min(dist, pointSetToPointSetDistance(pointPosition, false, [geometry.coordinates], false, ruler, dist));\n break;\n case 'LineString':\n dist = Math.min(dist, pointSetToPointSetDistance(pointPosition, false, geometry.coordinates, true, ruler, dist));\n break;\n case 'Polygon':\n dist = Math.min(dist, pointsToPolygonDistance(pointPosition, false, geometry.coordinates, ruler, dist));\n break;\n }\n if (dist === 0.0) {\n return dist;\n }\n }\n return dist;\n}\nfunction lineStringToGeometryDistance(ctx, geometries) {\n const tileLine = ctx.geometry();\n const linePositions = tileLine.flat().map(p => getLngLatFromTileCoord([p.x, p.y], ctx.canonical));\n if (tileLine.length === 0) {\n return NaN;\n }\n const ruler = new CheapRuler(linePositions[0][1]);\n let dist = Infinity;\n for (const geometry of geometries) {\n switch (geometry.type) {\n case 'Point':\n dist = Math.min(dist, pointSetToPointSetDistance(linePositions, true, [geometry.coordinates], false, ruler, dist));\n break;\n case 'LineString':\n dist = Math.min(dist, pointSetToPointSetDistance(linePositions, true, geometry.coordinates, true, ruler, dist));\n break;\n case 'Polygon':\n dist = Math.min(dist, pointsToPolygonDistance(linePositions, true, geometry.coordinates, ruler, dist));\n break;\n }\n if (dist === 0.0) {\n return dist;\n }\n }\n return dist;\n}\nfunction polygonToGeometryDistance(ctx, geometries) {\n const tilePolygon = ctx.geometry();\n if (tilePolygon.length === 0 || tilePolygon[0].length === 0) {\n return NaN;\n }\n const polygons = classifyRings(tilePolygon, 0).map(polygon => {\n return polygon.map(ring => {\n return ring.map(p => getLngLatFromTileCoord([p.x, p.y], ctx.canonical));\n });\n });\n const ruler = new CheapRuler(polygons[0][0][0][1]);\n let dist = Infinity;\n for (const geometry of geometries) {\n for (const polygon of polygons) {\n switch (geometry.type) {\n case 'Point':\n dist = Math.min(dist, pointsToPolygonDistance([geometry.coordinates], false, polygon, ruler, dist));\n break;\n case 'LineString':\n dist = Math.min(dist, pointsToPolygonDistance(geometry.coordinates, true, polygon, ruler, dist));\n break;\n case 'Polygon':\n dist = Math.min(dist, polygonToPolygonDistance(polygon, geometry.coordinates, ruler, dist));\n break;\n }\n if (dist === 0.0) {\n return dist;\n }\n }\n }\n return dist;\n}\nfunction toSimpleGeometry(geometry) {\n if (geometry.type === 'MultiPolygon') {\n return geometry.coordinates.map(polygon => {\n return {\n type: 'Polygon',\n coordinates: polygon\n };\n });\n }\n if (geometry.type === 'MultiLineString') {\n return geometry.coordinates.map(lineString => {\n return {\n type: 'LineString',\n coordinates: lineString\n };\n });\n }\n if (geometry.type === 'MultiPoint') {\n return geometry.coordinates.map(point => {\n return {\n type: 'Point',\n coordinates: point\n };\n });\n }\n return [geometry];\n}\nclass Distance {\n constructor(geojson, geometries) {\n this.type = NumberType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'distance' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n return new Distance(geojson, geojson.features.map(feature => toSimpleGeometry(feature.geometry)).flat());\n }\n else if (geojson.type === 'Feature') {\n return new Distance(geojson, toSimpleGeometry(geojson.geometry));\n }\n else if ('type' in geojson && 'coordinates' in geojson) {\n return new Distance(geojson, toSimpleGeometry(geojson));\n }\n }\n return context.error('\\'distance\\' expression requires valid geojson object that contains polygon geometry type.');\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointToGeometryDistance(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return lineStringToGeometryDistance(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'Polygon') {\n return polygonToGeometryDistance(ctx, this.geometries);\n }\n }\n return NaN;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nconst expressions$1 = {\n // special forms\n '==': Equals,\n '!=': NotEquals,\n '>': GreaterThan,\n '<': LessThan,\n '>=': GreaterThanOrEqual,\n '<=': LessThanOrEqual,\n 'array': Assertion,\n 'at': At,\n 'boolean': Assertion,\n 'case': Case,\n 'coalesce': Coalesce,\n 'collator': CollatorExpression,\n 'format': FormatExpression,\n 'image': ImageExpression,\n 'in': In,\n 'index-of': IndexOf,\n 'interpolate': Interpolate,\n 'interpolate-hcl': Interpolate,\n 'interpolate-lab': Interpolate,\n 'length': Length,\n 'let': Let,\n 'literal': Literal,\n 'match': Match,\n 'number': Assertion,\n 'number-format': NumberFormat,\n 'object': Assertion,\n 'slice': Slice,\n 'step': Step,\n 'string': Assertion,\n 'to-boolean': Coercion,\n 'to-color': Coercion,\n 'to-number': Coercion,\n 'to-string': Coercion,\n 'var': Var,\n 'within': Within,\n 'distance': Distance\n};\n\nclass CompoundExpression {\n constructor(name, type, evaluate, args) {\n this.name = name;\n this.type = type;\n this._evaluate = evaluate;\n this.args = args;\n }\n evaluate(ctx) {\n return this._evaluate(ctx, this.args);\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return false;\n }\n static parse(args, context) {\n const op = args[0];\n const definition = CompoundExpression.definitions[op];\n if (!definition) {\n return context.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n // Now check argument types against each signature\n const type = Array.isArray(definition) ?\n definition[0] : definition.type;\n const availableOverloads = Array.isArray(definition) ?\n [[definition[1], definition[2]]] :\n definition.overloads;\n const overloads = availableOverloads.filter(([signature]) => (!Array.isArray(signature) || // varags\n signature.length === args.length - 1 // correct param count\n ));\n let signatureContext = null;\n for (const [params, evaluate] of overloads) {\n // Use a fresh context for each attempted signature so that, if\n // we eventually succeed, we haven't polluted `context.errors`.\n signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope);\n // First parse all the args, potentially coercing to the\n // types expected by this overload.\n const parsedArgs = [];\n let argParseFailed = false;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n const expectedType = Array.isArray(params) ?\n params[i - 1] :\n params.type;\n const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);\n if (!parsed) {\n argParseFailed = true;\n break;\n }\n parsedArgs.push(parsed);\n }\n if (argParseFailed) {\n // Couldn't coerce args of this overload to expected type, move\n // on to next one.\n continue;\n }\n if (Array.isArray(params)) {\n if (params.length !== parsedArgs.length) {\n signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);\n continue;\n }\n }\n for (let i = 0; i < parsedArgs.length; i++) {\n const expected = Array.isArray(params) ? params[i] : params.type;\n const arg = parsedArgs[i];\n signatureContext.concat(i + 1).checkSubtype(expected, arg.type);\n }\n if (signatureContext.errors.length === 0) {\n return new CompoundExpression(op, type, evaluate, parsedArgs);\n }\n }\n if (overloads.length === 1) {\n context.errors.push(...signatureContext.errors);\n }\n else {\n const expected = overloads.length ? overloads : availableOverloads;\n const signatures = expected\n .map(([params]) => stringifySignature(params))\n .join(' | ');\n const actualTypes = [];\n // For error message, re-parse arguments without trying to\n // apply any coercions\n for (let i = 1; i < args.length; i++) {\n const parsed = context.parse(args[i], 1 + actualTypes.length);\n if (!parsed)\n return null;\n actualTypes.push(typeToString(parsed.type));\n }\n context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);\n }\n return null;\n }\n static register(registry, definitions) {\n CompoundExpression.definitions = definitions;\n for (const name in definitions) {\n registry[name] = CompoundExpression;\n }\n }\n}\nfunction rgba(ctx, [r, g, b, a]) {\n r = r.evaluate(ctx);\n g = g.evaluate(ctx);\n b = b.evaluate(ctx);\n const alpha = a ? a.evaluate(ctx) : 1;\n const error = validateRGBA(r, g, b, alpha);\n if (error)\n throw new RuntimeError(error);\n return new Color(r / 255, g / 255, b / 255, alpha, false);\n}\nfunction has(key, obj) {\n return key in obj;\n}\nfunction get(key, obj) {\n const v = obj[key];\n return typeof v === 'undefined' ? null : v;\n}\nfunction binarySearch(v, a, i, j) {\n while (i <= j) {\n const m = (i + j) >> 1;\n if (a[m] === v)\n return true;\n if (a[m] > v)\n j = m - 1;\n else\n i = m + 1;\n }\n return false;\n}\nfunction varargs(type) {\n return { type };\n}\nCompoundExpression.register(expressions$1, {\n 'error': [\n ErrorType,\n [StringType],\n (ctx, [v]) => { throw new RuntimeError(v.evaluate(ctx)); }\n ],\n 'typeof': [\n StringType,\n [ValueType],\n (ctx, [v]) => typeToString(typeOf(v.evaluate(ctx)))\n ],\n 'to-rgba': [\n array(NumberType, 4),\n [ColorType],\n (ctx, [v]) => {\n const [r, g, b, a] = v.evaluate(ctx).rgb;\n return [r * 255, g * 255, b * 255, a];\n },\n ],\n 'rgb': [\n ColorType,\n [NumberType, NumberType, NumberType],\n rgba\n ],\n 'rgba': [\n ColorType,\n [NumberType, NumberType, NumberType, NumberType],\n rgba\n ],\n 'has': {\n type: BooleanType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'get': {\n type: ValueType,\n overloads: [\n [\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())\n ], [\n [StringType, ObjectType],\n (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'feature-state': [\n ValueType,\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})\n ],\n 'properties': [\n ObjectType,\n [],\n (ctx) => ctx.properties()\n ],\n 'geometry-type': [\n StringType,\n [],\n (ctx) => ctx.geometryType()\n ],\n 'id': [\n ValueType,\n [],\n (ctx) => ctx.id()\n ],\n 'zoom': [\n NumberType,\n [],\n (ctx) => ctx.globals.zoom\n ],\n 'heatmap-density': [\n NumberType,\n [],\n (ctx) => ctx.globals.heatmapDensity || 0\n ],\n 'line-progress': [\n NumberType,\n [],\n (ctx) => ctx.globals.lineProgress || 0\n ],\n 'accumulated': [\n ValueType,\n [],\n (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated\n ],\n '+': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 0;\n for (const arg of args) {\n result += arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '*': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 1;\n for (const arg of args) {\n result *= arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '-': {\n type: NumberType,\n overloads: [\n [\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)\n ], [\n [NumberType],\n (ctx, [a]) => -a.evaluate(ctx)\n ]\n ]\n },\n '/': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)\n ],\n '%': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)\n ],\n 'ln2': [\n NumberType,\n [],\n () => Math.LN2\n ],\n 'pi': [\n NumberType,\n [],\n () => Math.PI\n ],\n 'e': [\n NumberType,\n [],\n () => Math.E\n ],\n '^': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))\n ],\n 'sqrt': [\n NumberType,\n [NumberType],\n (ctx, [x]) => Math.sqrt(x.evaluate(ctx))\n ],\n 'log10': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10\n ],\n 'ln': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx))\n ],\n 'log2': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2\n ],\n 'sin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.sin(n.evaluate(ctx))\n ],\n 'cos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.cos(n.evaluate(ctx))\n ],\n 'tan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.tan(n.evaluate(ctx))\n ],\n 'asin': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.asin(n.evaluate(ctx))\n ],\n 'acos': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.acos(n.evaluate(ctx))\n ],\n 'atan': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.atan(n.evaluate(ctx))\n ],\n 'min': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'max': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))\n ],\n 'abs': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.abs(n.evaluate(ctx))\n ],\n 'round': [\n NumberType,\n [NumberType],\n (ctx, [n]) => {\n const v = n.evaluate(ctx);\n // Javascript's Math.round() rounds towards +Infinity for halfway\n // values, even when they're negative. It's more common to round\n // away from 0 (e.g., this is what python and C++ do)\n return v < 0 ? -Math.round(-v) : Math.round(v);\n }\n ],\n 'floor': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.floor(n.evaluate(ctx))\n ],\n 'ceil': [\n NumberType,\n [NumberType],\n (ctx, [n]) => Math.ceil(n.evaluate(ctx))\n ],\n 'filter-==': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => ctx.properties()[k.value] === v.value\n ],\n 'filter-id-==': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => ctx.id() === v.value\n ],\n 'filter-type-==': [\n BooleanType,\n [StringType],\n (ctx, [v]) => ctx.geometryType() === v.value\n ],\n 'filter-<': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter-id-<': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter->': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-id->': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-<=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter-id-<=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter->=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-id->=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-has': [\n BooleanType,\n [ValueType],\n (ctx, [k]) => k.value in ctx.properties()\n ],\n 'filter-has-id': [\n BooleanType,\n [],\n (ctx) => (ctx.id() !== null && ctx.id() !== undefined)\n ],\n 'filter-type-in': [\n BooleanType,\n [array(StringType)],\n (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0\n ],\n 'filter-id-in': [\n BooleanType,\n [array(ValueType)],\n (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0\n ],\n 'filter-in-small': [\n BooleanType,\n [StringType, array(ValueType)],\n // assumes v is an array literal\n (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0\n ],\n 'filter-in-large': [\n BooleanType,\n [StringType, array(ValueType)],\n // assumes v is a array literal with values sorted in ascending order and of a single type\n (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)\n ],\n 'all': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (!arg.evaluate(ctx))\n return false;\n }\n return true;\n }\n ]\n ]\n },\n 'any': {\n type: BooleanType,\n overloads: [\n [\n [BooleanType, BooleanType],\n (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)\n ],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (arg.evaluate(ctx))\n return true;\n }\n return false;\n }\n ]\n ]\n },\n '!': [\n BooleanType,\n [BooleanType],\n (ctx, [b]) => !b.evaluate(ctx)\n ],\n 'is-supported-script': [\n BooleanType,\n [StringType],\n // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant\n (ctx, [s]) => {\n const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;\n if (isSupportedScript) {\n return isSupportedScript(s.evaluate(ctx));\n }\n return true;\n }\n ],\n 'upcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toUpperCase()\n ],\n 'downcase': [\n StringType,\n [StringType],\n (ctx, [s]) => s.evaluate(ctx).toLowerCase()\n ],\n 'concat': [\n StringType,\n varargs(ValueType),\n (ctx, args) => args.map(arg => valueToString(arg.evaluate(ctx))).join('')\n ],\n 'resolved-locale': [\n StringType,\n [CollatorType],\n (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()\n ]\n});\nfunction stringifySignature(signature) {\n if (Array.isArray(signature)) {\n return `(${signature.map(typeToString).join(', ')})`;\n }\n else {\n return `(${typeToString(signature.type)}...)`;\n }\n}\nfunction isExpressionConstant(expression) {\n if (expression instanceof Var) {\n return isExpressionConstant(expression.boundExpression);\n }\n else if (expression instanceof CompoundExpression && expression.name === 'error') {\n return false;\n }\n else if (expression instanceof CollatorExpression) {\n // Although the results of a Collator expression with fixed arguments\n // generally shouldn't change between executions, we can't serialize them\n // as constant expressions because results change based on environment.\n return false;\n }\n else if (expression instanceof Within) {\n return false;\n }\n else if (expression instanceof Distance) {\n return false;\n }\n const isTypeAnnotation = expression instanceof Coercion ||\n expression instanceof Assertion;\n let childrenConstant = true;\n expression.eachChild(child => {\n // We can _almost_ assume that if `expressions` children are constant,\n // they would already have been evaluated to Literal values when they\n // were parsed. Type annotations are the exception, because they might\n // have been inferred and added after a child was parsed.\n // So we recurse into isConstant() for the children of type annotations,\n // but otherwise simply check whether they are Literals.\n if (isTypeAnnotation) {\n childrenConstant = childrenConstant && isExpressionConstant(child);\n }\n else {\n childrenConstant = childrenConstant && child instanceof Literal;\n }\n });\n if (!childrenConstant) {\n return false;\n }\n return isFeatureConstant(expression) &&\n isGlobalPropertyConstant(expression, ['zoom', 'heatmap-density', 'line-progress', 'accumulated', 'is-supported-script']);\n}\nfunction isFeatureConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'get' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'feature-state') {\n return false;\n }\n else if (e.name === 'has' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'properties' ||\n e.name === 'geometry-type' ||\n e.name === 'id') {\n return false;\n }\n else if (/^filter-/.test(e.name)) {\n return false;\n }\n }\n if (e instanceof Within) {\n return false;\n }\n if (e instanceof Distance) {\n return false;\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isFeatureConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isStateConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'feature-state') {\n return false;\n }\n }\n let result = true;\n e.eachChild(arg => {\n if (result && !isStateConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isGlobalPropertyConstant(e, properties) {\n if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isGlobalPropertyConstant(arg, properties)) {\n result = false;\n }\n });\n return result;\n}\n\nfunction success(value) {\n return { result: 'success', value };\n}\nfunction error(value) {\n return { result: 'error', value };\n}\n\nfunction supportsPropertyExpression(spec) {\n return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven';\n}\nfunction supportsZoomExpression(spec) {\n return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;\n}\nfunction supportsInterpolation(spec) {\n return !!spec.expression && spec.expression.interpolated;\n}\n\nfunction getType(val) {\n if (val instanceof Number) {\n return 'number';\n }\n else if (val instanceof String) {\n return 'string';\n }\n else if (val instanceof Boolean) {\n return 'boolean';\n }\n else if (Array.isArray(val)) {\n return 'array';\n }\n else if (val === null) {\n return 'null';\n }\n else {\n return typeof val;\n }\n}\n\nfunction isFunction$1(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\nfunction identityFunction(x) {\n return x;\n}\nfunction createFunction(parameters, propertySpec) {\n const isColor = propertySpec.type === 'color';\n const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');\n if (isColor || propertySpec.type === 'padding') {\n const parseFn = isColor ? Color.parse : Padding.parse;\n parameters = extendBy({}, parameters);\n if (parameters.stops) {\n parameters.stops = parameters.stops.map((stop) => {\n return [stop[0], parseFn(stop[1])];\n });\n }\n if (parameters.default) {\n parameters.default = parseFn(parameters.default);\n }\n else {\n parameters.default = parseFn(propertySpec.default);\n }\n }\n if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) {\n throw new Error(`Unknown color space: \"${parameters.colorSpace}\"`);\n }\n let innerFun;\n let hashedStops;\n let categoricalKeyType;\n if (type === 'exponential') {\n innerFun = evaluateExponentialFunction;\n }\n else if (type === 'interval') {\n innerFun = evaluateIntervalFunction;\n }\n else if (type === 'categorical') {\n innerFun = evaluateCategoricalFunction;\n // For categorical functions, generate an Object as a hashmap of the stops for fast searching\n hashedStops = Object.create(null);\n for (const stop of parameters.stops) {\n hashedStops[stop[0]] = stop[1];\n }\n // Infer key type based on first stop key-- used to encforce strict type checking later\n categoricalKeyType = typeof parameters.stops[0][0];\n }\n else if (type === 'identity') {\n innerFun = evaluateIdentityFunction;\n }\n else {\n throw new Error(`Unknown function type \"${type}\"`);\n }\n if (zoomAndFeatureDependent) {\n const featureFunctions = {};\n const zoomStops = [];\n for (let s = 0; s < parameters.stops.length; s++) {\n const stop = parameters.stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctions[zoom] === undefined) {\n featureFunctions[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n stops: []\n };\n zoomStops.push(zoom);\n }\n featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);\n }\n const featureFunctionStops = [];\n for (const z of zoomStops) {\n featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);\n }\n const interpolationType = { name: 'linear' };\n return {\n kind: 'composite',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: featureFunctionStops.map(s => s[0]),\n evaluate({ zoom }, properties) {\n return evaluateExponentialFunction({\n stops: featureFunctionStops,\n base: parameters.base\n }, propertySpec, zoom).evaluate(zoom, properties);\n }\n };\n }\n else if (zoomDependent) {\n const interpolationType = type === 'exponential' ?\n { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 } : null;\n return {\n kind: 'camera',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: parameters.stops.map(s => s[0]),\n evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)\n };\n }\n else {\n return {\n kind: 'source',\n evaluate(_, feature) {\n const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;\n if (value === undefined) {\n return coalesce$1(parameters.default, propertySpec.default);\n }\n return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);\n }\n };\n }\n}\nfunction coalesce$1(a, b, c) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n if (c !== undefined)\n return c;\n}\nfunction evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {\n const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input\n return coalesce$1(evaluated, parameters.default, propertySpec.default);\n}\nfunction evaluateIntervalFunction(parameters, propertySpec, input) {\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n return parameters.stops[index][1];\n}\nfunction evaluateExponentialFunction(parameters, propertySpec, input) {\n const base = parameters.base !== undefined ? parameters.base : 1;\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);\n const outputLower = parameters.stops[index][1];\n const outputUpper = parameters.stops[index + 1][1];\n const interp = interpolateFactory[propertySpec.type] || identityFunction;\n if (typeof outputLower.evaluate === 'function') {\n return {\n evaluate(...args) {\n const evaluatedLower = outputLower.evaluate.apply(undefined, args);\n const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);\n // Special case for fill-outline-color, which has no spec default.\n if (evaluatedLower === undefined || evaluatedUpper === undefined) {\n return undefined;\n }\n return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace);\n }\n };\n }\n return interp(outputLower, outputUpper, t, parameters.colorSpace);\n}\nfunction evaluateIdentityFunction(parameters, propertySpec, input) {\n switch (propertySpec.type) {\n case 'color':\n input = Color.parse(input);\n break;\n case 'formatted':\n input = Formatted.fromString(input.toString());\n break;\n case 'resolvedImage':\n input = ResolvedImage.fromString(input.toString());\n break;\n case 'padding':\n input = Padding.parse(input);\n break;\n default:\n if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {\n input = undefined;\n }\n }\n return coalesce$1(input, parameters.default, propertySpec.default);\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n *\n * How it works:\n * Two consecutive stop values define a (scaled and shifted) exponential\n * function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction interpolationFactor(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass StyleExpression {\n constructor(expression, propertySpec) {\n this.expression = expression;\n this._warningHistory = {};\n this._evaluator = new EvaluationContext();\n this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;\n this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature;\n this._evaluator.featureState = featureState;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection;\n return this.expression.evaluate(this._evaluator);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n this._evaluator.globals = globals;\n this._evaluator.feature = feature || null;\n this._evaluator.featureState = featureState || null;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection || null;\n try {\n const val = this.expression.evaluate(this._evaluator);\n if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {\n return this._defaultValue;\n }\n if (this._enumValues && !(val in this._enumValues)) {\n throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map(v => JSON.stringify(v)).join(', ')}, but found ${JSON.stringify(val)} instead.`);\n }\n return val;\n }\n catch (e) {\n if (!this._warningHistory[e.message]) {\n this._warningHistory[e.message] = true;\n if (typeof console !== 'undefined') {\n console.warn(e.message);\n }\n }\n return this._defaultValue;\n }\n }\n}\nfunction isExpression(expression) {\n return Array.isArray(expression) && expression.length > 0 &&\n typeof expression[0] === 'string' && expression[0] in expressions$1;\n}\n/**\n * Parse and typecheck the given style spec JSON expression. If\n * options.defaultValue is provided, then the resulting StyleExpression's\n * `evaluate()` method will handle errors by logging a warning (once per\n * message) and returning the default value. Otherwise, it will throw\n * evaluation errors.\n *\n * @private\n */\nfunction createExpression(expression, propertySpec) {\n const parser = new ParsingContext(expressions$1, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined);\n // For string-valued properties, coerce to string at the top level rather than asserting.\n const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);\n if (!parsed) {\n return error(parser.errors);\n }\n return success(new StyleExpression(parsed, propertySpec));\n}\nclass ZoomConstantExpression {\n constructor(kind, expression) {\n this.kind = kind;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'constant' && !isStateConstant(expression.expression);\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n}\nclass ZoomDependentExpression {\n constructor(kind, expression, zoomStops, interpolationType) {\n this.kind = kind;\n this.zoomStops = zoomStops;\n this._styleExpression = expression;\n this.isStateDependent = kind !== 'camera' && !isStateConstant(expression.expression);\n this.interpolationType = interpolationType;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n interpolationFactor(input, lower, upper) {\n if (this.interpolationType) {\n return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);\n }\n else {\n return 0;\n }\n }\n}\nfunction isZoomExpression(expression) {\n return expression._styleExpression !== undefined;\n}\nfunction createPropertyExpression(expressionInput, propertySpec) {\n const expression = createExpression(expressionInput, propertySpec);\n if (expression.result === 'error') {\n return expression;\n }\n const parsed = expression.value.expression;\n const isFeatureConstantResult = isFeatureConstant(parsed);\n if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'data expressions not supported')]);\n }\n const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']);\n if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'zoom expressions not supported')]);\n }\n const zoomCurve = findZoomCurve(parsed);\n if (!zoomCurve && !isZoomConstant) {\n return error([new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.')]);\n }\n else if (zoomCurve instanceof ExpressionParsingError) {\n return error([zoomCurve]);\n }\n else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {\n return error([new ExpressionParsingError('', '\"interpolate\" expressions cannot be used with this property')]);\n }\n if (!zoomCurve) {\n return success(isFeatureConstantResult ?\n new ZoomConstantExpression('constant', expression.value) :\n new ZoomConstantExpression('source', expression.value));\n }\n const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;\n return success(isFeatureConstantResult ?\n new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType) :\n new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType));\n}\n// serialization wrapper for old-style stop functions normalized to the\n// expression interface\nclass StylePropertyFunction {\n constructor(parameters, specification) {\n this._parameters = parameters;\n this._specification = specification;\n extendBy(this, createFunction(this._parameters, this._specification));\n }\n static deserialize(serialized) {\n return new StylePropertyFunction(serialized._parameters, serialized._specification);\n }\n static serialize(input) {\n return {\n _parameters: input._parameters,\n _specification: input._specification\n };\n }\n}\nfunction normalizePropertyExpression(value, specification) {\n if (isFunction$1(value)) {\n return new StylePropertyFunction(value, specification);\n }\n else if (isExpression(value)) {\n const expression = createPropertyExpression(value, specification);\n if (expression.result === 'error') {\n // this should have been caught in validation\n throw new Error(expression.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n return expression.value;\n }\n else {\n let constant = value;\n if (specification.type === 'color' && typeof value === 'string') {\n constant = Color.parse(value);\n }\n else if (specification.type === 'padding' && (typeof value === 'number' || Array.isArray(value))) {\n constant = Padding.parse(value);\n }\n else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) {\n constant = VariableAnchorOffsetCollection.parse(value);\n }\n else if (specification.type === 'projectionDefinition' && typeof value === 'string') {\n constant = ProjectionDefinition.parse(value);\n }\n return {\n kind: 'constant',\n evaluate: () => constant\n };\n }\n}\n// Zoom-dependent expressions may only use [\"zoom\"] as the input to a top-level \"step\" or \"interpolate\"\n// expression (collectively referred to as a \"curve\"). The curve may be wrapped in one or more \"let\" or\n// \"coalesce\" expressions.\nfunction findZoomCurve(expression) {\n let result = null;\n if (expression instanceof Let) {\n result = findZoomCurve(expression.result);\n }\n else if (expression instanceof Coalesce) {\n for (const arg of expression.args) {\n result = findZoomCurve(arg);\n if (result) {\n break;\n }\n }\n }\n else if ((expression instanceof Step || expression instanceof Interpolate) &&\n expression.input instanceof CompoundExpression &&\n expression.input.name === 'zoom') {\n result = expression;\n }\n if (result instanceof ExpressionParsingError) {\n return result;\n }\n expression.eachChild((child) => {\n const childResult = findZoomCurve(child);\n if (childResult instanceof ExpressionParsingError) {\n result = childResult;\n }\n else if (!result && childResult) {\n result = new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.');\n }\n else if (result && childResult && result !== childResult) {\n result = new ExpressionParsingError('', 'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.');\n }\n });\n return result;\n}\nfunction getExpectedType(spec) {\n const types = {\n color: ColorType,\n string: StringType,\n number: NumberType,\n enum: StringType,\n boolean: BooleanType,\n formatted: FormattedType,\n padding: PaddingType,\n projectionDefinition: ProjectionDefinitionType,\n resolvedImage: ResolvedImageType,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType\n };\n if (spec.type === 'array') {\n return array(types[spec.value] || ValueType, spec.length);\n }\n return types[spec.type];\n}\nfunction getDefaultValue(spec) {\n if (spec.type === 'color' && isFunction$1(spec.default)) {\n // Special case for heatmap-color: it uses the 'default:' to define a\n // default color ramp, but createExpression expects a simple value to fall\n // back to in case of runtime errors\n return new Color(0, 0, 0, 0);\n }\n else if (spec.type === 'color') {\n return Color.parse(spec.default) || null;\n }\n else if (spec.type === 'padding') {\n return Padding.parse(spec.default) || null;\n }\n else if (spec.type === 'variableAnchorOffsetCollection') {\n return VariableAnchorOffsetCollection.parse(spec.default) || null;\n }\n else if (spec.type === 'projectionDefinition') {\n return ProjectionDefinition.parse(spec.default) || null;\n }\n else if (spec.default === undefined) {\n return null;\n }\n else {\n return spec.default;\n }\n}\n\nfunction isExpressionFilter(filter) {\n if (filter === true || filter === false) {\n return true;\n }\n if (!Array.isArray(filter) || filter.length === 0) {\n return false;\n }\n switch (filter[0]) {\n case 'has':\n return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';\n case 'in':\n return filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2]));\n case '!in':\n case '!has':\n case 'none':\n return false;\n case '==':\n case '!=':\n case '>':\n case '>=':\n case '<':\n case '<=':\n return filter.length !== 3 || (Array.isArray(filter[1]) || Array.isArray(filter[2]));\n case 'any':\n case 'all':\n for (const f of filter.slice(1)) {\n if (!isExpressionFilter(f) && typeof f !== 'boolean') {\n return false;\n }\n }\n return true;\n default:\n return true;\n }\n}\nconst filterSpec = {\n 'type': 'boolean',\n 'default': false,\n 'transition': false,\n 'property-type': 'data-driven',\n 'expression': {\n 'interpolated': false,\n 'parameters': ['zoom', 'feature']\n }\n};\n/**\n * Given a filter expressed as nested arrays, return a new function\n * that evaluates whether a given feature (with a .properties or .tags property)\n * passes its test.\n *\n * @private\n * @param {Array} filter MapLibre filter\n * @returns {Function} filter-evaluating function\n */\nfunction featureFilter(filter) {\n if (filter === null || filter === undefined) {\n return { filter: () => true, needGeometry: false };\n }\n if (!isExpressionFilter(filter)) {\n filter = convertFilter$1(filter);\n }\n const compiled = createExpression(filter, filterSpec);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map(err => `${err.key}: ${err.message}`).join(', '));\n }\n else {\n const needGeometry = geometryNeeded(filter);\n return { filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical),\n needGeometry };\n }\n}\n// Comparison function to sort numbers and strings\nfunction compare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\nfunction geometryNeeded(filter) {\n if (!Array.isArray(filter))\n return false;\n if (filter[0] === 'within' || filter[0] === 'distance')\n return true;\n for (let index = 1; index < filter.length; index++) {\n if (geometryNeeded(filter[index]))\n return true;\n }\n return false;\n}\nfunction convertFilter$1(filter) {\n if (!filter)\n return true;\n const op = filter[0];\n if (filter.length <= 1)\n return (op !== 'any');\n const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') :\n op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) :\n op === '<' ||\n op === '>' ||\n op === '<=' ||\n op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) :\n op === 'any' ? convertDisjunctionOp(filter.slice(1)) :\n op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) :\n op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) :\n op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) :\n op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) :\n op === 'has' ? convertHasOp$1(filter[1]) :\n op === '!has' ? convertNegation(convertHasOp$1(filter[1])) :\n true;\n return converted;\n}\nfunction convertComparisonOp$1(property, value, op) {\n switch (property) {\n case '$type':\n return [`filter-type-${op}`, value];\n case '$id':\n return [`filter-id-${op}`, value];\n default:\n return [`filter-${op}`, property, value];\n }\n}\nfunction convertDisjunctionOp(filters) {\n return ['any'].concat(filters.map(convertFilter$1));\n}\nfunction convertInOp$1(property, values) {\n if (values.length === 0) {\n return false;\n }\n switch (property) {\n case '$type':\n return ['filter-type-in', ['literal', values]];\n case '$id':\n return ['filter-id-in', ['literal', values]];\n default:\n if (values.length > 200 && !values.some(v => typeof v !== typeof values[0])) {\n return ['filter-in-large', property, ['literal', values.sort(compare)]];\n }\n else {\n return ['filter-in-small', property, ['literal', values]];\n }\n }\n}\nfunction convertHasOp$1(property) {\n switch (property) {\n case '$type':\n return true;\n case '$id':\n return ['filter-has-id'];\n default:\n return ['filter-has', property];\n }\n}\nfunction convertNegation(filter) {\n return ['!', filter];\n}\n\n/*\n * Convert the given filter to an expression, storing the expected types for\n * any feature properties referenced in expectedTypes.\n *\n * These expected types are needed in order to construct preflight type checks\n * needed for handling 'any' filters. A preflight type check is necessary in\n * order to mimic legacy filters' semantics around expected type mismatches.\n * For example, consider the legacy filter:\n *\n * [\"any\", [\"all\", [\">\", \"y\", 0], [\">\", \"y\", 0]], [\">\", \"x\", 0]]\n *\n * Naively, we might convert this to the expression:\n *\n * [\"any\", [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]], [\">\", [\"get\", \"x\"], 0]]\n *\n * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the\n * [\">\", [\"get\", \"y\"], 0] would cause an evaluation error, leading to the\n * entire filter returning false. Legacy filter semantics, though, ask for\n * [\">\", \"y\", 0] to simply return `false` when `y` is of the wrong type,\n * allowing the subsequent terms of the outer \"any\" expression to be evaluated\n * (resulting, in this case, in a `true` value, because x > 0).\n *\n * We account for this by inserting a preflight type-checking expression before\n * each \"any\" term, allowing us to avoid evaluating the actual converted filter\n * if any type mismatches would cause it to produce an evaluation error:\n *\n * [\"any\",\n * [\"case\",\n * [\"all\", [\"==\", [\"typeof\", [\"get\", \"y\"]], \"number\"], [\"==\", [\"typeof\", [\"get\", \"z\"], \"number]],\n * [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]],\n * false\n * ],\n * [\"case\",\n * [\"==\", [\"typeof\", [\"get\", \"x\"], \"number\"]],\n * [\">\", [\"get\", \"x\"], 0],\n * false\n * ]\n * ]\n *\n * An alternative, possibly more direct approach would be to use type checks\n * in the conversion of each comparison operator, so that the converted version\n * of each individual ==, >=, etc. would mimic the legacy filter semantics. The\n * downside of this approach is that it can lead to many more type checks than\n * would otherwise be necessary: outside the context of an \"any\" expression,\n * bailing out due to a runtime type error (expression semantics) and returning\n * false (legacy filter semantics) are equivalent: they cause the filter to\n * produce a `false` result.\n */\nfunction convertFilter(filter, expectedTypes = {}) {\n if (isExpressionFilter(filter))\n return filter;\n if (!filter)\n return true;\n const legacyFilter = filter;\n const legacyOp = legacyFilter[0];\n if (filter.length <= 1)\n return (legacyOp !== 'any');\n switch (legacyOp) {\n case '==':\n case '!=':\n case '<':\n case '>':\n case '<=':\n case '>=': {\n const [, property, value] = filter;\n return convertComparisonOp(property, value, legacyOp, expectedTypes);\n }\n case 'any': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => {\n const types = {};\n const child = convertFilter(f, types);\n const typechecks = runtimeTypeChecks(types);\n return typechecks === true ? child : ['case', typechecks, child, false];\n });\n return ['any', ...children];\n }\n case 'all': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map(f => convertFilter(f, expectedTypes));\n return children.length > 1 ? ['all', ...children] : children[0];\n }\n case 'none': {\n const [, ...conditions] = legacyFilter;\n return ['!', convertFilter(['any', ...conditions], {})];\n }\n case 'in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values);\n }\n case '!in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values, true);\n }\n case 'has':\n return convertHasOp(legacyFilter[1]);\n case '!has':\n return ['!', convertHasOp(legacyFilter[1])];\n default:\n return true;\n }\n}\n// Given a set of feature properties and an expected type for each one,\n// construct an boolean expression that tests whether each property has the\n// right type.\n// E.g.: for {name: 'string', population: 'number'}, return\n// [ 'all',\n// ['==', ['typeof', ['get', 'name'], 'string']],\n// ['==', ['typeof', ['get', 'population'], 'number]]\n// ]\nfunction runtimeTypeChecks(expectedTypes) {\n const conditions = [];\n for (const property in expectedTypes) {\n const get = property === '$id' ? ['id'] : ['get', property];\n conditions.push(['==', ['typeof', get], expectedTypes[property]]);\n }\n if (conditions.length === 0)\n return true;\n if (conditions.length === 1)\n return conditions[0];\n return ['all', ...conditions];\n}\nfunction convertComparisonOp(property, value, op, expectedTypes) {\n let get;\n if (property === '$type') {\n return [op, ['geometry-type'], value];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n if (expectedTypes && value !== null) {\n const type = typeof value;\n expectedTypes[property] = type;\n }\n if (op === '==' && property !== '$id' && value === null) {\n return [\n 'all',\n ['has', property], // missing property != null for legacy filters\n ['==', get, null]\n ];\n }\n else if (op === '!=' && property !== '$id' && value === null) {\n return [\n 'any',\n ['!', ['has', property]], // missing property != null for legacy filters\n ['!=', get, null]\n ];\n }\n return [op, get, value];\n}\nfunction convertInOp(property, values, negate = false) {\n if (values.length === 0)\n return negate;\n let get;\n if (property === '$type') {\n get = ['geometry-type'];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n // Determine if the list of values to be searched is homogenously typed.\n // If so (and if the type is string or number), then we can use a\n // [match, input, [...values], true, false] construction rather than a\n // bunch of `==` tests.\n let uniformTypes = true;\n const type = typeof values[0];\n for (const value of values) {\n if (typeof value !== type) {\n uniformTypes = false;\n break;\n }\n }\n if (uniformTypes && (type === 'string' || type === 'number')) {\n // Match expressions must have unique values.\n const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);\n return ['match', get, uniqueValues, !negate, negate];\n }\n if (negate) {\n return ['all', ...values.map(v => ['!=', get, v])];\n }\n else {\n return ['any', ...values.map(v => ['==', get, v])];\n }\n}\nfunction convertHasOp(property) {\n if (property === '$type') {\n return true;\n }\n else if (property === '$id') {\n return ['!=', ['id'], null];\n }\n else {\n return ['has', property];\n }\n}\n\nfunction convertLiteral(value) {\n return typeof value === 'object' ? ['literal', value] : value;\n}\nfunction convertFunction(parameters, propertySpec) {\n let stops = parameters.stops;\n if (!stops) {\n // identity function\n return convertIdentityFunction(parameters, propertySpec);\n }\n const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n stops = stops.map((stop) => {\n if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {\n return [stop[0], convertTokenString(stop[1])];\n }\n return [stop[0], convertLiteral(stop[1])];\n });\n if (zoomAndFeatureDependent) {\n return convertZoomAndPropertyFunction(parameters, propertySpec, stops);\n }\n else if (zoomDependent) {\n return convertZoomFunction(parameters, propertySpec, stops);\n }\n else {\n return convertPropertyFunction(parameters, propertySpec, stops);\n }\n}\nfunction convertIdentityFunction(parameters, propertySpec) {\n const get = ['get', parameters.property];\n if (parameters.default === undefined) {\n // By default, expressions for string-valued properties get coerced. To preserve\n // legacy function semantics, insert an explicit assertion instead.\n return propertySpec.type === 'string' ? ['string', get] : get;\n }\n else if (propertySpec.type === 'enum') {\n return [\n 'match',\n get,\n Object.keys(propertySpec.values),\n get,\n parameters.default\n ];\n }\n else {\n const expression = [propertySpec.type === 'color' ? 'to-color' : propertySpec.type, get, convertLiteral(parameters.default)];\n if (propertySpec.type === 'array') {\n expression.splice(1, 0, propertySpec.value, propertySpec.length || null);\n }\n return expression;\n }\n}\nfunction getInterpolateOperator(parameters) {\n switch (parameters.colorSpace) {\n case 'hcl': return 'interpolate-hcl';\n case 'lab': return 'interpolate-lab';\n default: return 'interpolate';\n }\n}\nfunction convertZoomAndPropertyFunction(parameters, propertySpec, stops) {\n const featureFunctionParameters = {};\n const featureFunctionStops = {};\n const zoomStops = [];\n for (let s = 0; s < stops.length; s++) {\n const stop = stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctionParameters[zoom] === undefined) {\n featureFunctionParameters[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n };\n featureFunctionStops[zoom] = [];\n zoomStops.push(zoom);\n }\n featureFunctionStops[zoom].push([stop[0].value, stop[1]]);\n }\n // the interpolation type for the zoom dimension of a zoom-and-property\n // function is determined directly from the style property specification\n // for which it's being used: linear for interpolatable properties, step\n // otherwise.\n const functionType = getFunctionType({}, propertySpec);\n if (functionType === 'exponential') {\n const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, false);\n }\n return expression;\n }\n else {\n const expression = ['step', ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, true);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n }\n}\nfunction coalesce(a, b) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n}\nfunction getFallback(parameters, propertySpec) {\n const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));\n /*\n * Some fields with type: resolvedImage have an undefined default.\n * Because undefined is an invalid value for resolvedImage, set fallback to\n * an empty string instead of undefined to ensure output\n * passes validation.\n */\n if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {\n return '';\n }\n return defaultValue;\n}\nfunction convertPropertyFunction(parameters, propertySpec, stops) {\n const type = getFunctionType(parameters, propertySpec);\n const get = ['get', parameters.property];\n if (type === 'categorical' && typeof stops[0][0] === 'boolean') {\n const expression = ['case'];\n for (const stop of stops) {\n expression.push(['==', get, stop[0]], stop[1]);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'categorical') {\n const expression = ['match', get];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'interval') {\n const expression = ['step', ['number', get]];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], true);\n }\n fixupDegenerateStepCurve(expression);\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n const expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n ['number', get]\n ];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n return parameters.default === undefined ? expression : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else {\n throw new Error(`Unknown property function type ${type}`);\n }\n}\nfunction convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) {\n const type = getFunctionType(parameters, propertySpec);\n let expression;\n let isStep = false;\n if (type === 'interval') {\n expression = ['step', input];\n isStep = true;\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n expression = [getInterpolateOperator(parameters), base === 1 ? ['linear'] : ['exponential', base], input];\n }\n else {\n throw new Error(`Unknown zoom function type \"${type}\"`);\n }\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], isStep);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n}\nfunction fixupDegenerateStepCurve(expression) {\n // degenerate step curve (i.e. a constant function): add a noop stop\n if (expression[0] === 'step' && expression.length === 3) {\n expression.push(0);\n expression.push(expression[3]);\n }\n}\nfunction appendStopPair(curve, input, output, isStep) {\n // Skip duplicate stop values. They were not validated for functions, but they are for expressions.\n // https://github.com/mapbox/mapbox-gl-js/issues/4107\n if (curve.length > 3 && input === curve[curve.length - 2]) {\n return;\n }\n // step curves don't get the first input value, as it is redundant.\n if (!(isStep && curve.length === 2)) {\n curve.push(input);\n }\n curve.push(output);\n}\nfunction getFunctionType(parameters, propertySpec) {\n if (parameters.type) {\n return parameters.type;\n }\n else {\n return propertySpec.expression.interpolated ? 'exponential' : 'interval';\n }\n}\n// \"String with {name} token\" => [\"concat\", \"String with \", [\"get\", \"name\"], \" token\"]\nfunction convertTokenString(s) {\n const result = ['concat'];\n const re = /{([^{}]+)}/g;\n let pos = 0;\n for (let match = re.exec(s); match !== null; match = re.exec(s)) {\n const literal = s.slice(pos, re.lastIndex - match[0].length);\n pos = re.lastIndex;\n if (literal.length > 0)\n result.push(literal);\n result.push(['get', match[1]]);\n }\n if (result.length === 1) {\n return s;\n }\n if (pos < s.length) {\n result.push(s.slice(pos));\n }\n else if (result.length === 2) {\n return ['to-string', result[1]];\n }\n return result;\n}\n\nfunction getPropertyReference(propertyName) {\n for (let i = 0; i < v8Spec.layout.length; i++) {\n for (const key in v8Spec[v8Spec.layout[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.layout[i]][key];\n }\n }\n for (let i = 0; i < v8Spec.paint.length; i++) {\n for (const key in v8Spec[v8Spec.paint[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.paint[i]][key];\n }\n }\n return null;\n}\nfunction eachSource(style, callback) {\n for (const k in style.sources) {\n callback(style.sources[k]);\n }\n}\nfunction eachLayer(style, callback) {\n for (const layer of style.layers) {\n callback(layer);\n }\n}\nfunction eachProperty(style, options, callback) {\n function inner(layer, propertyType) {\n const properties = layer[propertyType];\n if (!properties)\n return;\n Object.keys(properties).forEach((key) => {\n callback({\n path: [layer.id, propertyType, key],\n key,\n value: properties[key],\n reference: getPropertyReference(key),\n set(x) {\n properties[key] = x;\n }\n });\n });\n }\n eachLayer(style, (layer) => {\n if (options.paint) {\n inner(layer, 'paint');\n }\n if (options.layout) {\n inner(layer, 'layout');\n }\n });\n}\n\nfunction stringify$1(obj) {\n const type = typeof obj;\n if (type === 'number' || type === 'boolean' || type === 'string' || obj === undefined || obj === null)\n return JSON.stringify(obj);\n if (Array.isArray(obj)) {\n let str = '[';\n for (const val of obj) {\n str += `${stringify$1(val)},`;\n }\n return `${str}]`;\n }\n const keys = Object.keys(obj).sort();\n let str = '{';\n for (let i = 0; i < keys.length; i++) {\n str += `${JSON.stringify(keys[i])}:${stringify$1(obj[keys[i]])},`;\n }\n return `${str}}`;\n}\nfunction getKey(layer) {\n let key = '';\n for (const k of refProperties) {\n key += `/${stringify$1(layer[k])}`;\n }\n return key;\n}\n/**\n * Given an array of layers, return an array of arrays of layers where all\n * layers in each group have identical layout-affecting properties. These\n * are the properties that were formerly used by explicit `ref` mechanism\n * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n * 'filter', and 'layout'.\n *\n * The input is not modified. The output layers are references to the\n * input layers.\n *\n * @private\n * @param {Array} layers\n * @param {Object} [cachedKeys] - an object to keep already calculated keys.\n * @returns {Array>}\n */\nfunction groupByLayout(layers, cachedKeys) {\n const groups = {};\n for (let i = 0; i < layers.length; i++) {\n const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);\n // update the cache if there is one\n if (cachedKeys)\n cachedKeys[layers[i].id] = k;\n let group = groups[k];\n if (!group) {\n group = groups[k] = [];\n }\n group.push(layers[i]);\n }\n const result = [];\n for (const k in groups) {\n result.push(groups[k]);\n }\n return result;\n}\n\nfunction emptyStyle() {\n const style = {};\n const version = v8Spec['$version'];\n for (const styleKey in v8Spec['$root']) {\n const specification = v8Spec['$root'][styleKey];\n if (specification.required) {\n let value = null;\n if (styleKey === 'version') {\n value = version;\n }\n else {\n if (specification.type === 'array') {\n value = [];\n }\n else {\n value = {};\n }\n }\n if (value != null) {\n style[styleKey] = value;\n }\n }\n }\n return style;\n}\n\nfunction validateConstants(options) {\n const key = options.key;\n const constants = options.value;\n if (constants) {\n return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];\n }\n else {\n return [];\n }\n}\n\n// Turn jsonlint-lines-primitives objects into primitive objects\nfunction unbundle(value) {\n if (value instanceof Number || value instanceof String || value instanceof Boolean) {\n return value.valueOf();\n }\n else {\n return value;\n }\n}\nfunction deepUnbundle(value) {\n if (Array.isArray(value)) {\n return value.map(deepUnbundle);\n }\n else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {\n const unbundledValue = {};\n for (const key in value) {\n unbundledValue[key] = deepUnbundle(value[key]);\n }\n return unbundledValue;\n }\n return unbundle(value);\n}\n\nfunction validateObject(options) {\n const key = options.key;\n const object = options.value;\n const elementSpecs = options.valueSpec || {};\n const elementValidators = options.objectElementValidators || {};\n const style = options.style;\n const styleSpec = options.styleSpec;\n const validateSpec = options.validateSpec;\n let errors = [];\n const type = getType(object);\n if (type !== 'object') {\n return [new ValidationError(key, object, `object expected, ${type} found`)];\n }\n for (const objectKey in object) {\n const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'\n const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];\n let validateElement;\n if (elementValidators[elementSpecKey]) {\n validateElement = elementValidators[elementSpecKey];\n }\n else if (elementSpecs[elementSpecKey]) {\n validateElement = validateSpec;\n }\n else if (elementValidators['*']) {\n validateElement = elementValidators['*'];\n }\n else if (elementSpecs['*']) {\n validateElement = validateSpec;\n }\n else {\n errors.push(new ValidationError(key, object[objectKey], `unknown property \"${objectKey}\"`));\n continue;\n }\n errors = errors.concat(validateElement({\n key: (key ? `${key}.` : key) + objectKey,\n value: object[objectKey],\n valueSpec: elementSpec,\n style,\n styleSpec,\n object,\n objectKey,\n validateSpec,\n }, object));\n }\n for (const elementSpecKey in elementSpecs) {\n // Don't check `required` when there's a custom validator for that property.\n if (elementValidators[elementSpecKey]) {\n continue;\n }\n if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {\n errors.push(new ValidationError(key, object, `missing required property \"${elementSpecKey}\"`));\n }\n }\n return errors;\n}\n\nfunction validateArray(options) {\n const array = options.value;\n const arraySpec = options.valueSpec;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const key = options.key;\n const validateArrayElement = options.arrayElementValidator || validateSpec;\n if (getType(array) !== 'array') {\n return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];\n }\n if (arraySpec.length && array.length !== arraySpec.length) {\n return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)];\n }\n if (arraySpec['min-length'] && array.length < arraySpec['min-length']) {\n return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)];\n }\n let arrayElementSpec = {\n 'type': arraySpec.value,\n 'values': arraySpec.values\n };\n if (styleSpec.$version < 7) {\n arrayElementSpec['function'] = arraySpec.function;\n }\n if (getType(arraySpec.value) === 'object') {\n arrayElementSpec = arraySpec.value;\n }\n let errors = [];\n for (let i = 0; i < array.length; i++) {\n errors = errors.concat(validateArrayElement({\n array,\n arrayIndex: i,\n value: array[i],\n valueSpec: arrayElementSpec,\n validateSpec: options.validateSpec,\n style,\n styleSpec,\n key: `${key}[${i}]`\n }));\n }\n return errors;\n}\n\nfunction validateNumber(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n let type = getType(value);\n if (type === 'number' && value !== value) {\n type = 'NaN';\n }\n if (type !== 'number') {\n return [new ValidationError(key, value, `number expected, ${type} found`)];\n }\n if ('minimum' in valueSpec && value < valueSpec.minimum) {\n return [new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)];\n }\n if ('maximum' in valueSpec && value > valueSpec.maximum) {\n return [new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)];\n }\n return [];\n}\n\nfunction validateFunction(options) {\n const functionValueSpec = options.valueSpec;\n const functionType = unbundle(options.value.type);\n let stopKeyType;\n let stopDomainValues = {};\n let previousStopDomainValue;\n let previousStopDomainZoom;\n const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;\n const isPropertyFunction = !isZoomFunction;\n const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' &&\n getType(options.value.stops[0]) === 'array' &&\n getType(options.value.stops[0][0]) === 'object';\n const errors = validateObject({\n key: options.key,\n value: options.value,\n valueSpec: options.styleSpec.function,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n stops: validateFunctionStops,\n default: validateFunctionDefault\n }\n });\n if (functionType === 'identity' && isZoomFunction) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"property\"'));\n }\n if (functionType !== 'identity' && !options.value.stops) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"stops\"'));\n }\n if (functionType === 'exponential' && options.valueSpec.expression && !supportsInterpolation(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported'));\n }\n if (options.styleSpec.$version >= 8) {\n if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'property functions not supported'));\n }\n else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));\n }\n }\n if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) {\n errors.push(new ValidationError(options.key, options.value, '\"property\" property is required'));\n }\n return errors;\n function validateFunctionStops(options) {\n if (functionType === 'identity') {\n return [new ValidationError(options.key, options.value, 'identity function may not have a \"stops\" property')];\n }\n let errors = [];\n const value = options.value;\n errors = errors.concat(validateArray({\n key: options.key,\n value,\n valueSpec: options.valueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n arrayElementValidator: validateFunctionStop\n }));\n if (getType(value) === 'array' && value.length === 0) {\n errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));\n }\n return errors;\n }\n function validateFunctionStop(options) {\n let errors = [];\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n if (value.length !== 2) {\n return [new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)];\n }\n if (isZoomAndPropertyFunction) {\n if (getType(value[0]) !== 'object') {\n return [new ValidationError(key, value, `object expected, ${getType(value[0])} found`)];\n }\n if (value[0].zoom === undefined) {\n return [new ValidationError(key, value, 'object stop key must have zoom')];\n }\n if (value[0].value === undefined) {\n return [new ValidationError(key, value, 'object stop key must have value')];\n }\n if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {\n return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')];\n }\n if (unbundle(value[0].zoom) !== previousStopDomainZoom) {\n previousStopDomainZoom = unbundle(value[0].zoom);\n previousStopDomainValue = undefined;\n stopDomainValues = {};\n }\n errors = errors.concat(validateObject({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: { zoom: {} },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: { zoom: validateNumber, value: validateStopDomainValue }\n }));\n }\n else {\n errors = errors.concat(validateStopDomainValue({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: {},\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }, value));\n }\n if (isExpression(deepUnbundle(value[1]))) {\n return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]);\n }\n return errors.concat(options.validateSpec({\n key: `${key}[1]`,\n value: value[1],\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n function validateStopDomainValue(options, stop) {\n const type = getType(options.value);\n const value = unbundle(options.value);\n const reportValue = options.value !== null ? options.value : stop;\n if (!stopKeyType) {\n stopKeyType = type;\n }\n else if (type !== stopKeyType) {\n return [new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)];\n }\n if (type !== 'number' && type !== 'string' && type !== 'boolean') {\n return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];\n }\n if (type !== 'number' && functionType !== 'categorical') {\n let message = `number expected, ${type} found`;\n if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {\n message += '\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.';\n }\n return [new ValidationError(options.key, reportValue, message)];\n }\n if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) {\n return [new ValidationError(options.key, reportValue, `integer expected, found ${value}`)];\n }\n if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];\n }\n else {\n previousStopDomainValue = value;\n }\n if (functionType === 'categorical' && value in stopDomainValues) {\n return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];\n }\n else {\n stopDomainValues[value] = true;\n }\n return [];\n }\n function validateFunctionDefault(options) {\n return options.validateSpec({\n key: options.key,\n value: options.value,\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n });\n }\n}\n\nfunction validateExpression(options) {\n const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);\n if (expression.result === 'error') {\n return expression.value.map((error) => {\n return new ValidationError(`${options.key}${error.key}`, options.value, error.message);\n });\n }\n const expressionObj = expression.value.expression || expression.value._styleExpression.expression;\n if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&\n !expressionObj.outputDefined()) {\n return [new ValidationError(options.key, options.value, `Invalid data expression for \"${options.propertyKey}\". Output values must be contained as literals within the expression.`)];\n }\n if (options.expressionContext === 'property' && options.propertyType === 'layout' &&\n (!isStateConstant(expressionObj))) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with layout properties.')];\n }\n if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with filters.')];\n }\n if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {\n if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {\n return [new ValidationError(options.key, options.value, '\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.')];\n }\n if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {\n return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')];\n }\n }\n return [];\n}\n\nfunction validateBoolean(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'boolean') {\n return [new ValidationError(key, value, `boolean expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateColor(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `color expected, ${type} found`)];\n }\n if (!Color.parse(String(value))) { // cast String object to string primitive\n return [new ValidationError(key, value, `color expected, \"${value}\" found`)];\n }\n return [];\n}\n\nfunction validateEnum(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n const errors = [];\n if (Array.isArray(valueSpec.values)) { // <=v7\n if (valueSpec.values.indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n else { // >=v8\n if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n return errors;\n}\n\nfunction validateFilter(options) {\n if (isExpressionFilter(deepUnbundle(options.value))) {\n return validateExpression(extendBy({}, options, {\n expressionContext: 'filter',\n valueSpec: { value: 'boolean' }\n }));\n }\n else {\n return validateNonExpressionFilter(options);\n }\n}\nfunction validateNonExpressionFilter(options) {\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n const styleSpec = options.styleSpec;\n let type;\n let errors = [];\n if (value.length < 1) {\n return [new ValidationError(key, value, 'filter array must have at least 1 element')];\n }\n errors = errors.concat(validateEnum({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: styleSpec.filter_operator,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n switch (unbundle(value[0])) {\n case '<':\n case '<=':\n case '>':\n case '>=':\n if (value.length >= 2 && unbundle(value[1]) === '$type') {\n errors.push(new ValidationError(key, value, `\"$type\" cannot be use with operator \"${value[0]}\"`));\n }\n /* falls through */\n case '==':\n case '!=':\n if (value.length !== 3) {\n errors.push(new ValidationError(key, value, `filter array for operator \"${value[0]}\" must have 3 elements`));\n }\n /* falls through */\n case 'in':\n case '!in':\n if (value.length >= 2) {\n type = getType(value[1]);\n if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n }\n for (let i = 2; i < value.length; i++) {\n type = getType(value[i]);\n if (unbundle(value[1]) === '$type') {\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec.geometry_type,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));\n }\n }\n break;\n case 'any':\n case 'all':\n case 'none':\n for (let i = 1; i < value.length; i++) {\n errors = errors.concat(validateNonExpressionFilter({\n key: `${key}[${i}]`,\n value: value[i],\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n break;\n case 'has':\n case '!has':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n break;\n }\n return errors;\n}\n\nfunction validateProperty(options, propertyType) {\n const key = options.key;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const value = options.value;\n const propertyKey = options.objectKey;\n const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];\n if (!layerSpec)\n return [];\n const transitionMatch = propertyKey.match(/^(.*)-transition$/);\n if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {\n return validateSpec({\n key,\n value,\n valueSpec: styleSpec.transition,\n style,\n styleSpec\n });\n }\n const valueSpec = options.valueSpec || layerSpec[propertyKey];\n if (!valueSpec) {\n return [new ValidationError(key, value, `unknown property \"${propertyKey}\"`)];\n }\n let tokenMatch;\n if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {\n return [new ValidationError(key, value, `\"${propertyKey}\" does not support interpolation syntax\\n` +\n `Use an identity property function instead: \\`{ \"type\": \"identity\", \"property\": ${JSON.stringify(tokenMatch[1])} }\\`.`)];\n }\n const errors = [];\n if (options.layerType === 'symbol') {\n if (propertyKey === 'text-field' && style && !style.glyphs) {\n errors.push(new ValidationError(key, value, 'use of \"text-field\" requires a style \"glyphs\" property'));\n }\n if (propertyKey === 'text-font' && isFunction$1(deepUnbundle(value)) && unbundle(value.type) === 'identity') {\n errors.push(new ValidationError(key, value, '\"text-font\" does not support identity functions'));\n }\n }\n return errors.concat(validateSpec({\n key: options.key,\n value,\n valueSpec,\n style,\n styleSpec,\n expressionContext: 'property',\n propertyType,\n propertyKey\n }));\n}\n\nfunction validatePaintProperty(options) {\n return validateProperty(options, 'paint');\n}\n\nfunction validateLayoutProperty(options) {\n return validateProperty(options, 'layout');\n}\n\nfunction validateLayer(options) {\n let errors = [];\n const layer = options.value;\n const key = options.key;\n const style = options.style;\n const styleSpec = options.styleSpec;\n if (!layer.type && !layer.ref) {\n errors.push(new ValidationError(key, layer, 'either \"type\" or \"ref\" is required'));\n }\n let type = unbundle(layer.type);\n const ref = unbundle(layer.ref);\n if (layer.id) {\n const layerId = unbundle(layer.id);\n for (let i = 0; i < options.arrayIndex; i++) {\n const otherLayer = style.layers[i];\n if (unbundle(otherLayer.id) === layerId) {\n errors.push(new ValidationError(key, layer.id, `duplicate layer id \"${layer.id}\", previously used at line ${otherLayer.id.__line__}`));\n }\n }\n }\n if ('ref' in layer) {\n ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => {\n if (p in layer) {\n errors.push(new ValidationError(key, layer[p], `\"${p}\" is prohibited for ref layers`));\n }\n });\n let parent;\n style.layers.forEach((layer) => {\n if (unbundle(layer.id) === ref)\n parent = layer;\n });\n if (!parent) {\n errors.push(new ValidationError(key, layer.ref, `ref layer \"${ref}\" not found`));\n }\n else if (parent.ref) {\n errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));\n }\n else {\n type = unbundle(parent.type);\n }\n }\n else if (type !== 'background') {\n if (!layer.source) {\n errors.push(new ValidationError(key, layer, 'missing required property \"source\"'));\n }\n else {\n const source = style.sources && style.sources[layer.source];\n const sourceType = source && unbundle(source.type);\n if (!source) {\n errors.push(new ValidationError(key, layer.source, `source \"${layer.source}\" not found`));\n }\n else if (sourceType === 'vector' && type === 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'hillshade') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType === 'raster' && type !== 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a vector source`));\n }\n else if (sourceType === 'vector' && !layer['source-layer']) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" must specify a \"source-layer\"`));\n }\n else if (sourceType === 'raster-dem' && type !== 'hillshade') {\n errors.push(new ValidationError(key, layer.source, 'raster-dem source can only be used with layer type \\'hillshade\\'.'));\n }\n else if (type === 'line' && layer.paint && layer.paint['line-gradient'] &&\n (sourceType !== 'geojson' || !source.lineMetrics)) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`));\n }\n }\n }\n errors = errors.concat(validateObject({\n key,\n value: layer,\n valueSpec: styleSpec.layer,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'() {\n return [];\n },\n // We don't want to enforce the spec's `\"requires\": true` for backward compatibility with refs;\n // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772.\n type() {\n return options.validateSpec({\n key: `${key}.type`,\n value: layer.type,\n valueSpec: styleSpec.layer.type,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n object: layer,\n objectKey: 'type'\n });\n },\n filter: validateFilter,\n layout(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validateLayoutProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n },\n paint(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validatePaintProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n }\n }\n }));\n return errors;\n}\n\nfunction validateString(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `string expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateRasterDEMSource(options) {\n var _a;\n const sourceName = (_a = options.sourceName) !== null && _a !== undefined ? _a : '';\n const rasterDEM = options.value;\n const styleSpec = options.styleSpec;\n const rasterDEMSpec = styleSpec.source_raster_dem;\n const style = options.style;\n let errors = [];\n const rootType = getType(rasterDEM);\n if (rasterDEM === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));\n return errors;\n }\n const encoding = unbundle(rasterDEM.encoding);\n const isCustomEncoding = encoding === 'custom';\n const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];\n const encodingName = options.value.encoding ? `\"${options.value.encoding}\"` : 'Default';\n for (const key in rasterDEM) {\n if (!isCustomEncoding && customEncodingKeys.includes(key)) {\n errors.push(new ValidationError(key, rasterDEM[key], `In \"${sourceName}\": \"${key}\" is only valid when \"encoding\" is set to \"custom\". ${encodingName} encoding found`));\n }\n else if (rasterDEMSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: rasterDEM[key],\n valueSpec: rasterDEMSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors.push(new ValidationError(key, rasterDEM[key], `unknown property \"${key}\"`));\n }\n }\n return errors;\n}\n\nconst objectElementValidators = {\n promoteId: validatePromoteId\n};\nfunction validateSource(options) {\n const value = options.value;\n const key = options.key;\n const styleSpec = options.styleSpec;\n const style = options.style;\n const validateSpec = options.validateSpec;\n if (!value.type) {\n return [new ValidationError(key, value, '\"type\" is required')];\n }\n const type = unbundle(value.type);\n let errors;\n switch (type) {\n case 'vector':\n case 'raster':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec[`source_${type.replace('-', '_')}`],\n style: options.style,\n styleSpec,\n objectElementValidators,\n validateSpec,\n });\n return errors;\n case 'raster-dem':\n errors = validateRasterDEMSource({\n sourceName: key,\n value,\n style: options.style,\n styleSpec,\n validateSpec,\n });\n return errors;\n case 'geojson':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec.source_geojson,\n style,\n styleSpec,\n validateSpec,\n objectElementValidators\n });\n if (value.cluster) {\n for (const prop in value.clusterProperties) {\n const [operator, mapExpr] = value.clusterProperties[prop];\n const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator;\n errors.push(...validateExpression({\n key: `${key}.${prop}.map`,\n value: mapExpr,\n validateSpec,\n expressionContext: 'cluster-map'\n }));\n errors.push(...validateExpression({\n key: `${key}.${prop}.reduce`,\n value: reduceExpr,\n validateSpec,\n expressionContext: 'cluster-reduce'\n }));\n }\n }\n return errors;\n case 'video':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_video,\n style,\n validateSpec,\n styleSpec\n });\n case 'image':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_image,\n style,\n validateSpec,\n styleSpec\n });\n case 'canvas':\n return [new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')];\n default:\n return validateEnum({\n key: `${key}.type`,\n value: value.type,\n valueSpec: { values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image'] },\n style,\n validateSpec,\n styleSpec\n });\n }\n}\nfunction validatePromoteId({ key, value }) {\n if (getType(value) === 'string') {\n return validateString({ key, value });\n }\n else {\n const errors = [];\n for (const prop in value) {\n errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] }));\n }\n return errors;\n }\n}\n\nfunction validateLight(options) {\n const light = options.value;\n const styleSpec = options.styleSpec;\n const lightSpec = styleSpec.light;\n const style = options.style;\n let errors = [];\n const rootType = getType(light);\n if (light === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('light', light, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in light) {\n const transitionMatch = key.match(/^(.*)-transition$/);\n if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: styleSpec.transition,\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else if (lightSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: lightSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, light[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateSky(options) {\n const sky = options.value;\n const styleSpec = options.styleSpec;\n const skySpec = styleSpec.sky;\n const style = options.style;\n const rootType = getType(sky);\n if (sky === undefined) {\n return [];\n }\n else if (rootType !== 'object') {\n return [new ValidationError('sky', sky, `object expected, ${rootType} found`)];\n }\n let errors = [];\n for (const key in sky) {\n if (skySpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: sky[key],\n valueSpec: skySpec[key],\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, sky[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateTerrain(options) {\n const terrain = options.value;\n const styleSpec = options.styleSpec;\n const terrainSpec = styleSpec.terrain;\n const style = options.style;\n let errors = [];\n const rootType = getType(terrain);\n if (terrain === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${rootType} found`)]);\n return errors;\n }\n for (const key in terrain) {\n if (terrainSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: terrain[key],\n valueSpec: terrainSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, terrain[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateFormatted(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validateImage(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validatePadding(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1 || value.length > 4) {\n return [new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)];\n }\n const arrayElementSpec = {\n type: 'number'\n };\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateVariableAnchorOffsetCollection(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n const styleSpec = options.styleSpec;\n if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) {\n return [new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')];\n }\n let errors = [];\n for (let i = 0; i < value.length; i += 2) {\n // Elements in even positions should be values from text-anchor enum\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec['layout_symbol']['text-anchor']\n }));\n // Elements in odd positions should be points (2-element numeric arrays)\n errors = errors.concat(validateArray({\n key: `${key}[${i + 1}]`,\n value: value[i + 1],\n valueSpec: {\n length: 2,\n value: 'number'\n },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec\n }));\n }\n return errors;\n}\n\nfunction validateSprite(options) {\n let errors = [];\n const sprite = options.value;\n const key = options.key;\n if (!Array.isArray(sprite)) {\n return validateString({\n key,\n value: sprite\n });\n }\n else {\n const allSpriteIds = [];\n const allSpriteURLs = [];\n for (const i in sprite) {\n if (sprite[i].id && allSpriteIds.includes(sprite[i].id))\n errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`));\n allSpriteIds.push(sprite[i].id);\n if (sprite[i].url && allSpriteURLs.includes(sprite[i].url))\n errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`));\n allSpriteURLs.push(sprite[i].url);\n const pairSpec = {\n id: {\n type: 'string',\n required: true,\n },\n url: {\n type: 'string',\n required: true,\n }\n };\n errors = errors.concat(validateObject({\n key: `${key}[${i}]`,\n value: sprite[i],\n valueSpec: pairSpec,\n validateSpec: options.validateSpec,\n }));\n }\n return errors;\n }\n}\n\nfunction validateProjection(options) {\n const projection = options.value;\n const styleSpec = options.styleSpec;\n const projectionSpec = styleSpec.projection;\n const style = options.style;\n const rootType = getType(projection);\n if (projection === undefined) {\n return [];\n }\n else if (rootType !== 'object') {\n return [new ValidationError('projection', projection, `object expected, ${rootType} found`)];\n }\n let errors = [];\n for (const key in projection) {\n if (projectionSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: projection[key],\n valueSpec: projectionSpec[key],\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([new ValidationError(key, projection[key], `unknown property \"${key}\"`)]);\n }\n }\n return errors;\n}\n\nfunction validateProjectionDefinition(options) {\n const key = options.key;\n let value = options.value;\n value = value instanceof String ? value.valueOf() : value;\n const type = getType(value);\n if (type === 'array' && !isProjectionDefinitionValue(value) && !isPropertyValueSpecification(value)) {\n return [new ValidationError(key, value, `projection expected, invalid array ${JSON.stringify(value)} found`)];\n }\n else if (!['array', 'string'].includes(type)) {\n return [new ValidationError(key, value, `projection expected, invalid type \"${type}\" found`)];\n }\n return [];\n}\nfunction isPropertyValueSpecification(value) {\n if (['interpolate', 'step', 'literal'].includes(value[0])) {\n return true;\n }\n return false;\n}\nfunction isProjectionDefinitionValue(value) {\n return Array.isArray(value) &&\n value.length === 3 &&\n typeof value[0] === 'string' &&\n typeof value[1] === 'string' &&\n typeof value[2] === 'number';\n}\n\nconst VALIDATORS = {\n '*'() {\n return [];\n },\n 'array': validateArray,\n 'boolean': validateBoolean,\n 'number': validateNumber,\n 'color': validateColor,\n 'constants': validateConstants,\n 'enum': validateEnum,\n 'filter': validateFilter,\n 'function': validateFunction,\n 'layer': validateLayer,\n 'object': validateObject,\n 'source': validateSource,\n 'light': validateLight,\n 'sky': validateSky,\n 'terrain': validateTerrain,\n 'projection': validateProjection,\n 'projectionDefinition': validateProjectionDefinition,\n 'string': validateString,\n 'formatted': validateFormatted,\n 'resolvedImage': validateImage,\n 'padding': validatePadding,\n 'variableAnchorOffsetCollection': validateVariableAnchorOffsetCollection,\n 'sprite': validateSprite,\n};\n/**\n * Main recursive validation function used internally.\n * You should use `validateStyleMin` in the browser or `validateStyle` in node env.\n * @param options - the options object\n * @param options.key - string representing location of validation in style tree. Used only\n * for more informative error reporting.\n * @param options.value - current value from style being evaluated. May be anything from a\n * high level object that needs to be descended into deeper or a simple\n * scalar value.\n * @param options.valueSpec - current spec being evaluated. Tracks value.\n * @param options.styleSpec - current full spec being evaluated.\n * @param options.validateSpec - the validate function itself\n * @param options.style - the style object\n * @param options.objectElementValidators - optional object of functions that will be called\n * @returns an array of errors, or an empty array if no errors are found.\n */\nfunction validate(options) {\n const value = options.value;\n const valueSpec = options.valueSpec;\n const styleSpec = options.styleSpec;\n options.validateSpec = validate;\n if (valueSpec.expression && isFunction$1(unbundle(value))) {\n return validateFunction(options);\n }\n else if (valueSpec.expression && isExpression(deepUnbundle(value))) {\n return validateExpression(options);\n }\n else if (valueSpec.type && VALIDATORS[valueSpec.type]) {\n return VALIDATORS[valueSpec.type](options);\n }\n else {\n const valid = validateObject(extendBy({}, options, {\n valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec\n }));\n return valid;\n }\n}\n\nfunction validateGlyphsUrl(options) {\n const value = options.value;\n const key = options.key;\n const errors = validateString(options);\n if (errors.length)\n return errors;\n if (value.indexOf('{fontstack}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{fontstack}\" token'));\n }\n if (value.indexOf('{range}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{range}\" token'));\n }\n return errors;\n}\n\n/**\n * Validate a MapLibre style against the style specification.\n * Use this when running in the browser.\n *\n * @param style - The style to be validated.\n * @param styleSpec - The style specification to validate against.\n * If omitted, the latest style spec is used.\n * @returns an array of errors, or an empty array if no errors are found.\n * @example\n * const validate = require('@maplibre/maplibre-gl-style-spec/').validateStyleMin;\n * const errors = validate(style);\n */\nfunction validateStyleMin(style, styleSpec = v8Spec) {\n let errors = [];\n errors = errors.concat(validate({\n key: '',\n value: style,\n valueSpec: styleSpec.$root,\n styleSpec,\n style,\n validateSpec: validate,\n objectElementValidators: {\n glyphs: validateGlyphsUrl,\n '*'() {\n return [];\n }\n }\n }));\n if (style['constants']) {\n errors = errors.concat(validateConstants({\n key: 'constants',\n value: style['constants'],\n style,\n styleSpec,\n validateSpec: validate,\n }));\n }\n return sortErrors(errors);\n}\nvalidateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource));\nvalidateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite));\nvalidateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl));\nvalidateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight));\nvalidateStyleMin.sky = wrapCleanErrors(injectValidateSpec(validateSky));\nvalidateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain));\nvalidateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer));\nvalidateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter));\nvalidateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty));\nvalidateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty));\nfunction injectValidateSpec(validator) {\n return function (options) {\n return validator({\n ...options,\n validateSpec: validate,\n });\n };\n}\nfunction sortErrors(errors) {\n return [].concat(errors).sort((a, b) => {\n return a.line - b.line;\n });\n}\nfunction wrapCleanErrors(inner) {\n return function (...args) {\n return sortErrors(inner.apply(this, args));\n };\n}\n\n// Note: This regex matches even invalid JSON strings, but since we’re\n// working on the output of `JSON.stringify` we know that only valid strings\n// are present (unless the user supplied a weird `options.indent` but in\n// that case we don’t care since the output would be invalid anyway).\nconst stringOrChar = /(\"(?:[^\\\\\"]|\\\\.)*\")|[:,]/g;\n\nfunction stringify(passedObj, options = {}) {\n const indent = JSON.stringify(\n [1],\n undefined,\n options.indent === undefined ? 2 : options.indent\n ).slice(2, -3);\n\n const maxLength =\n indent === \"\"\n ? Infinity\n : options.maxLength === undefined\n ? 80\n : options.maxLength;\n\n let { replacer } = options;\n\n return (function _stringify(obj, currentIndent, reserved) {\n if (obj && typeof obj.toJSON === \"function\") {\n obj = obj.toJSON();\n }\n\n const string = JSON.stringify(obj, replacer);\n\n if (string === undefined) {\n return string;\n }\n\n const length = maxLength - currentIndent.length - reserved;\n\n if (string.length <= length) {\n const prettified = string.replace(\n stringOrChar,\n (match, stringLiteral) => {\n return stringLiteral || `${match} `;\n }\n );\n if (prettified.length <= length) {\n return prettified;\n }\n }\n\n if (replacer != null) {\n obj = JSON.parse(string);\n replacer = undefined;\n }\n\n if (typeof obj === \"object\" && obj !== null) {\n const nextIndent = currentIndent + indent;\n const items = [];\n let index = 0;\n let start;\n let end;\n\n if (Array.isArray(obj)) {\n start = \"[\";\n end = \"]\";\n const { length } = obj;\n for (; index < length; index++) {\n items.push(\n _stringify(obj[index], nextIndent, index === length - 1 ? 0 : 1) ||\n \"null\"\n );\n }\n } else {\n start = \"{\";\n end = \"}\";\n const keys = Object.keys(obj);\n const { length } = keys;\n for (; index < length; index++) {\n const key = keys[index];\n const keyPart = `${JSON.stringify(key)}: `;\n const value = _stringify(\n obj[key],\n nextIndent,\n keyPart.length + (index === length - 1 ? 0 : 1)\n );\n if (value !== undefined) {\n items.push(keyPart + value);\n }\n }\n }\n\n if (items.length > 0) {\n return [start, indent + items.join(`,\\n${nextIndent}`), end].join(\n `\\n${currentIndent}`\n );\n }\n }\n\n return string;\n })(passedObj, \"\", 0);\n}\n\nfunction sortKeysBy(obj, reference) {\n const result = {};\n for (const key in reference) {\n if (obj[key] !== undefined) {\n result[key] = obj[key];\n }\n }\n for (const key in obj) {\n if (result[key] === undefined) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n/**\n * Format a MapLibre Style. Returns a stringified style with its keys\n * sorted in the same order as the reference style.\n *\n * The optional `space` argument is passed to\n * [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)\n * to generate formatted output.\n *\n * If `space` is unspecified, a default of `2` spaces will be used.\n *\n * @private\n * @param {Object} style a MapLibre Style\n * @param {number} [space] space argument to pass to `JSON.stringify`\n * @returns {string} stringified formatted JSON\n * @example\n * var fs = require('fs');\n * var format = require('maplibre-gl-style-spec').format;\n * var style = fs.readFileSync('./source.json', 'utf8');\n * fs.writeFileSync('./dest.json', format(style));\n * fs.writeFileSync('./dest.min.json', format(style, 0));\n */\nfunction format(style, space = 2) {\n style = sortKeysBy(style, v8Spec.$root);\n if (style.layers) {\n style.layers = style.layers.map((layer) => sortKeysBy(layer, v8Spec.layer));\n }\n return stringify(style, { indent: space });\n}\n\nfunction eachLayout(layer, callback) {\n for (const k in layer) {\n if (k.indexOf('layout') === 0) {\n callback(layer[k], k);\n }\n }\n}\nfunction eachPaint(layer, callback) {\n for (const k in layer) {\n if (k.indexOf('paint') === 0) {\n callback(layer[k], k);\n }\n }\n}\nfunction resolveConstant(style, value) {\n if (typeof value === 'string' && value[0] === '@') {\n return resolveConstant(style, style.constants[value]);\n }\n else {\n return value;\n }\n}\nfunction isFunction(value) {\n return Array.isArray(value.stops);\n}\nfunction renameProperty(obj, from, to) {\n obj[to] = obj[from];\n delete obj[from];\n}\nfunction migrateV8(style) {\n style.version = 8;\n // Rename properties, reverse coordinates in source and layers\n eachSource(style, (source) => {\n if (source.type === 'video' && source['url'] !== undefined) {\n renameProperty(source, 'url', 'urls');\n }\n if (source.type === 'video') {\n source.coordinates.forEach((coord) => {\n return coord.reverse();\n });\n }\n });\n eachLayer(style, (layer) => {\n eachLayout(layer, (layout) => {\n if (layout['symbol-min-distance'] !== undefined) {\n renameProperty(layout, 'symbol-min-distance', 'symbol-spacing');\n }\n });\n eachPaint(layer, (paint) => {\n if (paint['background-image'] !== undefined) {\n renameProperty(paint, 'background-image', 'background-pattern');\n }\n if (paint['line-image'] !== undefined) {\n renameProperty(paint, 'line-image', 'line-pattern');\n }\n if (paint['fill-image'] !== undefined) {\n renameProperty(paint, 'fill-image', 'fill-pattern');\n }\n });\n });\n // Inline Constants\n eachProperty(style, { paint: true, layout: true }, (property) => {\n const value = resolveConstant(style, property.value);\n if (isFunction(value)) {\n value.stops.forEach((stop) => {\n stop[1] = resolveConstant(style, stop[1]);\n });\n }\n property.set(value);\n });\n delete style['constants'];\n eachLayer(style, (layer) => {\n // get rid of text-max-size, icon-max-size\n // turn text-size, icon-size into layout properties\n // https://github.com/mapbox/mapbox-gl-style-spec/issues/255\n eachLayout(layer, (layout) => {\n delete layout['text-max-size'];\n delete layout['icon-max-size'];\n });\n eachPaint(layer, (paint) => {\n if (paint['text-size']) {\n if (!layer.layout)\n layer.layout = {};\n layer.layout['text-size'] = paint['text-size'];\n delete paint['text-size'];\n }\n if (paint['icon-size']) {\n if (!layer.layout)\n layer.layout = {};\n layer.layout['icon-size'] = paint['icon-size'];\n delete paint['icon-size'];\n }\n });\n });\n function migrateFontStack(font) {\n function splitAndTrim(string) {\n return string.split(',').map((s) => {\n return s.trim();\n });\n }\n if (Array.isArray(font)) {\n // Assume it's a previously migrated font-array.\n return font;\n }\n else if (typeof font === 'string') {\n return splitAndTrim(font);\n }\n else if (typeof font === 'object') {\n font.stops.forEach((stop) => {\n stop[1] = splitAndTrim(stop[1]);\n });\n return font;\n }\n else {\n throw new Error('unexpected font value');\n }\n }\n eachLayer(style, (layer) => {\n eachLayout(layer, (layout) => {\n if (layout['text-font']) {\n layout['text-font'] = migrateFontStack(layout['text-font']);\n }\n });\n });\n // Reverse order of symbol layers. This is an imperfect migration.\n //\n // The order of a symbol layer in the layers list affects two things:\n // - how it is drawn relative to other layers (like oneway arrows below bridges)\n // - the placement priority compared to other layers\n //\n // It's impossible to reverse the placement priority without breaking the draw order\n // in some cases. This migration only reverses the order of symbol layers that\n // are above all other types of layers.\n //\n // Symbol layers that are at the top of the map preserve their priority.\n // Symbol layers that are below another type (line, fill) of layer preserve their draw order.\n let firstSymbolLayer = 0;\n for (let i = style.layers.length - 1; i >= 0; i--) {\n const layer = style.layers[i];\n if (layer.type !== 'symbol') {\n firstSymbolLayer = i + 1;\n break;\n }\n }\n const symbolLayers = style.layers.splice(firstSymbolLayer);\n symbolLayers.reverse();\n style.layers = style.layers.concat(symbolLayers);\n return style;\n}\n\n/**\n * Migrate the given style object in place to use expressions. Specifically,\n * this will convert (a) \"stop\" functions, and (b) legacy filters to their\n * expression equivalents.\n * @param style The style object to migrate.\n * @returns The migrated style object.\n */\nfunction expressions(style) {\n const converted = [];\n eachLayer(style, (layer) => {\n if (layer.filter) {\n layer.filter = convertFilter(layer.filter);\n }\n });\n eachProperty(style, { paint: true, layout: true }, ({ path, value, reference, set }) => {\n if (isExpression(value))\n return;\n if (typeof value === 'object' && !Array.isArray(value)) {\n set(convertFunction(value, reference));\n converted.push(path.join('.'));\n }\n else if (reference.tokens && typeof value === 'string') {\n set(convertTokenString(value));\n }\n });\n return style;\n}\n\n/**\n * Migrate color style values to supported format.\n *\n * @param colorToMigrate Color value to migrate, could be a string or an expression.\n * @returns Color style value in supported format.\n */\nfunction migrateColors(colorToMigrate) {\n return JSON.parse(migrateHslColors(JSON.stringify(colorToMigrate)));\n}\n/**\n * Created to migrate from colors supported by the former CSS color parsing\n * library `csscolorparser` but not compliant with the CSS Color specification,\n * like `hsl(900, 0.15, 90%)`.\n *\n * @param colorToMigrate Serialized color style value.\n * @returns A serialized color style value in which all non-standard hsl color values\n * have been converted to a format that complies with the CSS Color specification.\n *\n * @example\n * migrateHslColors('\"hsl(900, 0.15, 90%)\"'); // returns '\"hsl(900, 15%, 90%)\"'\n * migrateHslColors('\"hsla(900, .15, .9)\"'); // returns '\"hsl(900, 15%, 90%)\"'\n * migrateHslColors('\"hsl(900, 15%, 90%)\"'); // returns '\"hsl(900, 15%, 90%)\"' - no changes\n */\nfunction migrateHslColors(colorToMigrate) {\n return colorToMigrate.replace(/\"hsla?\\((.+?)\\)\"/gi, (match, hslArgs) => {\n const argsMatch = hslArgs.match(/^(.+?)\\s*,\\s*(.+?)\\s*,\\s*(.+?)(?:\\s*,\\s*(.+))?$/i);\n if (argsMatch) {\n let [h, s, l, a] = argsMatch.slice(1);\n [s, l] = [s, l].map(v => v.endsWith('%') ? v : `${parseFloat(v) * 100}%`);\n return `\"hsl${typeof a === 'string' ? 'a' : ''}(${[h, s, l, a].filter(Boolean).join(',')})\"`;\n }\n return match;\n });\n}\n\n/**\n * Migrate a Mapbox/MapLibre GL Style to the latest version.\n *\n * @param style - a MapLibre Style\n * @returns a migrated style\n * @example\n * const fs = require('fs');\n * const migrate = require('@maplibre/maplibre-gl-style-spec').migrate;\n * const style = fs.readFileSync('./style.json', 'utf8');\n * fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));\n */\nfunction migrate(style) {\n let migrated = false;\n if (style.version === 7) {\n style = migrateV8(style);\n migrated = true;\n }\n if (style.version === 8) {\n migrated = !!expressions(style);\n migrated = true;\n }\n eachProperty(style, { paint: true, layout: true }, ({ value, reference, set }) => {\n if (reference.type === 'color') {\n set(migrateColors(value));\n }\n });\n if (!migrated) {\n throw new Error(`Cannot migrate from ${style.version}`);\n }\n return style;\n}\n\nconst v8 = v8Spec;\nconst expression = {\n StyleExpression,\n StylePropertyFunction,\n ZoomConstantExpression,\n ZoomDependentExpression,\n createExpression,\n createPropertyExpression,\n isExpression,\n isExpressionFilter,\n isZoomExpression,\n normalizePropertyExpression,\n};\nconst styleFunction = {\n convertFunction,\n createFunction,\n isFunction: isFunction$1\n};\nconst visit = { eachLayer, eachProperty, eachSource };\n\nexport { Color, ColorType, CompoundExpression, EvaluationContext, FormatExpression, Formatted, FormattedSection, FormattedType, Interpolate, Literal, NullType, Padding, ParsingError, ProjectionDefinition, ProjectionDefinitionType, ResolvedImage, Step, StyleExpression, StylePropertyFunction, ValidationError, VariableAnchorOffsetCollection, ZoomConstantExpression, ZoomDependentExpression, classifyRings, convertFilter, convertFunction, createExpression, createFunction, createPropertyExpression, derefLayers, diff, emptyStyle, expression, expressions$1 as expressions, featureFilter, format, styleFunction as function, groupByLayout, interpolateFactory as interpolates, isExpression, isFunction$1 as isFunction, isZoomExpression, v8Spec as latest, migrate, normalizePropertyExpression, supportsPropertyExpression, typeToString as toString, typeOf, v8, validate, validateStyleMin, visit };\n//# sourceMappingURL=index.mjs.map\n","var fontWeights = {\n thin: 100,\n hairline: 100,\n 'ultra-light': 200,\n 'extra-light': 200,\n light: 300,\n book: 300,\n regular: 400,\n normal: 400,\n plain: 400,\n roman: 400,\n standard: 400,\n medium: 500,\n 'semi-bold': 600,\n 'demi-bold': 600,\n bold: 700,\n 'extra-bold': 800,\n 'ultra-bold': 800,\n heavy: 900,\n black: 900,\n 'heavy-black': 900,\n fat: 900,\n poster: 900,\n 'ultra-black': 950,\n 'extra-black': 950\n};\nvar sp = ' ';\nvar italicRE = /(italic|oblique)$/i;\n\nvar fontCache = {};\n\n/**\n * @param {string|Array} fonts Mapbox GL Style fontstack or single font, e.g. `['Open Sans Regular', 'Arial Unicode MS Regular']` or `'Open Sans Regular'`.\n * @param {number} size Font size in pixels.\n * @param {string|number} [lineHeight] Line height as css line-height.\n * @returns {string} CSS font definition, e.g. `'normal 400 16px/1.2 \"Open Sans\"'`.\n */\nexport default function(fonts, size, lineHeight) {\n var cssData = fontCache[fonts];\n if (!cssData) {\n if (!Array.isArray(fonts)) {\n fonts = [fonts];\n }\n var weight = 400;\n var style = 'normal';\n var fontFamilies = [];\n var haveWeight, haveStyle;\n for (var i = 0, ii = fonts.length; i < ii; ++i) {\n var font = fonts[i];\n var parts = font.split(' ');\n var maybeWeight = parts[parts.length - 1].toLowerCase();\n if (maybeWeight == 'normal' || maybeWeight == 'italic' || maybeWeight == 'oblique') {\n style = haveStyle ? style : maybeWeight;\n haveStyle = true;\n parts.pop();\n maybeWeight = parts[parts.length - 1].toLowerCase();\n } else if (italicRE.test(maybeWeight)) {\n maybeWeight = maybeWeight.replace(italicRE, '');\n style = haveStyle ? style : parts[parts.length - 1].replace(maybeWeight, '');\n haveStyle = true;\n }\n for (var w in fontWeights) {\n var previousPart = parts.length > 1 ? parts[parts.length - 2].toLowerCase() : '';\n if (maybeWeight == w || maybeWeight == w.replace('-', '') || previousPart + '-' + maybeWeight == w) {\n weight = haveWeight ? weight : fontWeights[w];\n parts.pop();\n if (previousPart && w.startsWith(previousPart)) {\n parts.pop();\n }\n break;\n }\n }\n if (!haveWeight && typeof maybeWeight == 'number') {\n weight = maybeWeight;\n haveWeight = true;\n }\n var fontFamily = parts.join(sp)\n .replace('Klokantech Noto Sans', 'Noto Sans');\n if (fontFamily.indexOf(sp) !== -1) {\n fontFamily = '\"' + fontFamily + '\"';\n }\n fontFamilies.push(fontFamily);\n }\n // CSS font property: font-style font-weight font-size/line-height font-family\n cssData = fontCache[fonts] = [style, weight, fontFamilies];\n }\n return cssData[0] + sp + cssData[1] + sp + size + 'px' + (lineHeight ? '/' + lineHeight : '') + sp + cssData[2];\n}\n","const mapboxBaseUrl = 'https://api.mapbox.com';\n\n/**\n * Gets the path from a mapbox:// URL.\n * @param {string} url The Mapbox URL.\n * @return {string} The path.\n * @private\n */\nexport function getMapboxPath(url) {\n const startsWith = 'mapbox://';\n if (url.indexOf(startsWith) !== 0) {\n return '';\n }\n return url.slice(startsWith.length);\n}\n\n/**\n * Turns mapbox:// sprite URLs into resolvable URLs.\n * @param {string} url The sprite URL.\n * @param {string} token The access token.\n * @param {string} styleUrl The style URL.\n * @return {string} A resolvable URL.\n * @private\n */\nexport function normalizeSpriteUrl(url, token, styleUrl) {\n const mapboxPath = getMapboxPath(url);\n if (!mapboxPath) {\n return decodeURI(new URL(url, styleUrl).href);\n }\n const startsWith = 'sprites/';\n if (mapboxPath.indexOf(startsWith) !== 0) {\n throw new Error(`unexpected sprites url: ${url}`);\n }\n const sprite = mapboxPath.slice(startsWith.length);\n\n return `${mapboxBaseUrl}/styles/v1/${sprite}/sprite?access_token=${token}`;\n}\n\n/**\n * Turns mapbox:// style URLs into resolvable URLs.\n * @param {string} url The style URL.\n * @param {string} token The access token.\n * @return {string} A resolvable URL.\n * @private\n */\nexport function normalizeStyleUrl(url, token) {\n const mapboxPath = getMapboxPath(url);\n if (!mapboxPath) {\n return decodeURI(new URL(url, location.href).href);\n }\n const startsWith = 'styles/';\n if (mapboxPath.indexOf(startsWith) !== 0) {\n throw new Error(`unexpected style url: ${url}`);\n }\n const style = mapboxPath.slice(startsWith.length);\n\n return `${mapboxBaseUrl}/styles/v1/${style}?&access_token=${token}`;\n}\n\nconst mapboxSubdomains = ['a', 'b', 'c', 'd'];\n\n/**\n * Turns mapbox:// source URLs into vector tile URL templates.\n * @param {string} url The source URL.\n * @param {string} token The access token.\n * @param {string} tokenParam The access token key.\n * @param {string} styleUrl The style URL.\n * @return {Array} A vector tile template.\n * @private\n */\nexport function normalizeSourceUrl(url, token, tokenParam, styleUrl) {\n const urlObject = new URL(url, styleUrl);\n const mapboxPath = getMapboxPath(url);\n if (!mapboxPath) {\n if (!token) {\n return [decodeURI(urlObject.href)];\n }\n if (!urlObject.searchParams.has(tokenParam)) {\n urlObject.searchParams.set(tokenParam, token);\n }\n return [decodeURI(urlObject.href)];\n }\n\n if (mapboxPath === 'mapbox.satellite') {\n const sizeFactor = window.devicePixelRatio >= 1.5 ? '@2x' : '';\n return [\n `https://api.mapbox.com/v4/${mapboxPath}/{z}/{x}/{y}${sizeFactor}.webp?access_token=${token}`,\n ];\n }\n return mapboxSubdomains.map(\n (sub) =>\n `https://${sub}.tiles.mapbox.com/v4/${mapboxPath}/{z}/{x}/{y}.vector.pbf?access_token=${token}`,\n );\n}\n","import {VectorTile} from 'ol';\nimport TileState from 'ol/TileState.js';\nimport {toPromise} from 'ol/functions.js';\nimport {getUid} from 'ol/util.js';\nimport {normalizeSourceUrl, normalizeStyleUrl} from './mapbox.js';\n\n/** @typedef {'Style'|'Source'|'Sprite'|'SpriteImage'|'Tiles'|'GeoJSON'} ResourceType */\n\n/** @typedef {import(\"ol\").Map} Map */\n/** @typedef {import(\"ol/layer\").Layer} Layer */\n/** @typedef {import(\"ol/layer\").Group} LayerGroup */\n/** @typedef {import(\"ol/layer\").Vector} VectorLayer */\n/** @typedef {import(\"ol/layer\").VectorTile} VectorTileLayer */\n/** @typedef {import(\"ol/source\").Source} Source */\n\nconst functionCacheByStyleId = {};\nconst filterCacheByStyleId = {};\n\nlet styleId = 0;\nexport function getStyleId(glStyle) {\n if (!glStyle.id) {\n glStyle.id = styleId++;\n }\n return glStyle.id;\n}\n\nexport function getStyleFunctionKey(glStyle, olLayer) {\n return getStyleId(glStyle) + '.' + getUid(olLayer);\n}\n\n/**\n * @param {Object} glStyle Mapboox style object.\n * @return {Object} Function cache.\n */\nexport function getFunctionCache(glStyle) {\n let functionCache = functionCacheByStyleId[glStyle.id];\n if (!functionCache) {\n functionCache = {};\n functionCacheByStyleId[getStyleId(glStyle)] = functionCache;\n }\n return functionCache;\n}\n\nexport function clearFunctionCache() {\n for (const key in functionCacheByStyleId) {\n delete functionCacheByStyleId[key];\n }\n}\n\n/**\n * @param {Object} glStyle Mapboox style object.\n * @return {Object} Filter cache.\n */\nexport function getFilterCache(glStyle) {\n let filterCache = filterCacheByStyleId[glStyle.id];\n if (!filterCache) {\n filterCache = {};\n filterCacheByStyleId[getStyleId(glStyle)] = filterCache;\n }\n return filterCache;\n}\n\nexport function deg2rad(degrees) {\n return (degrees * Math.PI) / 180;\n}\n\nexport const defaultResolutions = (function () {\n const resolutions = [];\n for (let res = 78271.51696402048; resolutions.length <= 24; res /= 2) {\n resolutions.push(res);\n }\n return resolutions;\n})();\n\n/**\n * @param {number} width Width of the canvas.\n * @param {number} height Height of the canvas.\n * @return {HTMLCanvasElement} Canvas.\n */\nexport function createCanvas(width, height) {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope && typeof OffscreenCanvas !== 'undefined') { // eslint-disable-line\n return /** @type {?} */ (new OffscreenCanvas(width, height));\n }\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n}\n\nexport function getZoomForResolution(resolution, resolutions) {\n let i = 0;\n const ii = resolutions.length;\n for (; i < ii; ++i) {\n const candidate = resolutions[i];\n if (candidate < resolution && i + 1 < ii) {\n const zoomFactor = resolutions[i] / resolutions[i + 1];\n return i + Math.log(resolutions[i] / resolution) / Math.log(zoomFactor);\n }\n }\n return ii - 1;\n}\n\nexport function getResolutionForZoom(zoom, resolutions) {\n const base = Math.floor(zoom);\n const factor = Math.pow(2, zoom - base);\n return resolutions[base] / factor;\n}\n\nconst pendingRequests = {};\n/**\n * @param {ResourceType} resourceType Type of resource to load.\n * @param {string} url Url of the resource.\n * @param {Options} [options] Options.\n * @param {{request?: Request}} [metadata] Object to be filled with the request.\n * @return {Promise} Promise that resolves with the loaded resource\n * or rejects with the Response object.\n * @private\n */\nexport function fetchResource(resourceType, url, options = {}, metadata) {\n if (url in pendingRequests) {\n if (metadata) {\n metadata.request = pendingRequests[url][0];\n }\n return pendingRequests[url][1];\n }\n const transformedRequest = options.transformRequest\n ? options.transformRequest(url, resourceType) || url\n : url;\n const pendingRequest = toPromise(() => transformedRequest).then(\n (transformedRequest) => {\n if (!(transformedRequest instanceof Request)) {\n transformedRequest = new Request(transformedRequest);\n }\n if (!transformedRequest.headers.get('Accept')) {\n transformedRequest.headers.set('Accept', 'application/json');\n }\n if (metadata) {\n metadata.request = transformedRequest;\n }\n return fetch(transformedRequest)\n .then(function (response) {\n delete pendingRequests[url];\n return response.ok\n ? response.json()\n : Promise.reject(new Error('Error fetching source ' + url));\n })\n .catch(function (error) {\n delete pendingRequests[url];\n return Promise.reject(new Error('Error fetching source ' + url));\n });\n },\n );\n pendingRequests[url] = [transformedRequest, pendingRequest];\n return pendingRequest;\n}\n\nexport function getGlStyle(glStyleOrUrl, options) {\n if (typeof glStyleOrUrl === 'string') {\n if (glStyleOrUrl.trim().startsWith('{')) {\n try {\n const glStyle = JSON.parse(glStyleOrUrl);\n return Promise.resolve(glStyle);\n } catch (error) {\n return Promise.reject(error);\n }\n } else {\n glStyleOrUrl = normalizeStyleUrl(glStyleOrUrl, options.accessToken);\n return fetchResource('Style', glStyleOrUrl, options);\n }\n } else {\n return Promise.resolve(glStyleOrUrl);\n }\n}\n\nconst tilejsonCache = {};\n/**\n * @param {Object} glSource glStyle source object.\n * @param {string} styleUrl Style URL.\n * @param {Options} options Options.\n * @return {Promise<{tileJson: Object, tileLoadFunction: import('ol/Tile.js').LoadFunction}?>} TileJson and load function\n */\nexport function getTileJson(glSource, styleUrl, options = {}) {\n const cacheKey = [styleUrl, JSON.stringify(glSource)].toString();\n let promise = tilejsonCache[cacheKey];\n if (!promise || options.transformRequest) {\n let tileLoadFunction;\n if (options.transformRequest) {\n tileLoadFunction = (tile, src) => {\n const transformedRequest = options.transformRequest\n ? options.transformRequest(src, 'Tiles') || src\n : src;\n if (tile instanceof VectorTile) {\n tile.setLoader((extent, resolution, projection) => {\n toPromise(() => transformedRequest).then((transformedRequest) => {\n fetch(transformedRequest)\n .then((response) => response.arrayBuffer())\n .then((data) => {\n const format = tile.getFormat();\n const features = format.readFeatures(data, {\n extent: extent,\n featureProjection: projection,\n });\n // @ts-ignore\n tile.setFeatures(features);\n })\n .catch((e) => tile.setState(TileState.ERROR));\n });\n });\n } else {\n const img = tile.getImage();\n toPromise(() => transformedRequest).then((transformedRequest) => {\n if (transformedRequest instanceof Request) {\n fetch(transformedRequest)\n .then((response) => response.blob())\n .then((blob) => {\n const url = URL.createObjectURL(blob);\n img.addEventListener('load', () => URL.revokeObjectURL(url));\n img.addEventListener('error', () => URL.revokeObjectURL(url));\n img.src = url;\n })\n .catch((e) => tile.setState(TileState.ERROR));\n } else {\n img.src = transformedRequest;\n }\n });\n }\n };\n }\n const url = glSource.url;\n if (url && !glSource.tiles) {\n const normalizedSourceUrl = normalizeSourceUrl(\n url,\n options.accessToken,\n options.accessTokenParam || 'access_token',\n styleUrl || location.href,\n );\n if (url.startsWith('mapbox://')) {\n promise = Promise.resolve({\n tileJson: Object.assign({}, glSource, {\n url: undefined,\n tiles: normalizedSourceUrl,\n }),\n tileLoadFunction,\n });\n } else {\n const metadata = {};\n promise = fetchResource(\n 'Source',\n normalizedSourceUrl[0],\n options,\n metadata,\n ).then(function (tileJson) {\n tileJson.tiles = tileJson.tiles.map(function (tileUrl) {\n if (tileJson.scheme === 'tms') {\n tileUrl = tileUrl.replace('{y}', '{-y}');\n }\n return normalizeSourceUrl(\n tileUrl,\n options.accessToken,\n options.accessTokenParam || 'access_token',\n metadata.request.url,\n )[0];\n });\n return Promise.resolve({tileJson, tileLoadFunction});\n });\n }\n } else {\n glSource = Object.assign({}, glSource, {\n tiles: glSource.tiles.map(function (tileUrl) {\n if (glSource.scheme === 'tms') {\n tileUrl = tileUrl.replace('{y}', '{-y}');\n }\n return normalizeSourceUrl(\n tileUrl,\n options.accessToken,\n options.accessTokenParam || 'access_token',\n styleUrl || location.href,\n )[0];\n }),\n });\n promise = Promise.resolve({\n tileJson: Object.assign({}, glSource),\n tileLoadFunction,\n });\n }\n tilejsonCache[cacheKey] = promise;\n }\n return promise;\n}\n\n/**\n * @param {HTMLImageElement|HTMLCanvasElement} spriteImage Sprite image id.\n * @param {{x: number, y: number, width: number, height: number, pixelRatio: number}} spriteImageData Sprite image data.\n * @param {number} haloWidth Halo width.\n * @param {{r: number, g: number, b: number, a: number}} haloColor Halo color.\n * @return {HTMLCanvasElement} Canvas element with the halo.\n */\nexport function drawIconHalo(\n spriteImage,\n spriteImageData,\n haloWidth,\n haloColor,\n) {\n const imgSize = [\n 2 * haloWidth * spriteImageData.pixelRatio + spriteImageData.width,\n 2 * haloWidth * spriteImageData.pixelRatio + spriteImageData.height,\n ];\n const imageCanvas = createCanvas(imgSize[0], imgSize[1]);\n const imageContext = imageCanvas.getContext('2d');\n imageContext.drawImage(\n spriteImage,\n spriteImageData.x,\n spriteImageData.y,\n spriteImageData.width,\n spriteImageData.height,\n haloWidth * spriteImageData.pixelRatio,\n haloWidth * spriteImageData.pixelRatio,\n spriteImageData.width,\n spriteImageData.height,\n );\n const imageData = imageContext.getImageData(0, 0, imgSize[0], imgSize[1]);\n imageContext.globalCompositeOperation = 'destination-over';\n imageContext.fillStyle = `rgba(${haloColor.r * 255},${haloColor.g * 255},${\n haloColor.b * 255\n },${haloColor.a})`;\n const data = imageData.data;\n for (let i = 0, ii = imageData.width; i < ii; ++i) {\n for (let j = 0, jj = imageData.height; j < jj; ++j) {\n const index = (j * ii + i) * 4;\n const alpha = data[index + 3];\n if (alpha > 0) {\n imageContext.arc(\n i,\n j,\n haloWidth * spriteImageData.pixelRatio,\n 0,\n 2 * Math.PI,\n );\n }\n }\n }\n imageContext.fill();\n return imageCanvas;\n}\n\nfunction smoothstep(min, max, value) {\n const x = Math.max(0, Math.min(1, (value - min) / (max - min)));\n return x * x * (3 - 2 * x);\n}\n\n/**\n * @param {HTMLImageElement} image SDF image\n * @param {{x: number, y: number, width: number, height: number}} area Area to unSDF\n * @param {{r: number, g: number, b: number, a: number}} color Color to use\n * @return {HTMLCanvasElement} Regular image\n */\nexport function drawSDF(image, area, color) {\n const imageCanvas = createCanvas(area.width, area.height);\n const imageContext = imageCanvas.getContext('2d');\n imageContext.drawImage(\n image,\n area.x,\n area.y,\n area.width,\n area.height,\n 0,\n 0,\n area.width,\n area.height,\n );\n const imageData = imageContext.getImageData(0, 0, area.width, area.height);\n const data = imageData.data;\n for (let i = 0, ii = imageData.width; i < ii; ++i) {\n for (let j = 0, jj = imageData.height; j < jj; ++j) {\n const index = (j * ii + i) * 4;\n const dist = data[index + 3] / 255;\n\n const buffer = 0.75;\n const gamma = 0.1;\n\n const alpha = smoothstep(buffer - gamma, buffer + gamma, dist);\n if (alpha > 0) {\n data[index + 0] = Math.round(255 * color.r * alpha);\n data[index + 1] = Math.round(255 * color.g * alpha);\n data[index + 2] = Math.round(255 * color.b * alpha);\n data[index + 3] = Math.round(255 * alpha);\n } else {\n data[index + 3] = 0;\n }\n }\n }\n imageContext.putImageData(imageData, 0, 0);\n return imageCanvas;\n}\n\n/**\n * @typedef {import(\"./apply.js\").Options} Options\n * @private\n */\n","import mb2css from 'mapbox-to-css-font';\nimport {checkedFonts, registerFont} from 'ol/render/canvas.js';\nimport {createCanvas} from './util.js';\n\nconst hairSpacePool = Array(256).join('\\u200A');\nexport function applyLetterSpacing(text, letterSpacing) {\n if (letterSpacing >= 0.05) {\n let textWithLetterSpacing = '';\n const lines = text.split('\\n');\n const joinSpaceString = hairSpacePool.slice(\n 0,\n Math.round(letterSpacing / 0.1),\n );\n for (let l = 0, ll = lines.length; l < ll; ++l) {\n if (l > 0) {\n textWithLetterSpacing += '\\n';\n }\n textWithLetterSpacing += lines[l].split('').join(joinSpaceString);\n }\n return textWithLetterSpacing;\n }\n return text;\n}\n\nlet measureContext;\nfunction getMeasureContext() {\n if (!measureContext) {\n measureContext = createCanvas(1, 1).getContext('2d');\n }\n return measureContext;\n}\n\nfunction measureText(text, letterSpacing) {\n return (\n getMeasureContext().measureText(text).width +\n (text.length - 1) * letterSpacing\n );\n}\n\nconst measureCache = {};\nexport function wrapText(text, font, em, letterSpacing) {\n if (text.indexOf('\\n') !== -1) {\n const hardLines = text.split('\\n');\n const lines = [];\n for (let i = 0, ii = hardLines.length; i < ii; ++i) {\n lines.push(wrapText(hardLines[i], font, em, letterSpacing));\n }\n return lines.join('\\n');\n }\n const key = em + ',' + font + ',' + text + ',' + letterSpacing;\n let wrappedText = measureCache[key];\n if (!wrappedText) {\n const words = text.split(' ');\n if (words.length > 1) {\n const ctx = getMeasureContext();\n ctx.font = font;\n const oneEm = ctx.measureText('M').width;\n const maxWidth = oneEm * em;\n let line = '';\n const lines = [];\n // Pass 1 - wrap lines to not exceed maxWidth\n for (let i = 0, ii = words.length; i < ii; ++i) {\n const word = words[i];\n const testLine = line + (line ? ' ' : '') + word;\n if (measureText(testLine, letterSpacing) <= maxWidth) {\n line = testLine;\n } else {\n if (line) {\n lines.push(line);\n }\n line = word;\n }\n }\n if (line) {\n lines.push(line);\n }\n // Pass 2 - add lines with a width of less than 30% of maxWidth to the previous or next line\n for (let i = 0, ii = lines.length; i < ii && ii > 1; ++i) {\n const line = lines[i];\n if (measureText(line, letterSpacing) < maxWidth * 0.35) {\n const prevWidth =\n i > 0 ? measureText(lines[i - 1], letterSpacing) : Infinity;\n const nextWidth =\n i < ii - 1 ? measureText(lines[i + 1], letterSpacing) : Infinity;\n lines.splice(i, 1);\n ii -= 1;\n if (prevWidth < nextWidth) {\n lines[i - 1] += ' ' + line;\n i -= 1;\n } else {\n lines[i] = line + ' ' + lines[i];\n }\n }\n }\n // Pass 3 - try to fill 80% of maxWidth for each line\n for (let i = 0, ii = lines.length - 1; i < ii; ++i) {\n const line = lines[i];\n const next = lines[i + 1];\n if (\n measureText(line, letterSpacing) > maxWidth * 0.7 &&\n measureText(next, letterSpacing) < maxWidth * 0.6\n ) {\n const lineWords = line.split(' ');\n const lastWord = lineWords.pop();\n if (measureText(lastWord, letterSpacing) < maxWidth * 0.2) {\n lines[i] = lineWords.join(' ');\n lines[i + 1] = lastWord + ' ' + next;\n }\n ii -= 1;\n }\n }\n wrappedText = lines.join('\\n');\n } else {\n wrappedText = text;\n }\n wrappedText = applyLetterSpacing(wrappedText, letterSpacing);\n measureCache[key] = wrappedText;\n }\n return wrappedText;\n}\n\nconst fontFamilyRegEx = /font-family: ?([^;]*);/;\nconst stripQuotesRegEx = /(\"|')/g;\nlet loadedFontFamilies;\nfunction hasFontFamily(family) {\n if (!loadedFontFamilies) {\n loadedFontFamilies = {};\n const styleSheets = document.styleSheets;\n for (let i = 0, ii = styleSheets.length; i < ii; ++i) {\n const styleSheet = /** @type {CSSStyleSheet} */ (styleSheets[i]);\n try {\n const cssRules = styleSheet.rules || styleSheet.cssRules;\n if (cssRules) {\n for (let j = 0, jj = cssRules.length; j < jj; ++j) {\n const cssRule = cssRules[j];\n if (cssRule.type == 5) {\n const match = cssRule.cssText.match(fontFamilyRegEx);\n loadedFontFamilies[match[1].replace(stripQuotesRegEx, '')] = true;\n }\n }\n }\n } catch {\n // empty catch block\n }\n }\n }\n return family in loadedFontFamilies;\n}\n\nconst processedFontFamilies = {};\n\n/**\n * @param {Array} fonts Fonts.\n * @param {string} [templateUrl] Template URL.\n * @return {Array} Processed fonts.\n * @private\n */\nexport function getFonts(\n fonts,\n templateUrl = 'https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css',\n) {\n const fontsKey = fonts.toString();\n if (fontsKey in processedFontFamilies) {\n return processedFontFamilies[fontsKey];\n }\n const fontDescriptions = [];\n for (let i = 0, ii = fonts.length; i < ii; ++i) {\n fonts[i] = fonts[i].replace('Arial Unicode MS', 'Arial');\n const font = fonts[i];\n const cssFont = mb2css(font, 1);\n registerFont(cssFont);\n const parts = cssFont.split(' ');\n fontDescriptions.push([\n parts.slice(3).join(' ').replace(/\"/g, ''),\n parts[1],\n parts[0],\n ]);\n }\n for (let i = 0, ii = fontDescriptions.length; i < ii; ++i) {\n const fontDescription = fontDescriptions[i];\n const family = fontDescription[0];\n if (!hasFontFamily(family)) {\n if (\n checkedFonts.get(\n `${fontDescription[2]}\\n${fontDescription[1]} \\n${family}`,\n ) !== 100\n ) {\n const fontUrl = templateUrl\n .replace('{font-family}', family.replace(/ /g, '-').toLowerCase())\n .replace('{Font+Family}', family.replace(/ /g, '+'))\n .replace('{fontweight}', fontDescription[1])\n .replace(\n '{-fontstyle}',\n fontDescription[2].replace('normal', '').replace(/(.+)/, '-$1'),\n )\n .replace('{fontstyle}', fontDescription[2]);\n if (!document.querySelector('link[href=\"' + fontUrl + '\"]')) {\n const markup = document.createElement('link');\n markup.href = fontUrl;\n markup.rel = 'stylesheet';\n document.head.appendChild(markup);\n }\n }\n }\n }\n processedFontFamilies[fontsKey] = fonts;\n return fonts;\n}\n","/*\nol-mapbox-style - Use Mapbox/MapLibre Style objects with OpenLayers\nCopyright 2016-present ol-mapbox-style contributors\nLicense: https://raw.githubusercontent.com/openlayers/ol-mapbox-style/master/LICENSE\n*/\n\nimport {\n Color,\n convertFunction,\n createPropertyExpression,\n derefLayers,\n featureFilter as createFilter,\n isExpression,\n isFunction,\n v8 as spec,\n} from '@maplibre/maplibre-gl-style-spec';\nimport mb2css from 'mapbox-to-css-font';\nimport {toPromise} from 'ol/functions.js';\nimport RenderFeature from 'ol/render/Feature.js';\nimport Circle from 'ol/style/Circle.js';\nimport Fill from 'ol/style/Fill.js';\nimport Icon from 'ol/style/Icon.js';\nimport Stroke from 'ol/style/Stroke.js';\nimport Style from 'ol/style/Style.js';\nimport Text from 'ol/style/Text.js';\n\nimport {applyLetterSpacing, wrapText} from './text.js';\nimport {\n clearFunctionCache,\n createCanvas,\n defaultResolutions,\n deg2rad,\n drawIconHalo,\n drawSDF,\n getFilterCache,\n getFunctionCache,\n getStyleFunctionKey,\n getZoomForResolution,\n} from './util.js';\n\n/**\n * @typedef {import(\"ol/layer/Vector\").default} VectorLayer\n * @typedef {import(\"ol/layer/VectorTile\").default} VectorTileLayer\n * @typedef {import(\"ol/style/Style\").StyleFunction} StyleFunction\n * @typedef {import('./util.js').ResourceType} ResourceType\n */\n\nconst types = {\n 'Point': 1,\n 'MultiPoint': 1,\n 'LineString': 2,\n 'MultiLineString': 2,\n 'Polygon': 3,\n 'MultiPolygon': 3,\n};\nconst anchor = {\n 'center': [0.5, 0.5],\n 'left': [0, 0.5],\n 'right': [1, 0.5],\n 'top': [0.5, 0],\n 'bottom': [0.5, 1],\n 'top-left': [0, 0],\n 'top-right': [1, 0],\n 'bottom-left': [0, 1],\n 'bottom-right': [1, 1],\n};\n\nconst expressionData = function (rawExpression, propertySpec) {\n const compiledExpression = createPropertyExpression(\n rawExpression,\n propertySpec,\n );\n if (compiledExpression.result === 'error') {\n throw new Error(\n compiledExpression.value\n .map((err) => `${err.key}: ${err.message}`)\n .join(', '),\n );\n }\n return compiledExpression.value;\n};\n\nconst emptyObj = {};\nconst zoomObj = {zoom: 0};\nlet renderFeatureCoordinates, renderFeature;\n\n/**\n * @private\n * @param {Object} layer Gl object layer.\n * @param {string} layoutOrPaint 'layout' or 'paint'.\n * @param {string} property Feature property.\n * @param {number} zoom Zoom.\n * @param {Object} feature Gl feature.\n * @param {Object} [functionCache] Function cache.\n * @param {Object} [featureState] Feature state.\n * @return {?} Value.\n */\nexport function getValue(\n layer,\n layoutOrPaint,\n property,\n zoom,\n feature,\n functionCache,\n featureState,\n) {\n const layerId = layer.id;\n if (!functionCache) {\n functionCache = {};\n console.warn('No functionCache provided to getValue()'); //eslint-disable-line no-console\n }\n if (!functionCache[layerId]) {\n functionCache[layerId] = {};\n }\n const functions = functionCache[layerId];\n if (!functions[property]) {\n let value = (layer[layoutOrPaint] || emptyObj)[property];\n const propertySpec = spec[`${layoutOrPaint}_${layer.type}`][property];\n if (value === undefined) {\n value = propertySpec.default;\n }\n let isExpr = isExpression(value);\n if (!isExpr && isFunction(value)) {\n value = convertFunction(value, propertySpec);\n isExpr = true;\n }\n if (isExpr) {\n const compiledExpression = expressionData(value, propertySpec);\n functions[property] =\n compiledExpression.evaluate.bind(compiledExpression);\n } else {\n if (propertySpec.type == 'color') {\n value = Color.parse(value);\n }\n functions[property] = function () {\n return value;\n };\n }\n }\n zoomObj.zoom = zoom;\n return functions[property](zoomObj, feature, featureState);\n}\n\n/**\n * @private\n * @param {Object} layer Gl object layer.\n * @param {number} zoom Zoom.\n * @param {Object} feature Gl feature.\n * @param {\"icon\"|\"text\"} prefix Style property prefix.\n * @param {Object} [functionCache] Function cache.\n * @return {\"declutter\"|\"obstacle\"|\"none\"} Value.\n */\nfunction getDeclutterMode(layer, zoom, feature, prefix, functionCache) {\n const allowOverlap = getValue(\n layer,\n 'layout',\n `${prefix}-allow-overlap`,\n zoom,\n feature,\n functionCache,\n );\n if (!allowOverlap) {\n return 'declutter';\n }\n const ignorePlacement = getValue(\n layer,\n 'layout',\n `${prefix}-ignore-placement`,\n zoom,\n feature,\n functionCache,\n );\n if (!ignorePlacement) {\n return 'obstacle';\n }\n return 'none';\n}\n\n/**\n * @private\n * @param {string} layerId Layer id.\n * @param {?} filter Filter.\n * @param {Object} feature Feature.\n * @param {number} zoom Zoom.\n * @param {Object} [filterCache] Filter cache.\n * @return {boolean} Filter result.\n */\nfunction evaluateFilter(layerId, filter, feature, zoom, filterCache) {\n if (!filterCache) {\n console.warn('No filterCache provided to evaluateFilter()'); //eslint-disable-line no-console\n }\n if (!(layerId in filterCache)) {\n filterCache[layerId] = createFilter(filter).filter;\n }\n zoomObj.zoom = zoom;\n return filterCache[layerId](zoomObj, feature);\n}\n\nlet renderTransparentEnabled = false;\n\n/**\n * Configure whether features with a transparent style should be rendered. When\n * set to `true`, it will be possible to hit detect content that is not visible,\n * like transparent fills of polygons, using `ol/layer/Layer#getFeatures()` or\n * `ol/Map#getFeaturesAtPixel()`\n * @param {boolean} enabled Rendering of transparent elements is enabled.\n * Default is `false`.\n */\nexport function renderTransparent(enabled) {\n if (enabled !== renderTransparentEnabled) {\n clearFunctionCache();\n renderTransparentEnabled = enabled;\n }\n}\n\n/**\n * @private\n * @param {?} color Color.\n * @param {number} [opacity] Opacity.\n * @return {string} Color.\n */\nfunction colorWithOpacity(color, opacity) {\n if (color) {\n if (!renderTransparentEnabled && (color.a === 0 || opacity === 0)) {\n return undefined;\n }\n const a = color.a;\n opacity = opacity === undefined ? 1 : opacity;\n return a === 0\n ? 'transparent'\n : 'rgba(' +\n Math.round((color.r * 255) / a) +\n ',' +\n Math.round((color.g * 255) / a) +\n ',' +\n Math.round((color.b * 255) / a) +\n ',' +\n a * opacity +\n ')';\n }\n return color;\n}\n\nconst templateRegEx = /\\{[^{}}]*\\}/g;\n\n/**\n * @private\n * @param {string} text Text.\n * @param {Object} properties Properties.\n * @return {string} Text.\n */\nfunction fromTemplate(text, properties) {\n return text.replace(templateRegEx, function (match) {\n return properties[match.slice(1, -1)] || '';\n });\n}\n\nlet recordLayer = false;\n\n/**\n * Turns recording of the Mapbox/MapLibre Style's `layer` on and off. When turned on,\n * the layer that a rendered feature belongs to will be set as the feature's\n * `mapbox-layer` property.\n * @param {boolean} record Recording of the style layer is on.\n */\nexport function recordStyleLayer(record = false) {\n recordLayer = record;\n}\n\nexport const styleFunctionArgs = {};\n\n/**\n * Creates a style function from the `glStyle` object for all layers that use\n * the specified `source`, which needs to be a `\"type\": \"vector\"` or\n * `\"type\": \"geojson\"` source and applies it to the specified OpenLayers layer.\n *\n * Two additional properties will be set on the provided layer:\n *\n * * `mapbox-source`: The `id` of the Mapbox/MapLibre Style document's source that the\n * OpenLayers layer was created from. Usually `apply()` creates one\n * OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has\n * layers from different sources in between.\n * * `mapbox-layers`: The `id`s of the Mapbox/MapLibre Style document's layers that are\n * included in the OpenLayers layer.\n *\n * This function also works in a web worker. In worker mode, the main thread needs\n * to listen to messages from the worker and respond with another message to make\n * sure that sprite image loading works:\n *\n * ```js\n * worker.addEventListener('message', event => {\n * if (event.data.action === 'loadImage') {\n * const image = new Image();\n * image.crossOrigin = 'anonymous';\n * image.addEventListener('load', function() {\n * createImageBitmap(image, 0, 0, image.width, image.height).then(imageBitmap => {\n * worker.postMessage({\n * action: 'imageLoaded',\n * image: imageBitmap,\n * src: event.data.src\n * }, [imageBitmap]);\n * });\n * });\n * image.src = event.data.src;\n * }\n * });\n * ```\n *\n * @param {VectorLayer|VectorTileLayer} olLayer OpenLayers layer to\n * apply the style to. In addition to the style, the layer will get two\n * properties: `mapbox-source` will be the `id` of the `glStyle`'s source used\n * for the layer, and `mapbox-layers` will be an array of the `id`s of the\n * `glStyle`'s layers.\n * @param {string|Object} glStyle Mapbox/MapLibre Style object.\n * @param {string|Array} sourceOrLayers `source` key or an array of layer `id`s\n * from the Mapbox/MapLibre Style object. When a `source` key is provided, all layers for\n * the specified source will be included in the style function. When layer `id`s\n * are provided, they must be from layers that use the same source.\n * @param {Array} resolutions\n * Resolutions for mapping resolution to zoom level.\n * @param {Object} spriteData Sprite data from the url specified in\n * the Mapbox/MapLibre Style object's `sprite` property. Only required if a `sprite`\n * property is specified in the Mapbox/MapLibre Style object.\n * @param {string|Request|Promise} spriteImageUrl Sprite image url for the sprite\n * specified in the Mapbox/MapLibre Style object's `sprite` property. Only required if a\n * `sprite` property is specified in the Mapbox/MapLibre Style object.\n * @param {function(Array, string=):Array} getFonts Function that\n * receives a font stack and the url template from the GL style's `metadata['ol:webfonts']`\n * property (if set) as arguments, and returns a (modified) font stack that\n * is available. Font names are the names used in the Mapbox/MapLibre Style object. If\n * not provided, the font stack will be used as-is. This function can also be\n * used for loading web fonts.\n * @param {function(VectorLayer|VectorTileLayer, string):HTMLImageElement|HTMLCanvasElement|string|undefined} [getImage]\n * Function that returns an image or a URL for an image name. If the result is an HTMLImageElement, it must already be\n * loaded. The layer can be used to call layer.changed() when the loading and processing of the image has finished.\n * This function can be used for icons not in the sprite or to override sprite icons.\n * @return {StyleFunction} Style function for use in\n * `ol.layer.Vector` or `ol.layer.VectorTile`.\n */\nexport function stylefunction(\n olLayer,\n glStyle,\n sourceOrLayers,\n resolutions = defaultResolutions,\n spriteData = undefined,\n spriteImageUrl = undefined,\n getFonts = undefined,\n getImage = undefined,\n) {\n if (typeof glStyle == 'string') {\n glStyle = JSON.parse(glStyle);\n }\n if (glStyle.version != 8) {\n throw new Error('glStyle version 8 required.');\n }\n styleFunctionArgs[getStyleFunctionKey(glStyle, olLayer)] =\n Array.from(arguments);\n\n let spriteImage, spriteImageSize;\n let spriteImageUnSDFed;\n\n if (spriteImageUrl) {\n if (typeof Image !== 'undefined') {\n const img = new Image();\n let blobUrl;\n toPromise(() => spriteImageUrl).then((spriteImageUrl) => {\n if (spriteImageUrl instanceof Request) {\n fetch(spriteImageUrl)\n .then((response) => response.blob())\n .then((blob) => {\n blobUrl = URL.createObjectURL(blob);\n img.src = blobUrl;\n })\n .catch(() => {});\n } else {\n img.crossOrigin = 'anonymous';\n img.src = spriteImageUrl;\n if (blobUrl) {\n URL.revokeObjectURL(blobUrl);\n }\n }\n });\n img.onload = function () {\n spriteImage = img;\n spriteImageSize = [img.width, img.height];\n olLayer.changed();\n img.onload = null;\n };\n } else if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { //eslint-disable-line\n const worker = /** @type {*} */ (self);\n // Main thread needs to handle 'loadImage' and dispatch 'imageLoaded'\n worker.postMessage({\n action: 'loadImage',\n src: spriteImageUrl,\n });\n worker.addEventListener('message', function handler(event) {\n if (\n event.data.action === 'imageLoaded' &&\n event.data.src === spriteImageUrl\n ) {\n spriteImage = event.data.image;\n spriteImageSize = [spriteImage.width, spriteImage.height];\n }\n });\n }\n }\n\n const allLayers = derefLayers(glStyle.layers);\n\n const layersBySourceLayer = {};\n const mapboxLayers = [];\n\n const iconImageCache = {};\n const patternCache = {};\n const functionCache = getFunctionCache(glStyle);\n const filterCache = getFilterCache(glStyle);\n\n let mapboxSource;\n for (let i = 0, ii = allLayers.length; i < ii; ++i) {\n const layer = allLayers[i];\n const layerId = layer.id;\n if (\n (typeof sourceOrLayers == 'string' && layer.source == sourceOrLayers) ||\n (Array.isArray(sourceOrLayers) && sourceOrLayers.indexOf(layerId) !== -1)\n ) {\n const sourceLayer = layer['source-layer'];\n if (!mapboxSource) {\n mapboxSource = layer.source;\n const source = glStyle.sources[mapboxSource];\n if (!source) {\n throw new Error(`Source \"${mapboxSource}\" is not defined`);\n }\n const type = source.type;\n if (type !== 'vector' && type !== 'geojson') {\n throw new Error(\n `Source \"${mapboxSource}\" is not of type \"vector\" or \"geojson\", but \"${type}\"`,\n );\n }\n } else if (layer.source !== mapboxSource) {\n throw new Error(\n `Layer \"${layerId}\" does not use source \"${mapboxSource}`,\n );\n }\n let layers = layersBySourceLayer[sourceLayer];\n if (!layers) {\n layers = [];\n layersBySourceLayer[sourceLayer] = layers;\n }\n layers.push({\n layer: layer,\n index: i,\n });\n mapboxLayers.push(layerId);\n }\n }\n\n const textHalo = new Stroke();\n const textColor = new Fill();\n\n const styles = [];\n\n /**\n * @param {import(\"ol/Feature\").default|import(\"ol/render/Feature\").default} feature Feature.\n * @param {number} resolution Resolution.\n * @param {string} [onlyLayer] Calculate style for this layer only.\n * @return {Array} Style.\n */\n const styleFunction = function (feature, resolution, onlyLayer) {\n const properties = feature.getProperties();\n const layers = layersBySourceLayer[properties.layer];\n if (!layers) {\n return undefined;\n }\n let zoom = resolutions.indexOf(resolution);\n if (zoom == -1) {\n zoom = getZoomForResolution(resolution, resolutions);\n }\n const type = types[feature.getGeometry().getType()];\n const f = {\n id: feature.getId(),\n properties: properties,\n type: type,\n };\n const featureState = olLayer.get('mapbox-featurestate')[feature.getId()];\n let stylesLength = -1;\n let featureBelongsToLayer;\n for (let i = 0, ii = layers.length; i < ii; ++i) {\n const layerData = layers[i];\n const layer = layerData.layer;\n const layerId = layer.id;\n if (onlyLayer !== undefined && onlyLayer !== layerId) {\n continue;\n }\n\n const layout = layer.layout || emptyObj;\n const paint = layer.paint || emptyObj;\n if (\n layout.visibility === 'none' ||\n ('minzoom' in layer && zoom < layer.minzoom) ||\n ('maxzoom' in layer && zoom >= layer.maxzoom)\n ) {\n continue;\n }\n const filter = layer.filter;\n if (!filter || evaluateFilter(layerId, filter, f, zoom, filterCache)) {\n featureBelongsToLayer = layer;\n let color, opacity, fill, stroke, strokeColor, style;\n const index = layerData.index;\n if (\n type == 3 &&\n (layer.type == 'fill' || layer.type == 'fill-extrusion')\n ) {\n opacity = getValue(\n layer,\n 'paint',\n layer.type + '-opacity',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (layer.type + '-pattern' in paint) {\n const fillIcon = getValue(\n layer,\n 'paint',\n layer.type + '-pattern',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (fillIcon) {\n const icon =\n typeof fillIcon === 'string'\n ? fromTemplate(fillIcon, properties)\n : fillIcon.toString();\n if (spriteImage && spriteData && spriteData[icon]) {\n ++stylesLength;\n style = styles[stylesLength];\n if (\n !style ||\n !style.getFill() ||\n style.getStroke() ||\n style.getText()\n ) {\n style = new Style({\n fill: new Fill(),\n });\n styles[stylesLength] = style;\n }\n fill = style.getFill();\n style.setZIndex(index);\n const icon_cache_key = icon + '.' + opacity;\n let pattern = patternCache[icon_cache_key];\n if (!pattern) {\n const spriteImageData = spriteData[icon];\n const canvas = createCanvas(\n spriteImageData.width,\n spriteImageData.height,\n );\n const ctx = /** @type {CanvasRenderingContext2D} */ (\n canvas.getContext('2d')\n );\n ctx.globalAlpha = opacity;\n ctx.drawImage(\n spriteImage,\n spriteImageData.x,\n spriteImageData.y,\n spriteImageData.width,\n spriteImageData.height,\n 0,\n 0,\n spriteImageData.width,\n spriteImageData.height,\n );\n pattern = ctx.createPattern(canvas, 'repeat');\n patternCache[icon_cache_key] = pattern;\n }\n fill.setColor(pattern);\n }\n }\n } else {\n color = colorWithOpacity(\n getValue(\n layer,\n 'paint',\n layer.type + '-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n opacity,\n );\n if (layer.type + '-outline-color' in paint) {\n strokeColor = colorWithOpacity(\n getValue(\n layer,\n 'paint',\n layer.type + '-outline-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n opacity,\n );\n }\n if (!strokeColor) {\n strokeColor = color;\n }\n if (color || strokeColor) {\n ++stylesLength;\n style = styles[stylesLength];\n if (\n !style ||\n (color && !style.getFill()) ||\n (!color && style.getFill()) ||\n (strokeColor && !style.getStroke()) ||\n (!strokeColor && style.getStroke()) ||\n style.getText()\n ) {\n style = new Style({\n fill: color ? new Fill() : undefined,\n stroke: strokeColor ? new Stroke() : undefined,\n });\n styles[stylesLength] = style;\n }\n if (color) {\n fill = style.getFill();\n fill.setColor(color);\n }\n if (strokeColor) {\n stroke = style.getStroke();\n stroke.setColor(strokeColor);\n stroke.setWidth(0.5);\n }\n style.setZIndex(index);\n }\n }\n }\n if (type != 1 && layer.type == 'line') {\n if (!('line-pattern' in paint)) {\n color = colorWithOpacity(\n getValue(\n layer,\n 'paint',\n 'line-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n getValue(\n layer,\n 'paint',\n 'line-opacity',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n } else {\n color = undefined;\n }\n const width = getValue(\n layer,\n 'paint',\n 'line-width',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (color && width > 0) {\n ++stylesLength;\n style = styles[stylesLength];\n if (\n !style ||\n !style.getStroke() ||\n style.getFill() ||\n style.getText()\n ) {\n style = new Style({\n stroke: new Stroke(),\n });\n styles[stylesLength] = style;\n }\n stroke = style.getStroke();\n stroke.setLineCap(\n getValue(\n layer,\n 'layout',\n 'line-cap',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n stroke.setLineJoin(\n getValue(\n layer,\n 'layout',\n 'line-join',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n stroke.setMiterLimit(\n getValue(\n layer,\n 'layout',\n 'line-miter-limit',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n stroke.setColor(color);\n stroke.setWidth(width);\n stroke.setLineDash(\n paint['line-dasharray']\n ? getValue(\n layer,\n 'paint',\n 'line-dasharray',\n zoom,\n f,\n functionCache,\n featureState,\n ).map(function (x) {\n return x * width;\n })\n : null,\n );\n style.setZIndex(index);\n }\n }\n\n let hasImage = false;\n let text = null;\n let placementAngle = 0;\n let icon, iconImg, skipLabel;\n if ((type == 1 || type == 2) && 'icon-image' in layout) {\n const iconImage = getValue(\n layer,\n 'layout',\n 'icon-image',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (iconImage) {\n icon =\n typeof iconImage === 'string'\n ? fromTemplate(iconImage, properties)\n : iconImage.toString();\n let styleGeom = undefined;\n const imageElement = getImage ? getImage(olLayer, icon) : undefined;\n if (\n (spriteImage && spriteData && spriteData[icon]) ||\n imageElement\n ) {\n const iconRotationAlignment = getValue(\n layer,\n 'layout',\n 'icon-rotation-alignment',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (type == 2) {\n const geom = /** @type {*} */ (feature.getGeometry());\n // ol package and ol-debug.js only\n if (geom.getFlatMidpoint || geom.getFlatMidpoints) {\n const extent = geom.getExtent();\n const size = Math.sqrt(\n Math.max(\n Math.pow((extent[2] - extent[0]) / resolution, 2),\n Math.pow((extent[3] - extent[1]) / resolution, 2),\n ),\n );\n if (size > 150) {\n //FIXME Do not hard-code a size of 150\n const midpoint =\n geom.getType() === 'MultiLineString'\n ? geom.getFlatMidpoints()\n : geom.getFlatMidpoint();\n if (!renderFeature) {\n renderFeatureCoordinates = [NaN, NaN];\n renderFeature = new RenderFeature(\n 'Point',\n renderFeatureCoordinates,\n [],\n 2,\n {},\n undefined,\n );\n }\n styleGeom = renderFeature;\n renderFeatureCoordinates[0] = midpoint[0];\n renderFeatureCoordinates[1] = midpoint[1];\n const placement = getValue(\n layer,\n 'layout',\n 'symbol-placement',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (\n placement === 'line' &&\n iconRotationAlignment === 'map'\n ) {\n const stride = geom.getStride();\n const coordinates = geom.getFlatCoordinates();\n for (\n let i = 0, ii = coordinates.length - stride;\n i < ii;\n i += stride\n ) {\n const x1 = coordinates[i];\n const y1 = coordinates[i + 1];\n const x2 = coordinates[i + stride];\n const y2 = coordinates[i + stride + 1];\n const minX = Math.min(x1, x2);\n const maxX = Math.max(x1, x2);\n const xM = midpoint[0];\n const yM = midpoint[1];\n const dotProduct =\n (y2 - y1) * (xM - x1) - (x2 - x1) * (yM - y1);\n if (\n Math.abs(dotProduct) < 0.001 && //midpoint is aligned with the segment\n xM <= maxX &&\n xM >= minX //midpoint is on the segment and not outside it\n ) {\n placementAngle = Math.atan2(y1 - y2, x2 - x1);\n break;\n }\n }\n }\n }\n }\n }\n if (type !== 2 || styleGeom) {\n const iconSize = getValue(\n layer,\n 'layout',\n 'icon-size',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const iconColor =\n paint['icon-color'] !== undefined\n ? getValue(\n layer,\n 'paint',\n 'icon-color',\n zoom,\n f,\n functionCache,\n featureState,\n )\n : null;\n if (!iconColor || iconColor.a !== 0) {\n const haloColor = getValue(\n layer,\n 'paint',\n 'icon-halo-color',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const haloWidth = getValue(\n layer,\n 'paint',\n 'icon-halo-width',\n zoom,\n f,\n functionCache,\n featureState,\n );\n let iconCacheKey = `${icon}.${iconSize}.${haloWidth}.${haloColor}`;\n if (iconColor !== null) {\n iconCacheKey += `.${iconColor}`;\n }\n iconImg = iconImageCache[iconCacheKey];\n if (!iconImg) {\n const declutterMode = getDeclutterMode(\n layer,\n zoom,\n f,\n 'icon',\n functionCache,\n );\n let displacement;\n if ('icon-offset' in layout) {\n displacement = getValue(\n layer,\n 'layout',\n 'icon-offset',\n zoom,\n f,\n functionCache,\n featureState,\n ).slice(0);\n displacement[0] *= iconSize;\n displacement[1] *= -iconSize;\n }\n let color = iconColor\n ? [\n iconColor.r * 255,\n iconColor.g * 255,\n iconColor.b * 255,\n iconColor.a,\n ]\n : undefined;\n if (imageElement) {\n const iconOptions = {\n color: color,\n rotateWithView: iconRotationAlignment === 'map',\n displacement: displacement,\n declutterMode: declutterMode,\n scale: iconSize,\n };\n if (typeof imageElement === 'string') {\n // it is a src URL\n iconOptions.src = imageElement;\n } else {\n iconOptions.img = imageElement;\n iconOptions.imgSize = [\n imageElement.width,\n imageElement.height,\n ];\n }\n iconImg = new Icon(iconOptions);\n } else {\n const spriteImageData = spriteData[icon];\n let img, size, offset;\n if (haloWidth) {\n if (spriteImageData.sdf) {\n img = drawIconHalo(\n drawSDF(\n spriteImage,\n spriteImageData,\n iconColor || [0, 0, 0, 1],\n ),\n {\n x: 0,\n y: 0,\n width: spriteImageData.width,\n height: spriteImageData.height,\n pixelRatio: spriteImageData.pixelRatio,\n },\n haloWidth,\n haloColor,\n );\n color = undefined; // do not tint haloed icons\n } else {\n img = drawIconHalo(\n spriteImage,\n spriteImageData,\n haloWidth,\n haloColor,\n );\n }\n } else {\n if (spriteImageData.sdf) {\n if (!spriteImageUnSDFed) {\n spriteImageUnSDFed = drawSDF(\n spriteImage,\n {\n x: 0,\n y: 0,\n width: spriteImageSize[0],\n height: spriteImageSize[1],\n },\n {r: 1, g: 1, b: 1, a: 1},\n );\n }\n img = spriteImageUnSDFed;\n } else {\n img = spriteImage;\n }\n size = [spriteImageData.width, spriteImageData.height];\n offset = [spriteImageData.x, spriteImageData.y];\n }\n iconImg = new Icon({\n color: color,\n img: img,\n // @ts-ignore\n imgSize: spriteImageSize,\n size: size,\n offset: offset,\n rotateWithView: iconRotationAlignment === 'map',\n scale: iconSize / spriteImageData.pixelRatio,\n displacement: displacement,\n declutterMode: declutterMode,\n });\n }\n iconImageCache[iconCacheKey] = iconImg;\n }\n }\n if (iconImg) {\n ++stylesLength;\n style = styles[stylesLength];\n if (\n !style ||\n !style.getImage() ||\n style.getFill() ||\n style.getStroke()\n ) {\n style = new Style();\n styles[stylesLength] = style;\n }\n style.setGeometry(styleGeom);\n iconImg.setRotation(\n placementAngle +\n deg2rad(\n getValue(\n layer,\n 'layout',\n 'icon-rotate',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n ),\n );\n iconImg.setOpacity(\n getValue(\n layer,\n 'paint',\n 'icon-opacity',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n iconImg.setAnchor(\n anchor[\n getValue(\n layer,\n 'layout',\n 'icon-anchor',\n zoom,\n f,\n functionCache,\n featureState,\n )\n ],\n );\n style.setImage(iconImg);\n text = style.getText();\n style.setText(undefined);\n style.setZIndex(index);\n hasImage = true;\n skipLabel = false;\n }\n } else {\n skipLabel = true;\n }\n }\n }\n }\n\n if (type == 1 && layer.type === 'circle') {\n ++stylesLength;\n style = styles[stylesLength];\n if (\n !style ||\n !style.getImage() ||\n style.getFill() ||\n style.getStroke()\n ) {\n style = new Style();\n styles[stylesLength] = style;\n }\n const circleRadius =\n 'circle-radius' in paint\n ? getValue(\n layer,\n 'paint',\n 'circle-radius',\n zoom,\n f,\n functionCache,\n featureState,\n )\n : 5;\n const circleStrokeColor = colorWithOpacity(\n getValue(\n layer,\n 'paint',\n 'circle-stroke-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n getValue(\n layer,\n 'paint',\n 'circle-stroke-opacity',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n\n const circleTranslate = getValue(\n layer,\n 'paint',\n 'circle-translate',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const circleColor = colorWithOpacity(\n getValue(\n layer,\n 'paint',\n 'circle-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n getValue(\n layer,\n 'paint',\n 'circle-opacity',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n const circleStrokeWidth = getValue(\n layer,\n 'paint',\n 'circle-stroke-width',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const cache_key =\n circleRadius +\n '.' +\n circleStrokeColor +\n '.' +\n circleColor +\n '.' +\n circleStrokeWidth +\n '.' +\n circleTranslate[0] +\n '.' +\n circleTranslate[1];\n\n iconImg = iconImageCache[cache_key];\n if (!iconImg) {\n iconImg = new Circle({\n radius: circleRadius,\n displacement: [circleTranslate[0], -circleTranslate[1]],\n stroke:\n circleStrokeColor && circleStrokeWidth > 0\n ? new Stroke({\n width: circleStrokeWidth,\n color: circleStrokeColor,\n })\n : undefined,\n fill: circleColor\n ? new Fill({\n color: circleColor,\n })\n : undefined,\n declutterMode: 'none',\n });\n iconImageCache[cache_key] = iconImg;\n }\n style.setImage(iconImg);\n text = style.getText();\n style.setText(undefined);\n style.setGeometry(undefined);\n style.setZIndex(index);\n hasImage = true;\n }\n\n let label, font, textLineHeight, textSize, letterSpacing, maxTextWidth;\n if ('text-field' in layout) {\n textSize = Math.round(\n getValue(\n layer,\n 'layout',\n 'text-size',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n );\n const fontArray = getValue(\n layer,\n 'layout',\n 'text-font',\n zoom,\n f,\n functionCache,\n featureState,\n );\n textLineHeight = getValue(\n layer,\n 'layout',\n 'text-line-height',\n zoom,\n f,\n functionCache,\n featureState,\n );\n font = mb2css(\n getFonts\n ? getFonts(\n fontArray,\n glStyle.metadata\n ? glStyle.metadata['ol:webfonts']\n : undefined,\n )\n : fontArray,\n textSize,\n textLineHeight,\n );\n if (!font.includes('sans-serif')) {\n font += ',sans-serif';\n }\n letterSpacing = getValue(\n layer,\n 'layout',\n 'text-letter-spacing',\n zoom,\n f,\n functionCache,\n featureState,\n );\n maxTextWidth = getValue(\n layer,\n 'layout',\n 'text-max-width',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const textField = getValue(\n layer,\n 'layout',\n 'text-field',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (typeof textField === 'object' && textField.sections) {\n if (textField.sections.length === 1) {\n label = textField.toString();\n } else {\n label = textField.sections.reduce((acc, chunk, i) => {\n const fonts = chunk.fontStack\n ? chunk.fontStack.split(',')\n : fontArray;\n const chunkFont = mb2css(\n getFonts ? getFonts(fonts) : fonts,\n textSize * (chunk.scale || 1),\n textLineHeight,\n );\n let text = chunk.text;\n if (text === '\\n') {\n acc.push('\\n', '');\n return acc;\n }\n if (type == 2) {\n acc.push(applyLetterSpacing(text, letterSpacing), chunkFont);\n return acc;\n }\n text = wrapText(\n text,\n chunkFont,\n maxTextWidth,\n letterSpacing,\n ).split('\\n');\n for (let i = 0, ii = text.length; i < ii; ++i) {\n if (i > 0) {\n acc.push('\\n', '');\n }\n acc.push(text[i], chunkFont);\n }\n return acc;\n }, []);\n }\n } else {\n label = fromTemplate(textField, properties).trim();\n }\n opacity = getValue(\n layer,\n 'paint',\n 'text-opacity',\n zoom,\n f,\n functionCache,\n featureState,\n );\n }\n if (label && opacity && !skipLabel) {\n if (!hasImage) {\n ++stylesLength;\n style = styles[stylesLength];\n if (\n !style ||\n !style.getText() ||\n style.getFill() ||\n style.getStroke()\n ) {\n style = new Style();\n styles[stylesLength] = style;\n }\n style.setImage(undefined);\n style.setGeometry(undefined);\n }\n const declutterMode = getDeclutterMode(\n layer,\n zoom,\n f,\n 'text',\n functionCache,\n );\n if (!style.getText()) {\n style.setText(text);\n }\n text = style.getText();\n if (\n !text ||\n ('getDeclutterMode' in text &&\n text.getDeclutterMode() !== declutterMode)\n ) {\n text = new Text({\n padding: [2, 2, 2, 2],\n // @ts-ignore\n declutterMode: declutterMode,\n });\n style.setText(text);\n }\n const textTransform = getValue(\n layer,\n 'layout',\n 'text-transform',\n zoom,\n f,\n functionCache,\n featureState,\n );\n if (textTransform == 'uppercase') {\n label = Array.isArray(label)\n ? label.map((t, i) => (i % 2 ? t : t.toUpperCase()))\n : label.toUpperCase();\n } else if (textTransform == 'lowercase') {\n label = Array.isArray(label)\n ? label.map((t, i) => (i % 2 ? t : t.toLowerCase()))\n : label.toLowerCase();\n }\n const wrappedLabel = Array.isArray(label)\n ? label\n : type == 2\n ? applyLetterSpacing(label, letterSpacing)\n : wrapText(label, font, maxTextWidth, letterSpacing);\n text.setText(wrappedLabel);\n text.setFont(font);\n text.setRotation(\n deg2rad(\n getValue(\n layer,\n 'layout',\n 'text-rotate',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n ),\n );\n if (typeof text.setKeepUpright === 'function') {\n const keepUpright = getValue(\n layer,\n 'layout',\n 'text-keep-upright',\n zoom,\n f,\n functionCache,\n featureState,\n );\n text.setKeepUpright(keepUpright);\n }\n const textAnchor = getValue(\n layer,\n 'layout',\n 'text-anchor',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const placement =\n hasImage || type == 1\n ? 'point'\n : getValue(\n layer,\n 'layout',\n 'symbol-placement',\n zoom,\n f,\n functionCache,\n featureState,\n );\n let textAlign;\n if (placement === 'line-center') {\n text.setPlacement('line');\n textAlign = 'center';\n } else {\n text.setPlacement(placement);\n }\n if (placement === 'line' && typeof text.setRepeat === 'function') {\n const symbolSpacing = getValue(\n layer,\n 'layout',\n 'symbol-spacing',\n zoom,\n f,\n functionCache,\n featureState,\n );\n text.setRepeat(symbolSpacing * 2);\n }\n text.setOverflow(placement === 'point');\n let textHaloWidth = getValue(\n layer,\n 'paint',\n 'text-halo-width',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const textOffset = getValue(\n layer,\n 'layout',\n 'text-offset',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const textTranslate = getValue(\n layer,\n 'paint',\n 'text-translate',\n zoom,\n f,\n functionCache,\n featureState,\n );\n // Text offset has to take halo width and line height into account\n let vOffset = 0;\n let hOffset = 0;\n if (placement == 'point') {\n textAlign = 'center';\n if (textAnchor.indexOf('left') !== -1) {\n textAlign = 'left';\n hOffset = textHaloWidth;\n } else if (textAnchor.indexOf('right') !== -1) {\n textAlign = 'right';\n hOffset = -textHaloWidth;\n }\n const textRotationAlignment = getValue(\n layer,\n 'layout',\n 'text-rotation-alignment',\n zoom,\n f,\n functionCache,\n featureState,\n );\n text.setRotateWithView(textRotationAlignment == 'map');\n } else {\n text.setMaxAngle(\n (deg2rad(\n getValue(\n layer,\n 'layout',\n 'text-max-angle',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n ) *\n label.length) /\n wrappedLabel.length,\n );\n text.setRotateWithView(false);\n }\n text.setTextAlign(textAlign);\n let textBaseline = 'middle';\n if (textAnchor.indexOf('bottom') == 0) {\n textBaseline = 'bottom';\n vOffset = -textHaloWidth - 0.5 * (textLineHeight - 1) * textSize;\n } else if (textAnchor.indexOf('top') == 0) {\n textBaseline = 'top';\n vOffset = textHaloWidth + 0.5 * (textLineHeight - 1) * textSize;\n }\n text.setTextBaseline(textBaseline);\n const textJustify = getValue(\n layer,\n 'layout',\n 'text-justify',\n zoom,\n f,\n functionCache,\n featureState,\n );\n text.setJustify(textJustify === 'auto' ? undefined : textJustify);\n text.setOffsetX(\n textOffset[0] * textSize + hOffset + textTranslate[0],\n );\n text.setOffsetY(\n textOffset[1] * textSize + vOffset + textTranslate[1],\n );\n textColor.setColor(\n colorWithOpacity(\n getValue(\n layer,\n 'paint',\n 'text-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n opacity,\n ),\n );\n text.setFill(textColor);\n const haloColor = colorWithOpacity(\n getValue(\n layer,\n 'paint',\n 'text-halo-color',\n zoom,\n f,\n functionCache,\n featureState,\n ),\n opacity,\n );\n if (haloColor && textHaloWidth > 0) {\n textHalo.setColor(haloColor);\n // spec here : https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-symbol-text-halo-width\n // Halo width must be doubled because it is applied around the center of the text outline\n textHaloWidth *= 2;\n // 1/4 of text size (spec) x 2\n const halfTextSize = 0.5 * textSize;\n textHalo.setWidth(\n textHaloWidth <= halfTextSize ? textHaloWidth : halfTextSize,\n );\n text.setStroke(textHalo);\n } else {\n text.setStroke(undefined);\n }\n const textPadding = getValue(\n layer,\n 'layout',\n 'text-padding',\n zoom,\n f,\n functionCache,\n featureState,\n );\n const padding = text.getPadding();\n if (textPadding !== padding[0]) {\n padding[0] = textPadding;\n padding[1] = textPadding;\n padding[2] = textPadding;\n padding[3] = textPadding;\n }\n style.setZIndex(index);\n }\n }\n }\n\n if (stylesLength > -1) {\n styles.length = stylesLength + 1;\n if (recordLayer) {\n if ('set' in feature) {\n // ol/Feature\n feature.set('mapbox-layer', featureBelongsToLayer);\n } else {\n // ol/render/Feature\n feature.getProperties()['mapbox-layer'] = featureBelongsToLayer;\n }\n }\n return styles;\n }\n return undefined;\n };\n\n olLayer.setStyle(styleFunction);\n olLayer.set('mapbox-source', mapboxSource);\n olLayer.set('mapbox-layers', mapboxLayers);\n olLayer.set('mapbox-featurestate', olLayer.get('mapbox-featurestate') || {});\n return styleFunction;\n}\n\n/**\n * Get the the style for a specific Mapbox layer only. This can be useful for creating a legend.\n * @param {import(\"ol/Feature\").default|import(\"ol/render/Feature\").default} feature OpenLayers feature.\n * @param {number} resolution View resolution.\n * @param {import(\"ol/layer\").Vector|import(\"ol/layer\").VectorTile} olLayer OpenLayers layer.\n * @param {string} layerId Id of the Mapbox layer to get the style for\n * @return {Array} Styles for the provided Mapbox layer.\n */\nexport function getStyleForLayer(feature, resolution, olLayer, layerId) {\n const evaluateStyle = olLayer.getStyleFunction();\n if (evaluateStyle.length === 3) {\n // @ts-ignore\n return evaluateStyle(feature, resolution, layerId);\n }\n return undefined;\n}\n\nexport {\n colorWithOpacity as _colorWithOpacity,\n evaluateFilter as _evaluateFilter,\n fromTemplate as _fromTemplate,\n getValue as _getValue,\n};\n","/**\n * Generates a shaded relief image given elevation data. Uses a 3x3\n * neighborhood for determining slope and aspect.\n * @param {Array} inputs Array of input images.\n * @param {Object} data Data added in the \"beforeoperations\" event.\n * @return {ImageData} Output image.\n */\nexport function hillshade(inputs, data) {\n const elevationImage = inputs[0];\n const width = elevationImage.width;\n const height = elevationImage.height;\n const elevationData = elevationImage.data;\n const shadeData = new Uint8ClampedArray(elevationData.length);\n const dp = data.resolution * 2;\n const maxX = width - 1;\n const maxY = height - 1;\n const pixel = [0, 0, 0, 0];\n const twoPi = 2 * Math.PI;\n const halfPi = Math.PI / 2;\n const sunEl = (Math.PI * data.sunEl) / 180;\n const sunAz = (Math.PI * data.sunAz) / 180;\n const cosSunEl = Math.cos(sunEl);\n const sinSunEl = Math.sin(sunEl);\n const highlightColor = data.highlightColor;\n const shadowColor = data.shadowColor;\n const accentColor = data.accentColor;\n const encoding = data.encoding;\n\n let pixelX,\n pixelY,\n x0,\n x1,\n y0,\n y1,\n offset,\n z0,\n z1,\n dzdx,\n dzdy,\n slope,\n aspect,\n accent,\n scaled,\n shade,\n scaledAccentColor,\n compositeShadeColor,\n clamp,\n slopeScaleBase,\n scaledSlope,\n cosIncidence;\n\n function calculateElevation(pixel, encoding = 'mapbox') {\n // The method used to extract elevations from the DEM.\n //\n // The supported methods are the Mapbox format\n // (red * 256 * 256 + green * 256 + blue) * 0.1 - 10000\n // and the Terrarium format\n // (red * 256 + green + blue / 256) - 32768\n //\n if (encoding === 'mapbox') {\n return (pixel[0] * 256 * 256 + pixel[1] * 256 + pixel[2]) * 0.1 - 10000;\n }\n if (encoding === 'terrarium') {\n return pixel[0] * 256 + pixel[1] + pixel[2] / 256 - 32768;\n }\n }\n for (pixelY = 0; pixelY <= maxY; ++pixelY) {\n y0 = pixelY === 0 ? 0 : pixelY - 1;\n y1 = pixelY === maxY ? maxY : pixelY + 1;\n for (pixelX = 0; pixelX <= maxX; ++pixelX) {\n x0 = pixelX === 0 ? 0 : pixelX - 1;\n x1 = pixelX === maxX ? maxX : pixelX + 1;\n\n // determine elevation for (x0, pixelY)\n offset = (pixelY * width + x0) * 4;\n pixel[0] = elevationData[offset];\n pixel[1] = elevationData[offset + 1];\n pixel[2] = elevationData[offset + 2];\n pixel[3] = elevationData[offset + 3];\n z0 = data.vert * calculateElevation(pixel, encoding);\n\n // determine elevation for (x1, pixelY)\n offset = (pixelY * width + x1) * 4;\n pixel[0] = elevationData[offset];\n pixel[1] = elevationData[offset + 1];\n pixel[2] = elevationData[offset + 2];\n pixel[3] = elevationData[offset + 3];\n z1 = data.vert * calculateElevation(pixel, encoding);\n\n dzdx = (z1 - z0) / dp;\n\n // determine elevation for (pixelX, y0)\n offset = (y0 * width + pixelX) * 4;\n pixel[0] = elevationData[offset];\n pixel[1] = elevationData[offset + 1];\n pixel[2] = elevationData[offset + 2];\n pixel[3] = elevationData[offset + 3];\n z0 = data.vert * calculateElevation(pixel, encoding);\n\n // determine elevation for (pixelX, y1)\n offset = (y1 * width + pixelX) * 4;\n pixel[0] = elevationData[offset];\n pixel[1] = elevationData[offset + 1];\n pixel[2] = elevationData[offset + 2];\n pixel[3] = elevationData[offset + 3];\n z1 = data.vert * calculateElevation(pixel, encoding);\n\n dzdy = (z1 - z0) / dp;\n\n aspect = Math.atan2(dzdy, -dzdx);\n if (aspect < 0) {\n aspect = halfPi - aspect;\n } else if (aspect > halfPi) {\n aspect = twoPi - aspect + halfPi;\n } else {\n aspect = halfPi - aspect;\n }\n\n // Bootstrap slope and corresponding incident values\n slope = Math.atan(Math.sqrt(dzdx * dzdx + dzdy * dzdy));\n cosIncidence =\n sinSunEl * Math.cos(slope) +\n cosSunEl * Math.sin(slope) * Math.cos(sunAz - aspect);\n accent = Math.cos(slope);\n // 255 for Hex colors\n scaled = 255 * cosIncidence;\n\n /*\n * The following is heavily inspired\n * by [Maplibre's equivalent WebGL shader](https://github.com/maplibre/maplibre-gl-js/blob/main/src/shaders/hillshade.fragment.glsl)\n */\n\n // Forces given value to stay between two given extremes\n clamp = Math.min(Math.max(2 * data.sunEl, 0), 1);\n\n // Intensity basis for hillshade opacity\n slopeScaleBase = 1.875 - data.opacity * 1.75;\n // Intensity interpolation so that higher intensity values create more opaque hillshading\n scaledSlope =\n data.opacity !== 0.5\n ? halfPi *\n ((Math.pow(slopeScaleBase, slope) - 1) /\n (Math.pow(slopeScaleBase, halfPi) - 1))\n : slope;\n\n // Accent hillshade color with given accentColor to emphasize rougher terrain\n scaledAccentColor = {\n r: (1 - accent) * accentColor.r * clamp * 255,\n g: (1 - accent) * accentColor.g * clamp * 255,\n b: (1 - accent) * accentColor.b * clamp * 255,\n a: (1 - accent) * accentColor.a * clamp * 255,\n };\n\n // Allows highlight vs shadow discrimination\n shade = Math.abs((((aspect + sunAz) / Math.PI + 0.5) % 2) - 1);\n // Creates a composite color mix between highlight & shadow colors to emphasize slopes\n compositeShadeColor = {\n r: (highlightColor.r * (1 - shade) + shadowColor.r * shade) * scaled,\n g: (highlightColor.g * (1 - shade) + shadowColor.g * shade) * scaled,\n b: (highlightColor.b * (1 - shade) + shadowColor.b * shade) * scaled,\n a: (highlightColor.a * (1 - shade) + shadowColor.a * shade) * scaled,\n };\n\n // Fill in result color value\n offset = (pixelY * width + pixelX) * 4;\n shadeData[offset] =\n scaledAccentColor.r * (1 - shade) + compositeShadeColor.r;\n shadeData[offset + 1] =\n scaledAccentColor.g * (1 - shade) + compositeShadeColor.g;\n shadeData[offset + 2] =\n scaledAccentColor.b * (1 - shade) + compositeShadeColor.b;\n // Key opacity on the scaledSlope to improve legibility by increasing higher elevation rates' contrast\n shadeData[offset + 3] =\n elevationData[offset + 3] *\n data.opacity *\n clamp *\n Math.sin(scaledSlope);\n }\n }\n\n return new ImageData(shadeData, width, height);\n}\n","/*\nol-mapbox-style - Use Mapbox/MapLibre Style objects with OpenLayers\nCopyright 2016-present ol-mapbox-style contributors\nLicense: https://raw.githubusercontent.com/openlayers/ol-mapbox-style/master/LICENSE\n*/\n\nimport {derefLayers} from '@maplibre/maplibre-gl-style-spec';\nimport Map from 'ol/Map.js';\nimport View from 'ol/View.js';\nimport {getCenter, getTopLeft} from 'ol/extent.js';\nimport GeoJSON from 'ol/format/GeoJSON.js';\nimport MVT from 'ol/format/MVT.js';\nimport LayerGroup from 'ol/layer/Group.js';\nimport ImageLayer from 'ol/layer/Image.js';\nimport Layer from 'ol/layer/Layer.js';\nimport TileLayer from 'ol/layer/Tile.js';\nimport VectorLayer from 'ol/layer/Vector.js';\nimport VectorTileLayer from 'ol/layer/VectorTile.js';\nimport {bbox as bboxStrategy} from 'ol/loadingstrategy.js';\nimport {METERS_PER_UNIT} from 'ol/proj/Units.js';\nimport {\n equivalent,\n fromLonLat,\n get as getProjection,\n getPointResolution,\n getUserProjection,\n} from 'ol/proj.js';\nimport Raster from 'ol/source/Raster.js';\nimport Source from 'ol/source/Source.js';\nimport TileJSON from 'ol/source/TileJSON.js';\nimport VectorSource from 'ol/source/Vector.js';\nimport VectorTileSource, {defaultLoadFunction} from 'ol/source/VectorTile.js';\nimport TileGrid from 'ol/tilegrid/TileGrid.js';\nimport {createXYZ} from 'ol/tilegrid.js';\nimport {\n normalizeSourceUrl,\n normalizeSpriteUrl,\n normalizeStyleUrl,\n} from './mapbox.js';\nimport {hillshade} from './shaders.js';\nimport {\n _colorWithOpacity,\n getValue,\n styleFunctionArgs,\n stylefunction as applyStylefunction,\n} from './stylefunction.js';\nimport {getFonts} from './text.js';\nimport {\n defaultResolutions,\n fetchResource,\n getFilterCache,\n getFunctionCache,\n getGlStyle,\n getResolutionForZoom,\n getStyleFunctionKey,\n getTileJson,\n getZoomForResolution,\n} from './util.js';\n\n/**\n * @typedef {Object} FeatureIdentifier\n * @property {string|number} id The feature id.\n * @property {string} source The source id.\n */\n\n/**\n * @typedef {Object} Options\n * @property {string} [accessToken] Access token for 'mapbox://' urls.\n * @property {function(string, import(\"./util.js\").ResourceType): (Request|string|Promise|void)} [transformRequest]\n * Function for controlling how `ol-mapbox-style` fetches resources. Can be used for modifying\n * the url, adding headers or setting credentials options. Called with the url and the resource\n * type as arguments, this function is supposed to return a `Request` or a url `string`, or a promise tehereof.\n * Without a return value the original request will not be modified.\n * @property {string} [projection='EPSG:3857'] Only useful when working with non-standard projections.\n * Code of a projection registered with OpenLayers. All sources of the style must be provided in this\n * projection. The projection must also have a valid extent defined, which will be used to determine the\n * origin and resolutions of the tile grid for all tiled sources of the style. When provided, the bbox\n * placeholder in tile and geojson urls changes: the default is `{bbox-epsg-3857}`, when projection is e.g.\n * set to `EPSG:4326`, the bbox placeholder will be `{bbox-epsg-4326}`.\n * @property {Array} [resolutions] Only useful when working with non-standard projections.\n * Resolutions for mapping resolution to the `zoom` used in the Mapbox/MapLibre style.\n * @property {string} [styleUrl] URL of the Mapbox GL style. Required for styles that were provided\n * as object, when they contain a relative sprite url, or sources referencing data by relative url.\n * @property {string} [webfonts] Template for resolving webfonts. Can be used to specify where to fetch\n * web fonts when no `ol:webfonts` metadata is set in the style object. See `getFonts()` and the\n * \"Font handling\" section in `README.md` for details.\n * @property {function(VectorLayer|VectorTileLayer, string):HTMLImageElement|HTMLCanvasElement|string|undefined} [getImage=undefined]\n * Function that returns an image for an icon name. If the result is an HTMLImageElement, it must already be\n * loaded. The layer can be used to call layer.changed() when the loading and processing of the image has finished.\n * This function be used for icons not in the sprite or to override sprite icons.\n * @property {string} [accessTokenParam='access_token'] Access token param. For internal use.\n */\n\n/**\n * @typedef {Object} ApplyStyleOptions\n * @property {string} [source=''] Source. Default is `''`, which causes the first source in the\n * style to be used.\n * @property {Array} [layers] Layers. If no source is provided, the layers with the\n * provided ids will be used from the style's `layers` array. All layers need to use the same source.\n * @property {boolean} [updateSource=true] Update or create vector (tile) layer source with parameters\n * specified for the source in the mapbox style definition.\n */\n\n/**\n * @param {import(\"ol/proj/Projection.js\").default} projection Projection.\n * @param {number} [tileSize] Tile size.\n * @return {Array} Resolutions.\n */\nfunction getTileResolutions(projection, tileSize = 512) {\n return projection.getExtent()\n ? createXYZ({\n extent: projection.getExtent(),\n tileSize: tileSize,\n maxZoom: 22,\n }).getResolutions()\n : defaultResolutions;\n}\n\n/**\n * @param {string} styleUrl Style URL.\n * @param {Options} options Options.\n * @return {Options} Completed options with accessToken and accessTokenParam.\n */\nfunction completeOptions(styleUrl, options) {\n if (!options.accessToken) {\n options = Object.assign({}, options);\n const searchParams = new URL(styleUrl).searchParams;\n // The last search parameter is the access token\n searchParams.forEach((value, key) => {\n options.accessToken = value;\n options.accessTokenParam = key;\n });\n }\n return options;\n}\n\n/**\n * Applies a style function to an `ol/layer/VectorTile` or `ol/layer/Vector`\n * with an `ol/source/VectorTile` or an `ol/source/Vector`. If the layer does not have a source\n * yet, it will be created and populated from the information in the `glStyle` (unless `updateSource` is\n * set to `false`).\n *\n * **Example:**\n * ```js\n * import {applyStyle} from 'ol-mapbox-style';\n * import {VectorTile} from 'ol/layer.js';\n *\n * const layer = new VectorTile({declutter: true});\n * applyStyle(layer, 'https://api.maptiler.com/maps/basic/style.json?key=YOUR_OPENMAPTILES_TOKEN');\n * ```\n *\n * The style function will render all layers from the `glStyle` object that use the source\n * of the first layer, the specified `source`, or a subset of layers from the same source. The\n * source needs to be a `\"type\": \"vector\"` or `\"type\": \"geojson\"` source.\n *\n * Two additional properties will be set on the provided layer:\n *\n * * `mapbox-source`: The `id` of the Mapbox/MapLibre Style document's source that the\n * OpenLayers layer was created from. Usually `apply()` creates one\n * OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has\n * layers from different sources in between.\n * * `mapbox-layers`: The `id`s of the Mapbox/MapLibre Style document's layers that are\n * included in the OpenLayers layer.\n *\n * @param {VectorTileLayer|VectorLayer} layer OpenLayers layer. When the layer has a source configured,\n * it will be modified to use the configuration from the glStyle's `source`. Options specified on the\n * layer's source will override those from the glStyle's `source`, except for `url` and\n * `tileUrlFunction`. When the source projection is the default (`EPSG:3857`), the `tileGrid` will\n * also be overridden. If you'd rather not have ol-mapbox-style modify the source, configure `applyStyle()`\n * with the `updateSource: false` option.\n * @param {string|Object} glStyle Mapbox/MapLibre Style object.\n * @param {string|Array|Options&ApplyStyleOptions} [sourceOrLayersOrOptions] Options or\n * `source` key or an array of layer `id`s from the Mapbox/MapLibre Style object. When a `source` key is\n * provided, all layers for the specified source will be included in the style function. When layer\n * `id`s are provided, they must be from layers that use the same source. When not provided or a falsey\n * value, all layers using the first source specified in the glStyle will be rendered.\n * @param {Options&ApplyStyleOptions|string} [optionsOrPath] **Deprecated**. Options. Alternatively the path of the style file\n * (only required when a relative path is used for the `\"sprite\"` property of the style).\n * @param {Array} [resolutions] **Deprecated**. Resolutions for mapping resolution to zoom level.\n * Only needed when working with non-standard tile grids or projections, can also be supplied with\n * options.\n * @return {Promise} Promise which will be resolved when the style can be used\n * for rendering.\n */\nexport function applyStyle(\n layer,\n glStyle,\n sourceOrLayersOrOptions = '',\n optionsOrPath = {},\n resolutions = undefined,\n) {\n let styleUrl, sourceId;\n /** @type {Options&ApplyStyleOptions} */\n let options;\n let sourceOrLayers;\n let updateSource = true;\n if (\n typeof sourceOrLayersOrOptions !== 'string' &&\n !Array.isArray(sourceOrLayersOrOptions)\n ) {\n options = sourceOrLayersOrOptions;\n sourceOrLayers = options.source || options.layers;\n optionsOrPath = options;\n } else {\n sourceOrLayers = sourceOrLayersOrOptions;\n }\n if (typeof optionsOrPath === 'string') {\n styleUrl = optionsOrPath;\n options = {};\n } else {\n styleUrl = optionsOrPath.styleUrl;\n options = optionsOrPath;\n }\n if (options.updateSource === false) {\n updateSource = false;\n }\n if (!resolutions) {\n resolutions = options.resolutions;\n }\n if (\n !styleUrl &&\n typeof glStyle === 'string' &&\n !glStyle.trim().startsWith('{')\n ) {\n styleUrl = glStyle;\n }\n if (styleUrl) {\n styleUrl = styleUrl.startsWith('data:')\n ? location.href\n : normalizeStyleUrl(styleUrl, options.accessToken);\n options = completeOptions(styleUrl, options);\n }\n\n return new Promise(function (resolve, reject) {\n // TODO: figure out where best place to check source type is\n // Note that the source arg is an array of gl layer ids and each must be\n // dereferenced to get source type to validate\n getGlStyle(glStyle, options)\n .then(function (glStyle) {\n if (glStyle.version != 8) {\n return reject(new Error('glStyle version 8 required.'));\n }\n if (\n !(layer instanceof VectorLayer || layer instanceof VectorTileLayer)\n ) {\n return reject(\n new Error('Can only apply to VectorLayer or VectorTileLayer'),\n );\n }\n\n const type = layer instanceof VectorTileLayer ? 'vector' : 'geojson';\n if (!sourceOrLayers) {\n sourceId = Object.keys(glStyle.sources).find(function (key) {\n return glStyle.sources[key].type === type;\n });\n sourceOrLayers = sourceId;\n } else if (Array.isArray(sourceOrLayers)) {\n sourceId = glStyle.layers.find(function (layer) {\n return layer.id === sourceOrLayers[0];\n }).source;\n } else {\n sourceId = sourceOrLayers;\n }\n if (!sourceId) {\n return reject(new Error(`No ${type} source found in the glStyle.`));\n }\n\n function assignSource() {\n if (!updateSource) {\n return Promise.resolve();\n }\n if (layer instanceof VectorTileLayer) {\n return setupVectorSource(\n glStyle.sources[sourceId],\n styleUrl,\n options,\n ).then(function (source) {\n const targetSource = layer.getSource();\n if (!targetSource) {\n layer.setSource(source);\n } else if (source !== targetSource) {\n targetSource.setTileUrlFunction(source.getTileUrlFunction());\n if (\n typeof targetSource.setUrls === 'function' &&\n typeof source.getUrls === 'function'\n ) {\n // to get correct keys for tile cache and queue\n targetSource.setUrls(source.getUrls());\n }\n //@ts-ignore\n if (!targetSource.format_) {\n //@ts-ignore\n targetSource.format_ = source.format_;\n }\n if (!targetSource.getAttributions()) {\n targetSource.setAttributions(source.getAttributions());\n }\n if (\n targetSource.getTileLoadFunction() === defaultLoadFunction\n ) {\n targetSource.setTileLoadFunction(\n source.getTileLoadFunction(),\n );\n }\n if (\n equivalent(\n targetSource.getProjection(),\n source.getProjection(),\n )\n ) {\n //@ts-ignore\n targetSource.tileGrid = source.getTileGrid();\n }\n }\n const tileGrid = layer.getSource().getTileGrid();\n if (\n !isFinite(layer.getMaxResolution()) &&\n !isFinite(layer.getMinZoom()) &&\n tileGrid.getMinZoom() > 0\n ) {\n layer.setMaxResolution(\n getResolutionForZoom(\n Math.max(0, tileGrid.getMinZoom() - 1e-12),\n tileGrid.getResolutions(),\n ),\n );\n }\n });\n }\n const glSource = glStyle.sources[sourceId];\n let source = layer.getSource();\n if (!source || source.get('mapbox-source') !== glSource) {\n source = setupGeoJSONSource(glSource, styleUrl, options);\n }\n const targetSource = /** @type {VectorSource} */ (layer.getSource());\n if (!targetSource) {\n layer.setSource(source);\n } else if (source !== targetSource) {\n if (!targetSource.getAttributions()) {\n targetSource.setAttributions(source.getAttributions());\n }\n //@ts-ignore\n if (!targetSource.format_) {\n //@ts-ignore\n targetSource.format_ = source.getFormat();\n }\n //@ts-ignore\n targetSource.url_ = source.getUrl();\n }\n return Promise.resolve();\n }\n\n let spriteScale, spriteData, spriteImageUrl, style;\n function onChange() {\n if (!style && (!glStyle.sprite || spriteData)) {\n if (options.projection && !resolutions) {\n const projection = getProjection(options.projection);\n const units = projection.getUnits();\n if (units !== 'm') {\n resolutions = defaultResolutions.map(\n (resolution) => resolution / METERS_PER_UNIT[units],\n );\n }\n }\n style = applyStylefunction(\n layer,\n glStyle,\n sourceOrLayers,\n resolutions,\n spriteData,\n spriteImageUrl,\n (fonts, templateUrl = options.webfonts) =>\n getFonts(fonts, templateUrl),\n options.getImage,\n );\n if (!layer.getStyle()) {\n reject(new Error(`Nothing to show for source [${sourceId}]`));\n } else {\n assignSource().then(resolve).catch(reject);\n }\n } else if (style) {\n layer.setStyle(style);\n assignSource().then(resolve).catch(reject);\n } else {\n reject(new Error('Something went wrong trying to apply style.'));\n }\n }\n\n if (glStyle.sprite) {\n const sprite = new URL(\n normalizeSpriteUrl(\n glStyle.sprite,\n options.accessToken,\n styleUrl || location.href,\n ),\n );\n spriteScale = window.devicePixelRatio >= 1.5 ? 0.5 : 1;\n const sizeFactor = spriteScale == 0.5 ? '@2x' : '';\n let spriteUrl =\n sprite.origin +\n sprite.pathname +\n sizeFactor +\n '.json' +\n sprite.search;\n\n new Promise(function (resolve, reject) {\n fetchResource('Sprite', spriteUrl, options)\n .then(resolve)\n .catch(function (error) {\n spriteUrl =\n sprite.origin + sprite.pathname + '.json' + sprite.search;\n fetchResource('Sprite', spriteUrl, options)\n .then(resolve)\n .catch(reject);\n });\n })\n .then(function (spritesJson) {\n if (spritesJson === undefined) {\n reject(new Error('No sprites found.'));\n }\n spriteData = spritesJson;\n spriteImageUrl =\n sprite.origin +\n sprite.pathname +\n sizeFactor +\n '.png' +\n sprite.search;\n if (options.transformRequest) {\n const transformed =\n options.transformRequest(spriteImageUrl, 'SpriteImage') ||\n spriteImageUrl;\n if (\n transformed instanceof Request ||\n transformed instanceof Promise\n ) {\n spriteImageUrl = transformed;\n }\n }\n onChange();\n })\n .catch(function (err) {\n reject(\n new Error(\n `Sprites cannot be loaded: ${spriteUrl}: ${err.message}`,\n ),\n );\n });\n } else {\n onChange();\n }\n })\n .catch(reject);\n });\n}\n\nconst emptyObj = {};\n\nfunction setFirstBackground(mapOrLayer, glStyle, options) {\n glStyle.layers.some(function (layer) {\n if (layer.type === 'background') {\n if (mapOrLayer instanceof Layer) {\n mapOrLayer.setBackground(function (resolution) {\n return getBackgroundColor(layer, resolution, options, {});\n });\n return true;\n }\n if (mapOrLayer instanceof Map || mapOrLayer instanceof LayerGroup) {\n mapOrLayer\n .getLayers()\n .insertAt(0, setupBackgroundLayer(layer, options, {}));\n return true;\n }\n }\n });\n}\n\n/**\n * Applies properties of the Mapbox/MapLibre Style's first `background` layer to the\n * provided map or layer (group).\n *\n * **Example:**\n * ```js\n * import {applyBackground} from 'ol-mapbox-style';\n * import {Map} from 'ol';\n *\n * const map = new Map({target: 'map'});\n * applyBackground(map, 'https://api.maptiler.com/maps/basic/style.json?key=YOUR_OPENMAPTILES_TOKEN');\n * ```\n * @param {Map|import(\"ol/layer/Base.js\").default} mapOrLayer OpenLayers Map or layer (group).\n * @param {Object|string} glStyle Mapbox/MapLibre Style object or url.\n * @param {Options} options Options.\n * @return {Promise} Promise that resolves when the background is applied.\n */\nexport function applyBackground(mapOrLayer, glStyle, options = {}) {\n return getGlStyle(glStyle, options).then(function (glStyle) {\n setFirstBackground(mapOrLayer, glStyle, options);\n });\n}\n\nfunction getSourceIdByRef(layers, ref) {\n let sourceId;\n layers.some(function (layer) {\n if (layer.id == ref) {\n sourceId = layer.source;\n return true;\n }\n });\n return sourceId;\n}\n\nfunction extentFromTileJSON(tileJSON, projection) {\n const bounds = tileJSON.bounds;\n if (bounds) {\n const ll = fromLonLat([bounds[0], bounds[1]], projection);\n const tr = fromLonLat([bounds[2], bounds[3]], projection);\n return [ll[0], ll[1], tr[0], tr[1]];\n }\n return getProjection(projection).getExtent();\n}\n\nfunction sourceOptionsFromTileJSON(glSource, tileJSON, options) {\n const tileJSONSource = new TileJSON({\n tileJSON: tileJSON,\n tileSize: glSource.tileSize || tileJSON.tileSize || 512,\n });\n const tileJSONDoc = tileJSONSource.getTileJSON();\n const tileGrid = tileJSONSource.getTileGrid();\n const projection = getProjection(options.projection || 'EPSG:3857');\n const extent = extentFromTileJSON(tileJSONDoc, projection);\n const projectionExtent = projection.getExtent();\n const minZoom = tileJSONDoc.minzoom || 0;\n const maxZoom = tileJSONDoc.maxzoom || 22;\n /** @type {import(\"ol/source/VectorTile.js\").Options} */\n const sourceOptions = {\n attributions: tileJSONSource.getAttributions(),\n projection: projection,\n tileGrid: new TileGrid({\n origin: projectionExtent\n ? getTopLeft(projectionExtent)\n : tileGrid.getOrigin(0),\n extent: extent || tileGrid.getExtent(),\n minZoom: minZoom,\n resolutions: getTileResolutions(projection, tileJSON.tileSize).slice(\n 0,\n maxZoom + 1,\n ),\n tileSize: tileGrid.getTileSize(0),\n }),\n };\n if (Array.isArray(tileJSONDoc.tiles)) {\n sourceOptions.urls = tileJSONDoc.tiles;\n } else {\n sourceOptions.url = tileJSONDoc.tiles;\n }\n return sourceOptions;\n}\n\nfunction getBackgroundColor(glLayer, resolution, options, functionCache) {\n const background = {\n id: glLayer.id,\n type: glLayer.type,\n };\n const layout = glLayer.layout || {};\n const paint = glLayer.paint || {};\n background['paint'] = paint;\n const zoom = getZoomForResolution(\n resolution,\n options.resolutions || defaultResolutions,\n );\n let opacity;\n const bg = getValue(\n background,\n 'paint',\n 'background-color',\n zoom,\n emptyObj,\n functionCache,\n );\n if (paint['background-opacity'] !== undefined) {\n opacity = getValue(\n background,\n 'paint',\n 'background-opacity',\n zoom,\n emptyObj,\n functionCache,\n );\n }\n return layout.visibility == 'none'\n ? undefined\n : _colorWithOpacity(bg, opacity);\n}\n\n/**\n * @param {Object} glLayer Mapbox/MapLibre Style layer object.\n * @param {Options} options Options.\n * @param {Object} functionCache Cache for functions.\n * @return {Layer} OpenLayers layer.\n */\nfunction setupBackgroundLayer(glLayer, options, functionCache) {\n const div = document.createElement('div');\n div.className = 'ol-mapbox-style-background';\n div.style.position = 'absolute';\n div.style.width = '100%';\n div.style.height = '100%';\n return new Layer({\n source: new Source({}),\n render(frameState) {\n const color = getBackgroundColor(\n glLayer,\n frameState.viewState.resolution,\n options,\n functionCache,\n );\n div.style.backgroundColor = color;\n return div;\n },\n });\n}\n\n/**\n * Creates an OpenLayers VectorTile source for a gl source entry.\n * @param {Object} glSource \"source\" entry from a Mapbox/MapLibre Style object.\n * @param {string|undefined} styleUrl URL to use for the source. This is expected to be the complete http(s) url,\n * with access key applied.\n * @param {Options} options Options.\n * @return {Promise} Promise resolving to a VectorTile source.\n * @private\n */\nexport function setupVectorSource(glSource, styleUrl, options) {\n return new Promise(function (resolve, reject) {\n getTileJson(glSource, styleUrl, options)\n .then(function ({tileJson, tileLoadFunction}) {\n const sourceOptions = sourceOptionsFromTileJSON(\n glSource,\n tileJson,\n options,\n );\n sourceOptions.tileLoadFunction = tileLoadFunction;\n sourceOptions.format = new MVT();\n resolve(new VectorTileSource(sourceOptions));\n })\n .catch(reject);\n });\n}\n\nfunction setupVectorLayer(glSource, styleUrl, options) {\n const layer = new VectorTileLayer({\n declutter: true,\n visible: false,\n });\n setupVectorSource(glSource, styleUrl, options)\n .then(function (source) {\n source.set('mapbox-source', glSource);\n layer.setSource(source);\n })\n .catch(function (error) {\n layer.setSource(undefined);\n });\n return layer;\n}\n\nfunction getBboxTemplate(projection) {\n const projCode = projection ? projection.getCode() : 'EPSG:3857';\n return `{bbox-${projCode.toLowerCase().replace(/[^a-z0-9]/g, '-')}}`;\n}\n\nfunction setupRasterSource(glSource, styleUrl, options) {\n return new Promise(function (resolve, reject) {\n getTileJson(glSource, styleUrl, options)\n .then(function ({tileJson, tileLoadFunction}) {\n const source = new TileJSON({\n interpolate:\n options.interpolate === undefined ? true : options.interpolate,\n transition: 0,\n crossOrigin: 'anonymous',\n tileJSON: tileJson,\n });\n //@ts-ignore\n source.tileGrid = sourceOptionsFromTileJSON(\n glSource,\n tileJson,\n options,\n ).tileGrid;\n if (options.projection) {\n //@ts-ignore\n source.projection = getProjection(options.projection);\n }\n const getTileUrl = source.getTileUrlFunction();\n if (tileLoadFunction) {\n source.setTileLoadFunction(tileLoadFunction);\n }\n source.setTileUrlFunction(function (tileCoord, pixelRatio, projection) {\n const bboxTemplate = getBboxTemplate(projection);\n let src = getTileUrl(tileCoord, pixelRatio, projection);\n if (src.indexOf(bboxTemplate) != -1) {\n const bbox = source.getTileGrid().getTileCoordExtent(tileCoord);\n src = src.replace(bboxTemplate, bbox.toString());\n }\n return src;\n });\n source.set('mapbox-source', glSource);\n resolve(source);\n })\n .catch(function (error) {\n reject(error);\n });\n });\n}\n\nfunction setupRasterLayer(glSource, styleUrl, options) {\n const layer = new TileLayer();\n setupRasterSource(glSource, styleUrl, options)\n .then(function (source) {\n layer.setSource(source);\n })\n .catch(function () {\n layer.setSource(undefined);\n });\n return layer;\n}\n\n/**\n *\n * @param {Object} glSource \"source\" entry from a Mapbox/MapLibre Style object.\n * @param {string} styleUrl Style url\n * @param {Options} options ol-mapbox-style options.\n * @return {ImageLayer} The raster layer\n */\nfunction setupHillshadeLayer(glSource, styleUrl, options) {\n const tileLayer = setupRasterLayer(glSource, styleUrl, options);\n /** @type {ImageLayer} */\n const layer = new ImageLayer({\n source: new Raster({\n operationType: 'image',\n operation: hillshade,\n sources: [tileLayer],\n }),\n });\n return layer;\n}\n\n/**\n * @param {Object} glSource glStyle source.\n * @param {string} styleUrl Style URL.\n * @param {Options} options Options.\n * @return {VectorSource} Configured vector source.\n */\nfunction setupGeoJSONSource(glSource, styleUrl, options) {\n const geoJsonFormat = options.projection\n ? new GeoJSON({dataProjection: options.projection})\n : new GeoJSON();\n const data = glSource.data;\n const sourceOptions = {};\n if (typeof data == 'string') {\n const [geoJsonUrl] = normalizeSourceUrl(\n data,\n options.accessToken,\n options.accessTokenParam || 'access_token',\n styleUrl || location.href,\n );\n if (/\\{bbox-[0-9a-z-]+\\}/.test(geoJsonUrl)) {\n const extentUrl = (extent, resolution, projection) => {\n const bboxTemplate = getBboxTemplate(projection);\n return geoJsonUrl.replace(bboxTemplate, `${extent.join(',')}`);\n };\n const source = new VectorSource({\n attributions: glSource.attribution,\n format: geoJsonFormat,\n loader: (extent, resolution, projection, success, failure) => {\n const url =\n typeof extentUrl === 'function'\n ? extentUrl(extent, resolution, projection)\n : extentUrl;\n fetchResource('GeoJSON', url, options)\n .then((json) => {\n const features = /** @type {*} */ (\n source\n .getFormat()\n .readFeatures(json, {featureProjection: projection})\n );\n source.addFeatures(features);\n success(features);\n })\n .catch((response) => {\n source.removeLoadedExtent(extent);\n failure();\n });\n },\n strategy: bboxStrategy,\n });\n source.set('mapbox-source', glSource);\n return source;\n }\n const source = new VectorSource({\n attributions: glSource.attribution,\n format: geoJsonFormat,\n url: geoJsonUrl,\n loader: (extent, resolution, projection, success, failure) => {\n fetchResource('GeoJSON', geoJsonUrl, options)\n .then((json) => {\n const features = /** @type {*} */ (\n source\n .getFormat()\n .readFeatures(json, {featureProjection: projection})\n );\n source.addFeatures(features);\n success(features);\n })\n .catch((response) => {\n source.removeLoadedExtent(extent);\n failure();\n });\n },\n });\n return source;\n }\n sourceOptions.features = geoJsonFormat.readFeatures(data, {\n featureProjection: getUserProjection() || 'EPSG:3857',\n });\n\n const source = new VectorSource(\n Object.assign(\n {\n attributions: glSource.attribution,\n format: geoJsonFormat,\n },\n sourceOptions,\n ),\n );\n source.set('mapbox-source', glSource);\n return /** @type {VectorSource} */ (source);\n}\n\nfunction setupGeoJSONLayer(glSource, styleUrl, options) {\n return new VectorLayer({\n declutter: true,\n source: setupGeoJSONSource(glSource, styleUrl, options),\n visible: false,\n });\n}\n\nfunction prerenderRasterLayer(glLayer, layer, functionCache) {\n let zoom = null;\n return function (event) {\n if (\n glLayer.paint &&\n 'raster-opacity' in glLayer.paint &&\n event.frameState.viewState.zoom !== zoom\n ) {\n zoom = event.frameState.viewState.zoom;\n delete functionCache[glLayer.id];\n updateRasterLayerProperties(glLayer, layer, zoom, functionCache);\n }\n };\n}\n\nfunction updateRasterLayerProperties(glLayer, layer, zoom, functionCache) {\n const opacity = getValue(\n glLayer,\n 'paint',\n 'raster-opacity',\n zoom,\n emptyObj,\n functionCache,\n );\n layer.setOpacity(opacity);\n}\n\nfunction manageVisibility(layer, mapOrGroup) {\n function onChange() {\n const glStyle = mapOrGroup.get('mapbox-style');\n if (!glStyle) {\n return;\n }\n const mapboxLayers = derefLayers(glStyle.layers);\n const layerMapboxLayerids = layer.get('mapbox-layers');\n const visible = mapboxLayers\n .filter(function (mapboxLayer) {\n return layerMapboxLayerids.includes(mapboxLayer.id);\n })\n .some(function (mapboxLayer) {\n return (\n !mapboxLayer.layout ||\n !mapboxLayer.layout.visibility ||\n mapboxLayer.layout.visibility === 'visible'\n );\n });\n if (layer.get('visible') !== visible) {\n layer.setVisible(visible);\n }\n }\n layer.on('change', onChange);\n onChange();\n}\n\nexport function setupLayer(glStyle, styleUrl, glLayer, options) {\n const functionCache = getFunctionCache(glStyle);\n const glLayers = glStyle.layers;\n const type = glLayer.type;\n\n const id = glLayer.source || getSourceIdByRef(glLayers, glLayer.ref);\n const glSource = glStyle.sources[id];\n let layer;\n if (type == 'background') {\n layer = setupBackgroundLayer(glLayer, options, functionCache);\n } else if (glSource.type == 'vector') {\n layer = setupVectorLayer(glSource, styleUrl, options);\n } else if (glSource.type == 'raster') {\n layer = setupRasterLayer(glSource, styleUrl, options);\n layer.setVisible(\n glLayer.layout ? glLayer.layout.visibility !== 'none' : true,\n );\n layer.on('prerender', prerenderRasterLayer(glLayer, layer, functionCache));\n } else if (glSource.type == 'geojson') {\n layer = setupGeoJSONLayer(glSource, styleUrl, options);\n } else if (glSource.type == 'raster-dem' && glLayer.type == 'hillshade') {\n const hillshadeLayer = setupHillshadeLayer(glSource, styleUrl, options);\n layer = hillshadeLayer;\n hillshadeLayer.getSource().on('beforeoperations', function (event) {\n const data = event.data;\n data.resolution = getPointResolution(\n options.projection || 'EPSG:3857',\n event.resolution,\n getCenter(event.extent),\n 'm',\n );\n const zoom = getZoomForResolution(\n event.resolution,\n options.resolutions || defaultResolutions,\n );\n data.encoding = glSource.encoding;\n data.vert =\n 5 *\n getValue(\n glLayer,\n 'paint',\n 'hillshade-exaggeration',\n zoom,\n emptyObj,\n functionCache,\n );\n data.sunAz = getValue(\n glLayer,\n 'paint',\n 'hillshade-illumination-direction',\n zoom,\n emptyObj,\n functionCache,\n );\n data.sunEl = 35;\n data.opacity = 0.3;\n data.highlightColor = getValue(\n glLayer,\n 'paint',\n 'hillshade-highlight-color',\n zoom,\n emptyObj,\n functionCache,\n );\n data.shadowColor = getValue(\n glLayer,\n 'paint',\n 'hillshade-shadow-color',\n zoom,\n emptyObj,\n functionCache,\n );\n data.accentColor = getValue(\n glLayer,\n 'paint',\n 'hillshade-accent-color',\n zoom,\n emptyObj,\n functionCache,\n );\n });\n layer.setVisible(\n glLayer.layout ? glLayer.layout.visibility !== 'none' : true,\n );\n }\n const glSourceId = id;\n if (layer) {\n layer.set('mapbox-source', glSourceId);\n }\n return layer;\n}\n\n/**\n * @param {*} glStyle Mapbox/MapLibre Style.\n * @param {Map|LayerGroup} mapOrGroup Map or layer group.\n * @param {string} styleUrl Style URL.\n * @param {Options} options Options.\n * @return {Promise} Promise that resolves when the style is loaded.\n */\nfunction processStyle(glStyle, mapOrGroup, styleUrl, options) {\n const promises = [];\n\n let view = null;\n if (mapOrGroup instanceof Map) {\n view = mapOrGroup.getView();\n if (!view.isDef() && !view.getRotation() && !view.getResolutions()) {\n const projection = options.projection\n ? getProjection(options.projection)\n : view.getProjection();\n view = new View(\n Object.assign(view.getProperties(), {\n maxResolution:\n defaultResolutions[0] / METERS_PER_UNIT[projection.getUnits()],\n projection: options.projection || view.getProjection(),\n }),\n );\n mapOrGroup.setView(view);\n }\n\n if ('center' in glStyle && !view.getCenter()) {\n view.setCenter(fromLonLat(glStyle.center, view.getProjection()));\n }\n if ('zoom' in glStyle && view.getZoom() === undefined) {\n view.setResolution(\n defaultResolutions[0] /\n METERS_PER_UNIT[view.getProjection().getUnits()] /\n Math.pow(2, glStyle.zoom),\n );\n }\n if (!view.getCenter() || view.getZoom() === undefined) {\n view.fit(view.getProjection().getExtent(), {\n nearest: true,\n size: mapOrGroup.getSize(),\n });\n }\n }\n mapOrGroup.set('mapbox-style', glStyle);\n mapOrGroup.set('mapbox-metadata', {styleUrl, options});\n\n const glLayers = glStyle.layers;\n let layerIds = [];\n\n let layer, glSourceId, id;\n for (let i = 0, ii = glLayers.length; i < ii; ++i) {\n const glLayer = glLayers[i];\n const type = glLayer.type;\n if (type == 'heatmap') {\n //FIXME Unsupported layer type\n // eslint-disable-next-line no-console\n console.debug(`layers[${i}].type \"${type}\" not supported`);\n continue;\n } else {\n id = glLayer.source || getSourceIdByRef(glLayers, glLayer.ref);\n // this technique assumes gl layers will be in a particular order\n if (!id || id != glSourceId) {\n if (layerIds.length) {\n promises.push(\n finalizeLayer(\n layer,\n layerIds,\n glStyle,\n styleUrl,\n mapOrGroup,\n options,\n ),\n );\n layerIds = [];\n }\n\n layer = setupLayer(glStyle, styleUrl, glLayer, options);\n if (\n !(layer instanceof VectorLayer || layer instanceof VectorTileLayer)\n ) {\n layerIds = [];\n }\n glSourceId = layer.get('mapbox-source');\n }\n layerIds.push(glLayer.id);\n }\n }\n promises.push(\n finalizeLayer(layer, layerIds, glStyle, styleUrl, mapOrGroup, options),\n );\n return Promise.all(promises);\n}\n\n/**\n * Loads and applies a Mapbox/MapLibre Style object into an OpenLayers Map or LayerGroup.\n * This includes the map background, the layers, and for Map instances that did not\n * have a View defined yet also the center and the zoom.\n *\n * **Example:**\n * ```js\n * import apply from 'ol-mapbox-style';\n *\n * apply('map', 'mapbox://styles/mapbox/bright-v9', {accessToken: 'YOUR_MAPBOX_TOKEN'});\n * ```\n *\n * The center and zoom will only be set if present in the Mapbox/MapLibre Style document,\n * and if not already set on the OpenLayers map.\n *\n * Layers will be added to the OpenLayers map, without affecting any layers that\n * might already be set on the map.\n *\n * Layers added by `apply()` will have two additional properties:\n *\n * * `mapbox-source`: The `id` of the Mapbox/MapLibre Style document's source that the\n * OpenLayers layer was created from. Usually `apply()` creates one\n * OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has\n * layers from different sources in between.\n * * `mapbox-layers`: The `id`s of the Mapbox/MapLibre Style document's layers that are\n * included in the OpenLayers layer.\n *\n * This function sets an additional `mapbox-style` property on the OpenLayers\n * Map or LayerGroup instance, which holds the Mapbox/MapLibre Style object.\n *\n * @param {Map|HTMLElement|string|LayerGroup} mapOrGroupOrElement Either an existing\n * OpenLayers Map instance, or a HTML element, or the id of a HTML element that will be\n * the target of a new OpenLayers Map, or a layer group. If layer group, styles\n * releated to the map and view will be ignored.\n * @param {string|Object} style JSON style object or style url pointing to a\n * Mapbox/MapLibre Style object. When using Mapbox APIs, the url is the `styleUrl`\n * shown in Mapbox Studio's \"share\" panel. In addition, the `accessToken` option\n * (see below) must be set.\n * When passed as JSON style object, all OpenLayers layers created by `apply()`\n * will be immediately available, but they may not have a source yet (i.e. when\n * they are defined by a TileJSON url in the Mapbox/MapLibre Style document). When passed\n * as style url, layers will be added to the map when the Mapbox/MapLibre Style document\n * is loaded and parsed.\n * @param {Options} options Options.\n * @return {Promise} A promise that resolves after all layers have been added to\n * the OpenLayers Map instance or LayerGroup, their sources set, and their styles applied. The\n * `resolve` callback will be called with the OpenLayers Map instance or LayerGroup as\n * argument.\n */\nexport function apply(mapOrGroupOrElement, style, options = {}) {\n let promise;\n /** @type {Map|LayerGroup} */\n let mapOrGroup;\n if (\n typeof mapOrGroupOrElement === 'string' ||\n mapOrGroupOrElement instanceof HTMLElement\n ) {\n mapOrGroup = new Map({\n target: mapOrGroupOrElement,\n });\n } else {\n mapOrGroup = mapOrGroupOrElement;\n }\n\n if (typeof style === 'string') {\n const styleUrl = style.startsWith('data:')\n ? location.href\n : normalizeStyleUrl(style, options.accessToken);\n options = completeOptions(styleUrl, options);\n\n promise = new Promise(function (resolve, reject) {\n getGlStyle(style, options)\n .then(function (glStyle) {\n processStyle(glStyle, mapOrGroup, styleUrl, options)\n .then(function () {\n resolve(mapOrGroup);\n })\n .catch(reject);\n })\n .catch(function (err) {\n reject(new Error(`Could not load ${style}: ${err.message}`));\n });\n });\n } else {\n promise = new Promise(function (resolve, reject) {\n processStyle(\n style,\n mapOrGroup,\n !options.styleUrl || options.styleUrl.startsWith('data:')\n ? location.href\n : normalizeStyleUrl(options.styleUrl, options.accessToken),\n options,\n )\n .then(function () {\n resolve(mapOrGroup);\n })\n .catch(reject);\n });\n }\n\n return promise;\n}\n\n/**\n * If layerIds is not empty, applies the style specified in glStyle to the layer,\n * and adds the layer to the map.\n *\n * The layer may not yet have a source when the function is called. If so, the style\n * is applied to the layer via a once listener on the 'change:source' event.\n *\n * @param {Layer} layer An OpenLayers layer instance.\n * @param {Array} layerIds Array containing layer ids of already-processed layers.\n * @param {Object} glStyle Style as a JSON object.\n * @param {string|undefined} styleUrl The original style URL. Only required\n * when a relative path is used with the `\"sprite\"` property of the style.\n * @param {Map|LayerGroup} mapOrGroup OpenLayers Map.\n * @param {Options} options Options.\n * @return {Promise} Returns a promise that resolves after the source has\n * been set on the specified layer, and the style has been applied.\n */\nexport function finalizeLayer(\n layer,\n layerIds,\n glStyle,\n styleUrl,\n mapOrGroup,\n options = {},\n) {\n let minZoom = 24;\n let maxZoom = 0;\n const glLayers = glStyle.layers;\n for (let i = 0, ii = glLayers.length; i < ii; ++i) {\n const glLayer = glLayers[i];\n if (layerIds.indexOf(glLayer.id) !== -1) {\n minZoom = Math.min('minzoom' in glLayer ? glLayer.minzoom : 0, minZoom);\n maxZoom = Math.max('maxzoom' in glLayer ? glLayer.maxzoom : 24, maxZoom);\n }\n }\n return new Promise(function (resolve, reject) {\n const setStyle = function () {\n const source = layer.getSource();\n if (!source || source.getState() === 'error') {\n reject(\n new Error(\n 'Error accessing data for source ' + layer.get('mapbox-source'),\n ),\n );\n return;\n }\n if ('getTileGrid' in source) {\n const tileGrid =\n /** @type {import(\"ol/source/Tile.js\").default|import(\"ol/source/VectorTile.js\").default} */ (\n source\n ).getTileGrid();\n if (tileGrid) {\n const sourceMinZoom = tileGrid.getMinZoom();\n if (minZoom > 0 || sourceMinZoom > 0) {\n layer.setMaxResolution(\n Math.min(\n getResolutionForZoom(\n Math.max(0, minZoom - 1e-12),\n defaultResolutions,\n ),\n getResolutionForZoom(\n Math.max(0, sourceMinZoom - 1e-12),\n tileGrid.getResolutions(),\n ),\n ),\n );\n }\n if (maxZoom < 24) {\n layer.setMinResolution(\n getResolutionForZoom(maxZoom, defaultResolutions),\n );\n }\n }\n } else {\n if (minZoom > 0) {\n layer.setMaxResolution(\n getResolutionForZoom(\n Math.max(0, minZoom - 1e-12),\n defaultResolutions,\n ),\n );\n }\n }\n if (\n source instanceof VectorSource ||\n source instanceof VectorTileSource\n ) {\n applyStyle(\n /** @type {import(\"ol/layer/Vector\").default|import(\"ol/layer/VectorTile\").default} */ (\n layer\n ),\n glStyle,\n layerIds,\n Object.assign({styleUrl: styleUrl}, options),\n )\n .then(function () {\n manageVisibility(layer, mapOrGroup);\n resolve();\n })\n .catch(reject);\n } else {\n resolve();\n }\n };\n\n layer.set('mapbox-layers', layerIds);\n const layers = mapOrGroup.getLayers();\n if (layers.getArray().indexOf(layer) === -1) {\n layers.push(layer);\n }\n\n if (layer.getSource()) {\n setStyle();\n } else {\n layer.once('change:source', setStyle);\n }\n });\n}\n\n/**\n * Get the Mapbox Layer object for the provided `layerId`.\n * @param {Map|LayerGroup} mapOrGroup Map or LayerGroup.\n * @param {string} layerId Mapbox Layer id.\n * @return {Object} Mapbox Layer object.\n */\nexport function getMapboxLayer(mapOrGroup, layerId) {\n const style = mapOrGroup.get('mapbox-style');\n const layerStyle = style.layers.find(function (layer) {\n return layer.id === layerId;\n });\n return layerStyle;\n}\n\n/**\n * Add a new Mapbox Layer object to the style. The map will be re-rendered.\n * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.\n * @param {Object} mapboxLayer Mapbox Layer object.\n * @param {string} [beforeLayerId] Optional id of the Mapbox Layer before the new layer that will be added.\n * @return {Promise} Resolves when the added layer is available.\n */\nexport function addMapboxLayer(mapOrGroup, mapboxLayer, beforeLayerId) {\n const glStyle = mapOrGroup.get('mapbox-style');\n const mapboxLayers = glStyle.layers;\n let spliceIndex;\n let sourceIndex = -1;\n if (beforeLayerId !== undefined) {\n const beforeMapboxLayer = getMapboxLayer(mapOrGroup, beforeLayerId);\n if (beforeMapboxLayer === undefined) {\n throw new Error(`Layer with id \"${beforeLayerId}\" not found.`);\n }\n spliceIndex = mapboxLayers.indexOf(beforeMapboxLayer);\n } else {\n spliceIndex = mapboxLayers.length;\n }\n let sourceOffset;\n if (\n spliceIndex > 0 &&\n mapboxLayers[spliceIndex - 1].source === mapboxLayer.source\n ) {\n sourceIndex = spliceIndex - 1;\n sourceOffset = -1;\n } else if (\n spliceIndex < mapboxLayers.length &&\n mapboxLayers[spliceIndex].source === mapboxLayer.source\n ) {\n sourceIndex = spliceIndex;\n sourceOffset = 0;\n }\n if (sourceIndex === -1) {\n const {options, styleUrl} = mapOrGroup.get('mapbox-metadata');\n const layer = setupLayer(glStyle, styleUrl, mapboxLayer, options);\n if (beforeLayerId) {\n const beforeLayer = getLayer(mapOrGroup, beforeLayerId);\n const beforeLayerIndex = mapOrGroup\n .getLayers()\n .getArray()\n .indexOf(beforeLayer);\n mapOrGroup.getLayers().insertAt(beforeLayerIndex, layer);\n }\n mapboxLayers.splice(spliceIndex, 0, mapboxLayer);\n return finalizeLayer(\n layer,\n [mapboxLayer.id],\n glStyle,\n styleUrl,\n mapOrGroup,\n options,\n );\n }\n\n if (mapboxLayers.some((layer) => layer.id === mapboxLayer.id)) {\n throw new Error(`Layer with id \"${mapboxLayer.id}\" already exists.`);\n }\n const sourceLayerId = mapboxLayers[sourceIndex].id;\n const args =\n styleFunctionArgs[\n getStyleFunctionKey(\n mapOrGroup.get('mapbox-style'),\n getLayer(mapOrGroup, sourceLayerId),\n )\n ];\n mapboxLayers.splice(spliceIndex, 0, mapboxLayer);\n if (args) {\n const [\n olLayer,\n glStyle,\n sourceOrLayers,\n resolutions,\n spriteData,\n spriteImageUrl,\n getFonts,\n getImage,\n ] = args;\n if (Array.isArray(sourceOrLayers)) {\n const layerIndex = sourceOrLayers.indexOf(sourceLayerId) + sourceOffset;\n sourceOrLayers.splice(layerIndex, 0, mapboxLayer.id);\n }\n applyStylefunction(\n olLayer,\n glStyle,\n sourceOrLayers,\n resolutions,\n spriteData,\n spriteImageUrl,\n getFonts,\n getImage,\n );\n } else {\n getLayer(mapOrGroup, mapboxLayers[sourceIndex].id).changed();\n }\n return Promise.resolve();\n}\n\n/**\n * Update a Mapbox Layer object in the style. The map will be re-rendered with the new style.\n * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.\n * @param {Object} mapboxLayer Updated Mapbox Layer object.\n */\nexport function updateMapboxLayer(mapOrGroup, mapboxLayer) {\n const glStyle = mapOrGroup.get('mapbox-style');\n const mapboxLayers = glStyle.layers;\n const index = mapboxLayers.findIndex(function (layer) {\n return layer.id === mapboxLayer.id;\n });\n if (index === -1) {\n throw new Error(`Layer with id \"${mapboxLayer.id}\" not found.`);\n }\n const oldLayer = mapboxLayers[index];\n if (oldLayer.source !== mapboxLayer.source) {\n throw new Error(\n 'Updated layer and previous version must use the same source.',\n );\n }\n delete getFunctionCache(glStyle)[mapboxLayer.id];\n delete getFilterCache(glStyle)[mapboxLayer.id];\n mapboxLayers[index] = mapboxLayer;\n const args =\n styleFunctionArgs[\n getStyleFunctionKey(\n mapOrGroup.get('mapbox-style'),\n getLayer(mapOrGroup, mapboxLayer.id),\n )\n ];\n if (args) {\n applyStylefunction.apply(undefined, args);\n } else {\n getLayer(mapOrGroup, mapboxLayer.id).changed();\n }\n}\n\n/**\n * Updates a Mapbox source object in the style. The according OpenLayers source will be replaced\n * and the map will be re-rendered.\n * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.\n * @param {string} id Key of the source in the `sources` object literal.\n * @param {Object} mapboxSource Mapbox source object.\n * @return {Promise} Promise that resolves when the source has been updated.\n */\nexport function updateMapboxSource(mapOrGroup, id, mapboxSource) {\n const currentSource = getSource(mapOrGroup, id);\n const layers = /** @type {Array} */ (\n mapOrGroup\n .getLayers()\n .getArray()\n .filter(function (layer) {\n return (\n (layer instanceof VectorLayer ||\n layer instanceof TileLayer ||\n layer instanceof VectorTileLayer) &&\n layer.getSource() === currentSource\n );\n })\n );\n const metadata = mapOrGroup.get('mapbox-metadata');\n let newSourcePromise;\n switch (mapboxSource.type) {\n case 'vector':\n newSourcePromise = setupVectorSource(\n mapboxSource,\n metadata.styleUrl,\n metadata.options,\n );\n break;\n case 'geojson':\n newSourcePromise = Promise.resolve(\n setupGeoJSONSource(mapboxSource, metadata.styleUrl, metadata.options),\n );\n break;\n case 'raster':\n case 'raster-dem':\n newSourcePromise = setupRasterSource(\n mapboxSource,\n metadata.styleUrl,\n metadata.options,\n );\n break;\n default:\n return Promise.reject(\n new Error('Unsupported source type ' + mapboxSource.type),\n );\n }\n newSourcePromise.then(function (newSource) {\n layers.forEach(function (layer) {\n layer.setSource(newSource);\n });\n });\n return newSourcePromise;\n}\n\n/**\n * Remove a Mapbox Layer object from the style. The map will be re-rendered.\n * @param {Map|LayerGroup} mapOrGroup The Map or LayerGroup `apply` was called on.\n * @param {string|Object} mapboxLayerIdOrLayer Mapbox Layer id or Mapbox Layer object.\n */\nexport function removeMapboxLayer(mapOrGroup, mapboxLayerIdOrLayer) {\n const mapboxLayerId =\n typeof mapboxLayerIdOrLayer === 'string'\n ? mapboxLayerIdOrLayer\n : mapboxLayerIdOrLayer.id;\n const layer = getLayer(mapOrGroup, mapboxLayerId);\n /** @type {Array} */\n const layerMapboxLayers = layer.get('mapbox-layers');\n if (layerMapboxLayers.length === 1) {\n throw new Error(\n 'Cannot remove last Mapbox layer from an OpenLayers layer.',\n );\n }\n layerMapboxLayers.splice(layerMapboxLayers.indexOf(mapboxLayerId), 1);\n const glStyle = mapOrGroup.get('mapbox-style');\n const layers = glStyle.layers;\n layers.splice(\n layers.findIndex((layer) => layer.id === mapboxLayerId),\n 1,\n );\n const args = styleFunctionArgs[getStyleFunctionKey(glStyle, layer)];\n if (args) {\n const [\n olLayer,\n glStyle,\n sourceOrLayers,\n resolutions,\n spriteData,\n spriteImageUrl,\n getFonts,\n getImage,\n ] = args;\n if (Array.isArray(sourceOrLayers)) {\n sourceOrLayers.splice(\n sourceOrLayers.findIndex((layer) => layer === mapboxLayerId),\n 1,\n );\n }\n applyStylefunction(\n olLayer,\n glStyle,\n sourceOrLayers,\n resolutions,\n spriteData,\n spriteImageUrl,\n getFonts,\n getImage,\n );\n } else {\n getLayer(mapOrGroup, mapboxLayerId).changed();\n }\n}\n\n/**\n * Get the OpenLayers layer instance that contains the provided Mapbox/MapLibre Style\n * `layer`. Note that multiple Mapbox/MapLibre Style layers are combined in a single\n * OpenLayers layer instance when they use the same Mapbox/MapLibre Style `source`.\n * @param {Map|LayerGroup} map OpenLayers Map or LayerGroup.\n * @param {string} layerId Mapbox/MapLibre Style layer id.\n * @return {Layer} OpenLayers layer instance.\n */\nexport function getLayer(map, layerId) {\n const layers = map.getLayers().getArray();\n for (let i = 0, ii = layers.length; i < ii; ++i) {\n const mapboxLayers = layers[i].get('mapbox-layers');\n if (mapboxLayers && mapboxLayers.indexOf(layerId) !== -1) {\n return /** @type {Layer} */ (layers[i]);\n }\n }\n return undefined;\n}\n\n/**\n * Get the OpenLayers layer instances for the provided Mapbox/MapLibre Style `source`.\n * @param {Map|LayerGroup} map OpenLayers Map or LayerGroup.\n * @param {string} sourceId Mapbox/MapLibre Style source id.\n * @return {Array} OpenLayers layer instances.\n */\nexport function getLayers(map, sourceId) {\n const result = [];\n const layers = map.getLayers().getArray();\n for (let i = 0, ii = layers.length; i < ii; ++i) {\n if (layers[i].get('mapbox-source') === sourceId) {\n result.push(/** @type {Layer} */ (layers[i]));\n }\n }\n return result;\n}\n\n/**\n * Get the OpenLayers source instance for the provided Mapbox/MapLibre Style `source`.\n * @param {Map|LayerGroup} map OpenLayers Map or LayerGroup.\n * @param {string} sourceId Mapbox/MapLibre Style source id.\n * @return {Source} OpenLayers source instance.\n */\nexport function getSource(map, sourceId) {\n const layers = map.getLayers().getArray();\n for (let i = 0, ii = layers.length; i < ii; ++i) {\n const source = /** @type {Layer} */ (layers[i]).getSource();\n if (layers[i].get('mapbox-source') === sourceId) {\n return source;\n }\n }\n return undefined;\n}\n\n/**\n * Sets or removes a feature state. The feature state is taken into account for styling,\n * just like the feature's properties, and can be used e.g. to conditionally render selected\n * features differently.\n *\n * The feature state will be stored on the OpenLayers layer matching the feature identifier, in the\n * `mapbox-featurestate` property.\n * @param {Map|VectorLayer|VectorTileLayer} mapOrLayer OpenLayers Map or layer to set the feature\n * state on.\n * @param {FeatureIdentifier} feature Feature identifier.\n * @param {Object|null} state Feature state. Set to `null` to remove the feature state.\n */\nexport function setFeatureState(mapOrLayer, feature, state) {\n const layers =\n 'getLayers' in mapOrLayer\n ? getLayers(mapOrLayer, feature.source)\n : [mapOrLayer];\n for (let i = 0, ii = layers.length; i < ii; ++i) {\n const featureState = layers[i].get('mapbox-featurestate');\n if (featureState) {\n if (state) {\n featureState[feature.id] = state;\n } else {\n delete featureState[feature.id];\n }\n layers[i].changed();\n } else {\n throw new Error(`Map or layer for source \"${feature.source}\" not found.`);\n }\n }\n}\n\n/**\n * Sets or removes a feature state. The feature state is taken into account for styling,\n * just like the feature's properties, and can be used e.g. to conditionally render selected\n * features differently.\n * @param {Map|VectorLayer|VectorTileLayer} mapOrLayer Map or layer to set the feature state on.\n * @param {FeatureIdentifier} feature Feature identifier.\n * @return {Object|null} Feature state or `null` when no feature state is set for the given\n * feature identifier.\n */\nexport function getFeatureState(mapOrLayer, feature) {\n const layers =\n 'getLayers' in mapOrLayer\n ? getLayers(mapOrLayer, feature.source)\n : [mapOrLayer];\n for (let i = 0, ii = layers.length; i < ii; ++i) {\n const featureState = layers[i].get('mapbox-featurestate');\n if (featureState && featureState[feature.id]) {\n return featureState[feature.id];\n }\n }\n return undefined;\n}\n","import BaseEvent from 'ol/events/Event.js';\nimport EventType from 'ol/events/EventType.js';\nimport MVT from 'ol/format/MVT.js';\nimport VectorTileLayer from 'ol/layer/VectorTile.js';\nimport VectorTileSource from 'ol/source/VectorTile.js';\nimport {applyBackground, applyStyle} from './apply.js';\n\n/** @typedef {import(\"ol/Map.js\").default} Map */\n\n/**\n * Event emitted on configuration or loading error.\n */\nclass ErrorEvent extends BaseEvent {\n /**\n * @param {Error} error error object.\n */\n constructor(error) {\n super(EventType.ERROR);\n\n /**\n * @type {Error}\n */\n this.error = error;\n }\n}\n\n/**\n * @typedef {Object} Options\n * @property {string} styleUrl The URL of the Mapbox/MapLibre Style object to use for this layer. For a\n * style created with Mapbox Studio and hosted on Mapbox, this will look like\n * 'mapbox://styles/you/your-style'.\n * @property {string} [accessToken] The access token for your Mapbox/MapLibre style. This has to be provided\n * for `mapbox://` style urls. For `https://` and other urls, any access key must be the last query\n * parameter of the style url.\n * @property {string} [source] If your style uses more than one source, you need to use either the\n * `source` property or the `layers` property to limit rendering to a single vector source. The\n * `source` property corresponds to the id of a vector source in your Mapbox/MapLibre style.\n * @property {Array} [layers] Limit rendering to the list of included layers. All layers\n * must share the same vector source. If your style uses more than one source, you need to use\n * either the `source` property or the `layers` property to limit rendering to a single vector\n * source.\n * @property {boolean} [declutter=true] Declutter images and text. Decluttering is applied to all\n * image and text styles of all Vector and VectorTile layers that have set this to `true`. The priority\n * is defined by the z-index of the layer, the `zIndex` of the style and the render order of features.\n * Higher z-index means higher priority. Within the same z-index, a feature rendered before another has\n * higher priority.\n *\n * As an optimization decluttered features from layers with the same `className` are rendered above\n * the fill and stroke styles of all of those layers regardless of z-index. To opt out of this\n * behavior and place declutterd features with their own layer configure the layer with a `className`\n * other than `ol-layer`.\n * @property {import(\"ol/layer/Base.js\").BackgroundColor|false} [background] Background color for the layer.\n * If not specified, the background from the Mapbox/MapLibre Style object will be used. Set to `false` to prevent\n * the Mapbox/MapLibre style's background from being used.\n * @property {string} [className='ol-layer'] A CSS class name to set to the layer element.\n * @property {number} [opacity=1] Opacity (0, 1).\n * @property {boolean} [visible=true] Visibility.\n * @property {import(\"ol/extent.js\").Extent} [extent] The bounding extent for layer rendering. The layer will not be\n * rendered outside of this extent.\n * @property {number} [zIndex] The z-index for layer rendering. At rendering time, the layers\n * will be ordered, first by Z-index and then by position. When `undefined`, a `zIndex` of 0 is assumed\n * for layers that are added to the map's `layers` collection, or `Infinity` when the layer's `setMap()`\n * method was used.\n * @property {number} [minResolution] The minimum resolution (inclusive) at which this layer will be\n * visible.\n * @property {number} [maxResolution] The maximum resolution (exclusive) below which this layer will\n * be visible. If neither `maxResolution` nor `minZoom` are defined, the layer's `maxResolution` will\n * match the style source's `minzoom`.\n * @property {number} [minZoom] The minimum view zoom level (exclusive) above which this layer will\n * be visible. If neither `maxResolution` nor `minZoom` are defined, the layer's `minZoom` will match\n * the style source's `minzoom`.\n * @property {number} [maxZoom] The maximum view zoom level (inclusive) at which this layer will\n * be visible.\n * @property {import(\"ol/render.js\").OrderFunction} [renderOrder] Render order. Function to be used when sorting\n * features before rendering. By default features are drawn in the order that they are created. Use\n * `null` to avoid the sort, but get an undefined draw order.\n * @property {number} [renderBuffer=100] The buffer in pixels around the tile extent used by the\n * renderer when getting features from the vector tile for the rendering or hit-detection.\n * Recommended value: Vector tiles are usually generated with a buffer, so this value should match\n * the largest possible buffer of the used tiles. It should be at least the size of the largest\n * point symbol or line width.\n * @property {import(\"ol/layer/VectorTile.js\").VectorTileRenderType} [renderMode='hybrid'] Render mode for vector tiles:\n * * `'hybrid'`: Polygon and line elements are rendered as images, so pixels are scaled during zoom\n * animations. Point symbols and texts are accurately rendered as vectors and can stay upright on\n * rotated views.\n * * `'vector'`: Everything is rendered as vectors. Use this mode for improved performance on vector\n * tile layers with only a few rendered features (e.g. for highlighting a subset of features of\n * another layer with the same source).\n * @property {import(\"ol/Map.js\").default} [map] Sets the layer as overlay on a map. The map will not manage\n * this layer in its layers collection, and the layer will be rendered on top. This is useful for\n * temporary layers. The standard way to add a layer to a map and have it managed by the map is to\n * use `map.addLayer()`.\n * @property {boolean} [updateWhileAnimating=false] When set to `true`, feature batches will be\n * recreated during animations. This means that no vectors will be shown clipped, but the setting\n * will have a performance impact for large amounts of vector data. When set to `false`, batches\n * will be recreated when no animation is active.\n * @property {boolean} [updateWhileInteracting=false] When set to `true`, feature batches will be\n * recreated during interactions. See also `updateWhileAnimating`.\n * @property {number} [preload=0] Preload. Load low-resolution tiles up to `preload` levels. `0`\n * means no preloading.\n * @property {boolean} [useInterimTilesOnError=true] Use interim tiles on error.\n * @property {Object} [properties] Arbitrary observable properties. Can be accessed with `#get()` and `#set()`.\n */\n\n/**\n * ```js\n * import {MapboxVectorLayer} from 'ol-mapbox-style';\n * ```\n * A vector tile layer based on a Mapbox/MapLibre style that uses a single vector source. Configure\n * the layer with the `styleUrl` and `accessToken` shown in Mapbox Studio's share panel.\n * If the style uses more than one source, use the `source` property to choose a single\n * vector source. If you want to render a subset of the layers in the style, use the `layers`\n * property (all layers must share the same vector source). See the constructor options for\n * more detail.\n *\n * const map = new Map({\n * view: new View({\n * center: [0, 0],\n * zoom: 1,\n * }),\n * layers: [\n * new MapboxVectorLayer({\n * styleUrl: 'mapbox://styles/mapbox/bright-v9',\n * accessToken: 'your-mapbox-access-token-here',\n * }),\n * ],\n * target: 'map',\n * });\n *\n * On configuration or loading error, the layer will trigger an `'error'` event. Listeners\n * will receive an object with an `error` property that can be used to diagnose the problem.\n *\n * Instances of this class emit an `error` event when an error occurs during style loading:\n *\n * layer.on('error', function() {\n * console.error('Error loading style');\n * }\n *\n * **Note for users of the full build**: The `MapboxVectorLayer` requires the\n * [ol-mapbox-style](https://github.com/openlayers/ol-mapbox-style) library to be loaded as well.\n *\n * @param {Options} options Options.\n * @extends {VectorTileLayer}\n */\nexport default class MapboxVectorLayer extends VectorTileLayer {\n /**\n * @param {Options} options Layer options. At a minimum, `styleUrl` and `accessToken`\n * must be provided.\n */\n constructor(options) {\n const declutter = 'declutter' in options ? options.declutter : true;\n const source = new VectorTileSource({\n state: 'loading',\n format: new MVT(),\n });\n\n super({\n source: source,\n background: options.background === false ? null : options.background,\n declutter: declutter,\n className: options.className,\n opacity: options.opacity,\n visible: options.visible,\n zIndex: options.zIndex,\n minResolution: options.minResolution,\n maxResolution: options.maxResolution,\n minZoom: options.minZoom,\n maxZoom: options.maxZoom,\n renderOrder: options.renderOrder,\n renderBuffer: options.renderBuffer,\n renderMode: options.renderMode,\n map: options.map,\n updateWhileAnimating: options.updateWhileAnimating,\n updateWhileInteracting: options.updateWhileInteracting,\n preload: options.preload,\n useInterimTilesOnError: options.useInterimTilesOnError,\n properties: options.properties,\n });\n\n if (options.accessToken) {\n this.accessToken = options.accessToken;\n }\n const url = options.styleUrl;\n const promises = [\n applyStyle(this, url, options.layers || options.source, {\n accessToken: this.accessToken,\n }),\n ];\n if (this.getBackground() === undefined) {\n promises.push(\n applyBackground(this, options.styleUrl, {\n accessToken: this.accessToken,\n }),\n );\n }\n Promise.all(promises)\n .then(() => {\n source.setState('ready');\n })\n .catch((error) => {\n this.dispatchEvent(new ErrorEvent(error));\n const source = this.getSource();\n source.setState('error');\n });\n }\n}\n"],"names":["v8Spec","$version","$root","version","required","type","values","name","metadata","center","value","centerAltitude","zoom","bearing","default","period","units","pitch","roll","light","sky","projection","terrain","sources","sprite","glyphs","transition","layers","source","source_vector","vector","url","tiles","bounds","length","scheme","xyz","tms","minzoom","maxzoom","attribution","promoteId","volatile","source_raster","raster","tileSize","source_raster_dem","encoding","terrarium","mapbox","custom","redFactor","blueFactor","greenFactor","baseShift","source_geojson","geojson","data","buffer","maximum","minimum","filter","tolerance","cluster","clusterRadius","clusterMaxZoom","clusterMinPoints","clusterProperties","lineMetrics","generateId","source_video","video","urls","coordinates","source_image","image","layer","id","fill","line","symbol","circle","heatmap","hillshade","background","layout","paint","layout_background","visibility","visible","none","layout_fill","expression","interpolated","parameters","layout_circle","layout_heatmap","layout_line","butt","round","square","bevel","miter","requires","layout_symbol","point","auto","never","always","cooperative","map","viewport","width","height","both","tokens","left","right","top","bottom","horizontal","vertical","uppercase","lowercase","layout_raster","layout_hillshade","filter_operator","in","all","any","has","geometry_type","Point","LineString","Polygon","function","stops","base","property","identity","exponential","interval","categorical","colorSpace","rgb","lab","hcl","function_stop","anchor","position","color","intensity","exaggeration","paint_fill","paint_line","paint_circle","paint_heatmap","paint_symbol","overridable","paint_raster","linear","nearest","paint_hillshade","paint_background","duration","delay","constant","refProperties","deref","parent","result","k","forEach","derefLayers","slice","Object","create","i","ref","ExpressionParsingError","Error","constructor","key","message","super","this","Scope","bindings","concat","get","NullType","kind","NumberType","StringType","BooleanType","ColorType","ProjectionDefinitionType","ObjectType","ValueType","CollatorType","FormattedType","PaddingType","ResolvedImageType","VariableAnchorOffsetCollectionType","array","itemType","N","typeToString","valueMemberTypes","checkSubtype","expected","t","memberType","isValidType","provided","allowedTypes","some","isValidNativeType","Array","isArray","verifyType","sample","Xn","Yn","Zn","t0","t1","t2","t3","deg2rad","Math","PI","rad2deg","constrainAngle","angle","rgbToLab","r","g","b","alpha","x","z","y","xyz2lab","rgb2xyz","l","pow","labToRgb","a","isNaN","lab2xyz","xyz2rgb","parseCssColor","input","toLowerCase","trim","namedColorsMatch","namedColors","startsWith","test","step","parseHex","rgbRegExp","rgbMatch","match","_","rp","f1","gp","f2","bp","f3","ap","argFormat","join","valFormat","maxValue","rgba","clamp","parseAlpha","validateNumbers","hslMatch","h","s","hsla","f","n","min","max","hslToRgb","hex","parseInt","padEnd","asPercentage","Number","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","interpolateNumber","from","to","interpolateArray","d","Color","premultiplied","overwriteGetter","parse","Infinity","rgbColor","c","sqrt","atan2","NaN","rgbToHcl","getterKey","lazyValue","defineProperty","toString","interpolate","spaceKey","hue0","chroma0","light0","alphaF","hue1","chroma1","light1","alphaT","hue","chroma","dh","cos","sin","hclToRgb","transparent","Collator","caseSensitive","diacriticSensitive","locale","sensitivity","collator","Intl","usage","compare","lhs","rhs","resolvedLocale","resolvedOptions","VERTICAL_ALIGN_OPTIONS","FormattedSection","text","scale","fontStack","textColor","verticalAlign","Formatted","sections","fromString","unformatted","isEmpty","section","factory","Padding","val","JSON","stringify","RuntimeError","toJSON","anchors","Set","VariableAnchorOffsetCollection","anchorValue","offsetValue","fromValues","toValues","output","push","fx","fy","tx","ty","ResolvedImage","options","available","ProjectionDefinition","validateRGBA","isValue","mixed","item","typeOf","valueToString","String","Literal","args","context","error","expectedType","evaluate","eachChild","outputDefined","types$1","string","number","boolean","object","Assertion","floor","parsed","ctx","fn","every","arg","types","Coercion","Boolean","parseColor","pad","coll","num","geometryTypes","EvaluationContext","globals","feature","featureState","formattedSection","_parseColorCache","availableImages","canonical","geometryType","geometry","canonicalID","properties","cached","ParsingContext","registry","isConstantFunc","path","scope","errors","part","_isConstant","expr","index","_parse","annotate","typeAnnotation","op","Expr","actual","ec","e","keys","Let","binding","Var","boundExpression","At","In","needle","haystack","indexOf","IndexOf","fromIndex","rawIndex","Match","inputType","outputType","cases","outputs","otherwise","labels","labelContext","label","abs","MAX_SAFE_INTEGER","out","Case","branches","Slice","beginIndex","endIndex","findStopLessThanOrEqualTo","lastIndex","currentValue","nextValue","lowerIndex","upperIndex","currentIndex","Step","labelKey","valueKey","stopCount","getDefaultExportFromCjs","__esModule","prototype","hasOwnProperty","call","unitbezier","hasRequiredUnitbezier","unitbezierExports","UnitBezier","p1x","p1y","p2x","p2y","cx","bx","ax","cy","by","ay","sampleCurveX","sampleCurveY","sampleCurveDerivativeX","solveCurveX","epsilon","undefined","x2","d2","solve","requireUnitbezier","Interpolate","operator","interpolation","interpolationFactor","lower","upper","exponentialInterpolation","controlPoints","rest","outputLower","outputUpper","lowerValue","upperValue","difference","progress","Coalesce","parsedArgs","needsAnnotation","requestedImageName","argCount","isComparableType","eqCollate","makeComparison","compareBasic","compareWithCollator","isOrderComparison","Comparison","hasUntypedArgument","lt","rt","Equals","NotEquals","LessThan","GreaterThan","LessThanOrEqual","GreaterThanOrEqual","CollatorExpression","NumberFormat","currency","minFractionDigits","maxFractionDigits","style","minimumFractionDigits","maximumFractionDigits","format","FormatExpression","firstArg","nextTokenMayBeObject","font","includes","lastExpression","content","evaluatedContent","ImageExpression","evaluatedImageName","Length","EXTENT","getTileCoordinates","p","lat","log","tilesAtZoom","getLngLatFromTileCoord","coord","mercatorX","mercatorY","atan","exp","updateBBox","bbox","boxWithinBox","bbox1","bbox2","pointOnBoundary","p1","p2","x1","y1","y2","segmentIntersectSegment","vectorP","vectorQ","v1","v2","twoSided","lineIntersectPolygon","polygon","ring","j","pointWithinPolygon","rings","trueIfOnBoundary","inside","pointWithinPolygons","polygons","lineStringWithinPolygon","lineStringWithinPolygons","q1","q2","x3","y3","det1","det2","getTilePolygon","getTilePolygons","updatePoint","polyBBox","worldSize","halfWorldSize","shift","getTilePoints","pointBBox","shifts","tilePoints","points","getTileLines","lineBBox","tileLines","tileLine","Within","geometries","polygonsCoords","features","polygonGeometry","tilePolygon","tilePolygons","pointsWithinPolygons","linesWithinPolygons","TinyQueue","_down","_up","pop","peek","pos","current","halfLength","bestChild","quickselect","arr","defaultCompare","m","sd","swap","tmp","compareAreas","area","calculateSignedArea","sum","len","FE","E2","RAD","CheapRuler","coslat","w2","w","kx","ky","distance","dx","wrap","dy","pointOnLine","minX","minY","minI","minT","minDist","sqDist","deg","MinPointsSize","MinLinePointsSize","compareDistPair","getRangeSize","range","isRangeSafe","threshold","splitRange","isLine","size","size1","getBBox","coords","getPolygonBBox","isValidBBox","bboxToBBoxDistance","ruler","pointToLineDistance","nearestPoint","segmentToSegmentDistance","dist1","dist2","lineToLineDistance","line1","range1","line2","range2","dist","pointsToPointsDistance","points1","points2","pointToPolygonDistance","front","back","lineToPolygonDistance","polygonIntersect","poly1","poly2","polygonToPolygonDistance","polygon1","polygon2","currentMiniDist","ring1","len1","ring2","len2","updateQueue","distQueue","miniDist","rangeA","tempDist","updateQueueTwoSets","pointSet1","pointSet2","pointsToPolygonDistance","distPair","newRangesA","pointSetToPointSetDistance","isLine1","isLine2","rangeB","threshold1","threshold2","sublibe","newRangesB","polygonToGeometryDistance","maxRings","ccw","classifyRings","toSimpleGeometry","lineString","Distance","flat","pointPosition","pointToGeometryDistance","linePositions","lineStringToGeometryDistance","expressions$1","at","case","coalesce","let","literal","var","within","CompoundExpression","_evaluate","definition","definitions","availableOverloads","overloads","signature","signatureContext","params","isExpressionConstant","argParseFailed","signatures","stringifySignature","actualTypes","register","obj","v","varargs","isTypeAnnotation","childrenConstant","child","isFeatureConstant","isGlobalPropertyConstant","isStateConstant","success","isFunction$1","typeof","heatmapDensity","lineProgress","accumulated","ln2","LN2","pi","E","log10","LN10","ln","log2","asin","acos","ceil","binarySearch","isSupportedScript","upcase","toUpperCase","downcase","StyleExpression","propertySpec","spec","_warningHistory","_evaluator","_defaultValue","_enumValues","evaluateWithoutErrorHandling","console","warn","createExpression","parser","enum","formatted","padding","projectionDefinition","resolvedImage","variableAnchorOffsetCollection","getExpectedType","ZoomConstantExpression","_styleExpression","isStateDependent","ZoomDependentExpression","zoomStops","interpolationType","createPropertyExpression","expressionInput","isFeatureConstantResult","isZoomConstant","supportsZoomExpression","zoomCurve","findZoomCurve","supportsInterpolation","childResult","isExpressionFilter","filterSpec","featureFilter","needGeometry","convertFilter$1","compiled","err","globalProperties","geometryNeeded","filters","convertComparisonOp$1","convertNegation","convertInOp$1","convertHasOp$1","sort","convertLiteral","convertFunction","splice","convertIdentityFunction","zoomAndFeatureDependent","featureDependent","zoomDependent","stop","convertTokenString","featureFunctionParameters","featureFunctionStops","functionType","getFunctionType","getInterpolateOperator","appendStopPair","convertPropertyFunction","fixupDegenerateStepCurve","convertZoomAndPropertyFunction","isStep","convertZoomFunction","getFallback","defaultValue","curve","re","exec","v8","fontWeights","thin","hairline","book","regular","normal","plain","roman","standard","medium","bold","heavy","fat","poster","sp","italicRE","fontCache","mb2css","fonts","lineHeight","cssData","haveWeight","haveStyle","weight","fontFamilies","ii","parts","split","maybeWeight","replace","previousPart","fontFamily","mapboxBaseUrl","getMapboxPath","normalizeStyleUrl","token","mapboxPath","decodeURI","URL","location","href","mapboxSubdomains","normalizeSourceUrl","tokenParam","styleUrl","urlObject","searchParams","set","sizeFactor","window","devicePixelRatio","sub","functionCacheByStyleId","filterCacheByStyleId","styleId","getStyleId","glStyle","getStyleFunctionKey","olLayer","getUid","getFunctionCache","functionCache","getFilterCache","filterCache","degrees","defaultResolutions","resolutions","res","createCanvas","WorkerGlobalScope","self","OffscreenCanvas","canvas","document","createElement","getZoomForResolution","resolution","zoomFactor","getResolutionForZoom","factor","pendingRequests","fetchResource","resourceType","request","transformedRequest","transformRequest","pendingRequest","toPromise","then","Request","headers","fetch","response","ok","json","Promise","reject","catch","getGlStyle","glStyleOrUrl","resolve","accessToken","tilejsonCache","getTileJson","glSource","cacheKey","promise","tileLoadFunction","tile","src","VectorTile","setLoader","extent","arrayBuffer","getFormat","readFeatures","featureProjection","setFeatures","setState","TileState","ERROR","img","getImage","blob","createObjectURL","addEventListener","revokeObjectURL","normalizedSourceUrl","accessTokenParam","tileJson","assign","tileUrl","drawIconHalo","spriteImage","spriteImageData","haloWidth","haloColor","imgSize","pixelRatio","imageCanvas","imageContext","getContext","drawImage","imageData","getImageData","globalCompositeOperation","fillStyle","jj","arc","smoothstep","drawSDF","gamma","putImageData","hairSpacePool","applyLetterSpacing","letterSpacing","textWithLetterSpacing","lines","joinSpaceString","ll","measureContext","getMeasureContext","measureText","measureCache","wrapText","em","hardLines","wrappedText","words","maxWidth","word","testLine","prevWidth","nextWidth","next","lineWords","lastWord","fontFamilyRegEx","stripQuotesRegEx","loadedFontFamilies","hasFontFamily","family","styleSheets","styleSheet","cssRules","rules","cssRule","cssText","processedFontFamilies","MultiPoint","MultiLineString","MultiPolygon","expressionData","rawExpression","compiledExpression","emptyObj","zoomObj","renderFeatureCoordinates","renderFeature","getValue","layoutOrPaint","layerId","functions","isExpr","isFunction","bind","getDeclutterMode","prefix","evaluateFilter","createFilter","renderTransparentEnabled","colorWithOpacity","opacity","templateRegEx","fromTemplate","recordLayer","styleFunctionArgs","stylefunction","sourceOrLayers","spriteData","spriteImageUrl","getFonts","spriteImageSize","spriteImageUnSDFed","arguments","Image","blobUrl","crossOrigin","onload","changed","worker","postMessage","action","event","allLayers","layersBySourceLayer","mapboxLayers","iconImageCache","patternCache","mapboxSource","sourceLayer","textHalo","Stroke","Fill","styles","styleFunction","onlyLayer","getProperties","getGeometry","getType","getId","featureBelongsToLayer","stylesLength","layerData","stroke","strokeColor","fillIcon","icon","getFill","getStroke","getText","Style","setZIndex","icon_cache_key","pattern","globalAlpha","createPattern","setColor","setWidth","setLineCap","setLineJoin","setMiterLimit","setLineDash","iconImg","skipLabel","textLineHeight","textSize","maxTextWidth","hasImage","placementAngle","iconImage","styleGeom","imageElement","iconRotationAlignment","geom","getFlatMidpoint","getFlatMidpoints","getExtent","midpoint","RenderFeature","stride","getStride","getFlatCoordinates","maxX","xM","dotProduct","iconSize","iconColor","iconCacheKey","declutterMode","displacement","iconOptions","rotateWithView","Icon","offset","sdf","setGeometry","setRotation","setOpacity","setAnchor","setImage","setText","circleRadius","circleStrokeColor","circleTranslate","circleColor","circleStrokeWidth","cache_key","Circle","radius","fontArray","textField","reduce","acc","chunk","chunkFont","Text","textTransform","wrappedLabel","setFont","setKeepUpright","keepUpright","textAnchor","placement","textAlign","setPlacement","setRepeat","symbolSpacing","setOverflow","textHaloWidth","textOffset","textTranslate","vOffset","hOffset","textRotationAlignment","setRotateWithView","setMaxAngle","setTextAlign","textBaseline","setTextBaseline","textJustify","setJustify","setOffsetX","setOffsetY","setFill","halfTextSize","setStroke","textPadding","getPadding","setStyle","inputs","elevationImage","elevationData","shadeData","Uint8ClampedArray","dp","maxY","pixel","twoPi","halfPi","sunEl","sunAz","cosSunEl","sinSunEl","highlightColor","shadowColor","accentColor","pixelX","pixelY","x0","y0","z0","z1","dzdx","dzdy","slope","aspect","accent","scaled","shade","scaledAccentColor","compositeShadeColor","slopeScaleBase","scaledSlope","cosIncidence","calculateElevation","vert","ImageData","getTileResolutions","createXYZ","maxZoom","getResolutions","completeOptions","applyStyle","sourceOrLayersOrOptions","optionsOrPath","sourceId","updateSource","VectorLayer","VectorTileLayer","find","assignSource","setupVectorSource","targetSource","getSource","setTileUrlFunction","getTileUrlFunction","setUrls","getUrls","format_","getAttributions","setAttributions","getTileLoadFunction","defaultLoadFunction","setTileLoadFunction","equivalent","getProjection","tileGrid","getTileGrid","setSource","isFinite","getMaxResolution","getMinZoom","setMaxResolution","setupGeoJSONSource","url_","getUrl","spriteScale","onChange","getUnits","METERS_PER_UNIT","applyStylefunction","templateUrl","webfonts","fontsKey","fontDescriptions","cssFont","registerFont","fontDescription","checkedFonts","fontUrl","querySelector","markup","rel","head","appendChild","getStyle","normalizeSpriteUrl","spriteUrl","origin","pathname","search","spritesJson","transformed","applyBackground","mapOrLayer","Layer","setBackground","getBackgroundColor","Map","LayerGroup","getLayers","insertAt","setupBackgroundLayer","setFirstBackground","getSourceIdByRef","sourceOptionsFromTileJSON","tileJSON","tileJSONSource","TileJSON","tileJSONDoc","getTileJSON","fromLonLat","tr","extentFromTileJSON","projectionExtent","minZoom","sourceOptions","attributions","TileGrid","getTopLeft","getOrigin","getTileSize","glLayer","bg","_colorWithOpacity","div","className","Source","render","frameState","viewState","backgroundColor","MVT","VectorTileSource","getBboxTemplate","getCode","setupRasterSource","getTileUrl","tileCoord","bboxTemplate","getTileCoordExtent","setupRasterLayer","TileLayer","geoJsonFormat","GeoJSON","dataProjection","geoJsonUrl","extentUrl","VectorSource","loader","failure","addFeatures","removeLoadedExtent","strategy","bboxStrategy","getUserProjection","prerenderRasterLayer","updateRasterLayerProperties","setupLayer","glLayers","declutter","setupVectorLayer","setVisible","on","setupGeoJSONLayer","hillshadeLayer","tileLayer","ImageLayer","Raster","operationType","operation","setupHillshadeLayer","getPointResolution","getCenter","glSourceId","processStyle","mapOrGroup","promises","view","getView","isDef","getRotation","View","maxResolution","setView","setCenter","getZoom","setResolution","fit","getSize","layerIds","finalizeLayer","debug","apply","mapOrGroupOrElement","HTMLElement","target","getState","sourceMinZoom","setMinResolution","layerMapboxLayerids","mapboxLayer","manageVisibility","getArray","once","getMapboxLayer","layerStyle","getLayer","ErrorEvent","BaseEvent","EventType","MapboxVectorLayer","state","zIndex","minResolution","renderOrder","renderBuffer","renderMode","updateWhileAnimating","updateWhileInteracting","preload","useInterimTilesOnError","getBackground","dispatchEvent","beforeLayerId","spliceIndex","sourceOffset","sourceIndex","beforeMapboxLayer","beforeLayer","beforeLayerIndex","sourceLayerId","layerIndex","evaluateStyle","getStyleFunction","record","mapboxLayerIdOrLayer","mapboxLayerId","layerMapboxLayers","findIndex","enabled","clearFunctionCache","currentSource","newSourcePromise","newSource"],"mappings":"4xFA+2FIA,GAAS,CACZC,SAh3Fc,EAi3FdC,MAh3FW,CACXC,QAAS,CACRC,UAA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ZjB,EAAOQ,GAAgB3kB,GAEzBA,EAAMioB,YAAYzB,GAClBR,EAAQkC,YACN5B,EACEpkC,GACEo/B,GACE7oC,EACA,SACA,cACAhE,EACAiR,EACAkzB,EACAvhB,KAIR2uB,EAAQmC,WACN7G,GACE7oC,EACA,QACA,eACAhE,EACAiR,EACAkzB,EACAvhB,IAGJ2uB,EAAQoC,UACNnrC,GACEqkC,GACE7oC,EACA,SACA,cACAhE,EACAiR,EACAkzB,EACAvhB,KAIN2I,EAAMqoB,SAASrC,GACfpzB,EAAOoN,EAAMmlB,UACbnlB,EAAMsoB,aAAQprB,GACd8C,EAAMqlB,UAAU7sB,GAChB6tB,GAAW,EACXJ,GAAY,EAE9B,MACgBA,GAAY,CAEf,CACF,CACF,CAED,GAAY,GAAR/xC,GAA4B,WAAfuE,EAAMvE,KAAmB,GACtCywC,EACF3kB,EAAQmkB,EAAOQ,GAEZ3kB,GACAA,EAAMyc,aACPzc,EAAMilB,YACNjlB,EAAMklB,cAENllB,EAAQ,IAAIolB,EAAAA,QACZjB,EAAOQ,GAAgB3kB,GAEzB,MAAMuoB,EACJ,kBAAmBpvC,EACfmoC,GACE7oC,EACA,QACA,gBACAhE,EACAiR,EACAkzB,EACAvhB,GAEF,EACAmxB,EAAoBtG,GACxBZ,GACE7oC,EACA,QACA,sBACAhE,EACAiR,EACAkzB,EACAvhB,GAEFiqB,GACE7oC,EACA,QACA,wBACAhE,EACAiR,EACAkzB,EACAvhB,IAIEoxB,EAAkBnH,GACtB7oC,EACA,QACA,mBACAhE,EACAiR,EACAkzB,EACAvhB,GAEIqxB,EAAcxG,GAClBZ,GACE7oC,EACA,QACA,eACAhE,EACAiR,EACAkzB,EACAvhB,GAEFiqB,GACE7oC,EACA,QACA,iBACAhE,EACAiR,EACAkzB,EACAvhB,IAGEsxB,EAAoBrH,GACxB7oC,EACA,QACA,sBACAhE,EACAiR,EACAkzB,EACAvhB,GAEIuxB,EACJL,EACA,IACAC,EACA,IACAE,EACA,IACAC,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,SAAQ,SAAUhG,GACvBA,EAAMm3C,UAAU0L,EACtB,GACA,IACSD,CACT"} \ No newline at end of file diff --git a/dist/shaders.d.ts b/dist/shaders.d.ts new file mode 100644 index 00000000..c8bc67cc --- /dev/null +++ b/dist/shaders.d.ts @@ -0,0 +1,8 @@ +/** + * Generates a shaded relief image given elevation data. Uses a 3x3 + * neighborhood for determining slope and aspect. + * @param {Array} inputs Array of input images. + * @param {Object} data Data added in the "beforeoperations" event. + * @return {ImageData} Output image. + */ +export function hillshade(inputs: Array, data: any): ImageData; diff --git a/dist/stylefunction.d.ts b/dist/stylefunction.d.ts new file mode 100644 index 00000000..9b9abbc1 --- /dev/null +++ b/dist/stylefunction.d.ts @@ -0,0 +1,136 @@ +/** + * @private + * @param {Object} layer Gl object layer. + * @param {string} layoutOrPaint 'layout' or 'paint'. + * @param {string} property Feature property. + * @param {number} zoom Zoom. + * @param {Object} feature Gl feature. + * @param {Object} [functionCache] Function cache. + * @param {Object} [featureState] Feature state. + * @return {?} Value. + */ +export function getValue(layer: any, layoutOrPaint: string, property: string, zoom: number, feature: any, functionCache?: any, featureState?: any): unknown; +/** + * Configure whether features with a transparent style should be rendered. When + * set to `true`, it will be possible to hit detect content that is not visible, + * like transparent fills of polygons, using `ol/layer/Layer#getFeatures()` or + * `ol/Map#getFeaturesAtPixel()` + * @param {boolean} enabled Rendering of transparent elements is enabled. + * Default is `false`. + */ +export function renderTransparent(enabled: boolean): void; +/** + * Turns recording of the Mapbox/MapLibre Style's `layer` on and off. When turned on, + * the layer that a rendered feature belongs to will be set as the feature's + * `mapbox-layer` property. + * @param {boolean} record Recording of the style layer is on. + */ +export function recordStyleLayer(record?: boolean): void; +/** + * Creates a style function from the `glStyle` object for all layers that use + * the specified `source`, which needs to be a `"type": "vector"` or + * `"type": "geojson"` source and applies it to the specified OpenLayers layer. + * + * Two additional properties will be set on the provided layer: + * + * * `mapbox-source`: The `id` of the Mapbox/MapLibre Style document's source that the + * OpenLayers layer was created from. Usually `apply()` creates one + * OpenLayers layer per Mapbox/MapLibre Style source, unless the layer stack has + * layers from different sources in between. + * * `mapbox-layers`: The `id`s of the Mapbox/MapLibre Style document's layers that are + * included in the OpenLayers layer. + * + * This function also works in a web worker. In worker mode, the main thread needs + * to listen to messages from the worker and respond with another message to make + * sure that sprite image loading works: + * + * ```js + * worker.addEventListener('message', event => { + * if (event.data.action === 'loadImage') { + * const image = new Image(); + * image.crossOrigin = 'anonymous'; + * image.addEventListener('load', function() { + * createImageBitmap(image, 0, 0, image.width, image.height).then(imageBitmap => { + * worker.postMessage({ + * action: 'imageLoaded', + * image: imageBitmap, + * src: event.data.src + * }, [imageBitmap]); + * }); + * }); + * image.src = event.data.src; + * } + * }); + * ``` + * + * @param {VectorLayer|VectorTileLayer} olLayer OpenLayers layer to + * apply the style to. In addition to the style, the layer will get two + * properties: `mapbox-source` will be the `id` of the `glStyle`'s source used + * for the layer, and `mapbox-layers` will be an array of the `id`s of the + * `glStyle`'s layers. + * @param {string|Object} glStyle Mapbox/MapLibre Style object. + * @param {string|Array} sourceOrLayers `source` key or an array of layer `id`s + * from the Mapbox/MapLibre Style object. When a `source` key is provided, all layers for + * the specified source will be included in the style function. When layer `id`s + * are provided, they must be from layers that use the same source. + * @param {Array} resolutions + * Resolutions for mapping resolution to zoom level. + * @param {Object} spriteData Sprite data from the url specified in + * the Mapbox/MapLibre Style object's `sprite` property. Only required if a `sprite` + * property is specified in the Mapbox/MapLibre Style object. + * @param {string|Request|Promise} spriteImageUrl Sprite image url for the sprite + * specified in the Mapbox/MapLibre Style object's `sprite` property. Only required if a + * `sprite` property is specified in the Mapbox/MapLibre Style object. + * @param {function(Array, string=):Array} getFonts Function that + * receives a font stack and the url template from the GL style's `metadata['ol:webfonts']` + * property (if set) as arguments, and returns a (modified) font stack that + * is available. Font names are the names used in the Mapbox/MapLibre Style object. If + * not provided, the font stack will be used as-is. This function can also be + * used for loading web fonts. + * @param {function(VectorLayer|VectorTileLayer, string):HTMLImageElement|HTMLCanvasElement|string|undefined} [getImage] + * Function that returns an image or a URL for an image name. If the result is an HTMLImageElement, it must already be + * loaded. The layer can be used to call layer.changed() when the loading and processing of the image has finished. + * This function can be used for icons not in the sprite or to override sprite icons. + * @return {StyleFunction} Style function for use in + * `ol.layer.Vector` or `ol.layer.VectorTile`. + */ +export function stylefunction(olLayer: VectorLayer | VectorTileLayer, glStyle: string | any, sourceOrLayers: string | Array, resolutions?: Array, spriteData?: any, spriteImageUrl?: string | Request | Promise, getFonts?: (arg0: Array, arg1: string | undefined) => Array, getImage?: (arg0: VectorLayer | VectorTileLayer, arg1: string) => HTMLImageElement | HTMLCanvasElement | string | undefined, ...args: any[]): StyleFunction; +/** + * Get the the style for a specific Mapbox layer only. This can be useful for creating a legend. + * @param {import("ol/Feature").default|import("ol/render/Feature").default} feature OpenLayers feature. + * @param {number} resolution View resolution. + * @param {import("ol/layer").Vector|import("ol/layer").VectorTile} olLayer OpenLayers layer. + * @param {string} layerId Id of the Mapbox layer to get the style for + * @return {Array} Styles for the provided Mapbox layer. + */ +export function getStyleForLayer(feature: import("ol/Feature").default | import("ol/render/Feature").default, resolution: number, olLayer: import("ol/layer").Vector | import("ol/layer").VectorTile, layerId: string): Array; +export const styleFunctionArgs: {}; +export type VectorLayer = import("ol/layer/Vector").default; +export type VectorTileLayer = import("ol/layer/VectorTile").default; +export type StyleFunction = import("ol/style/Style").StyleFunction; +export type ResourceType = import("./util.js").ResourceType; +/** + * @private + * @param {?} color Color. + * @param {number} [opacity] Opacity. + * @return {string} Color. + */ +declare function colorWithOpacity(color: unknown, opacity?: number): string; +/** + * @private + * @param {string} layerId Layer id. + * @param {?} filter Filter. + * @param {Object} feature Feature. + * @param {number} zoom Zoom. + * @param {Object} [filterCache] Filter cache. + * @return {boolean} Filter result. + */ +declare function evaluateFilter(layerId: string, filter: unknown, feature: any, zoom: number, filterCache?: any): boolean; +/** + * @private + * @param {string} text Text. + * @param {Object} properties Properties. + * @return {string} Text. + */ +declare function fromTemplate(text: string, properties: any): string; +export { colorWithOpacity as _colorWithOpacity, evaluateFilter as _evaluateFilter, fromTemplate as _fromTemplate, getValue as _getValue }; diff --git a/dist/text.d.ts b/dist/text.d.ts new file mode 100644 index 00000000..9433187e --- /dev/null +++ b/dist/text.d.ts @@ -0,0 +1,9 @@ +export function applyLetterSpacing(text: any, letterSpacing: any): any; +export function wrapText(text: any, font: any, em: any, letterSpacing: any): any; +/** + * @param {Array} fonts Fonts. + * @param {string} [templateUrl] Template URL. + * @return {Array} Processed fonts. + * @private + */ +export function getFonts(fonts: any[], templateUrl?: string): any[]; diff --git a/dist/util.d.ts b/dist/util.d.ts new file mode 100644 index 00000000..4d6dbc04 --- /dev/null +++ b/dist/util.d.ts @@ -0,0 +1,90 @@ +export function getStyleId(glStyle: any): any; +export function getStyleFunctionKey(glStyle: any, olLayer: any): string; +/** + * @param {Object} glStyle Mapboox style object. + * @return {Object} Function cache. + */ +export function getFunctionCache(glStyle: any): any; +export function clearFunctionCache(): void; +/** + * @param {Object} glStyle Mapboox style object. + * @return {Object} Filter cache. + */ +export function getFilterCache(glStyle: any): any; +export function deg2rad(degrees: any): number; +/** + * @param {number} width Width of the canvas. + * @param {number} height Height of the canvas. + * @return {HTMLCanvasElement} Canvas. + */ +export function createCanvas(width: number, height: number): HTMLCanvasElement; +export function getZoomForResolution(resolution: any, resolutions: any): number; +export function getResolutionForZoom(zoom: any, resolutions: any): number; +/** + * @param {ResourceType} resourceType Type of resource to load. + * @param {string} url Url of the resource. + * @param {Options} [options] Options. + * @param {{request?: Request}} [metadata] Object to be filled with the request. + * @return {Promise} Promise that resolves with the loaded resource + * or rejects with the Response object. + * @private + */ +export function fetchResource(resourceType: ResourceType, url: string, options?: Options, metadata?: { + request?: Request; +}): Promise; +export function getGlStyle(glStyleOrUrl: any, options: any): Promise; +/** + * @param {Object} glSource glStyle source object. + * @param {string} styleUrl Style URL. + * @param {Options} options Options. + * @return {Promise<{tileJson: Object, tileLoadFunction: import('ol/Tile.js').LoadFunction}?>} TileJson and load function + */ +export function getTileJson(glSource: any, styleUrl: string, options?: Options): Promise<{ + tileJson: any; + tileLoadFunction: import("ol/Tile.js").LoadFunction; +} | null>; +/** + * @param {HTMLImageElement|HTMLCanvasElement} spriteImage Sprite image id. + * @param {{x: number, y: number, width: number, height: number, pixelRatio: number}} spriteImageData Sprite image data. + * @param {number} haloWidth Halo width. + * @param {{r: number, g: number, b: number, a: number}} haloColor Halo color. + * @return {HTMLCanvasElement} Canvas element with the halo. + */ +export function drawIconHalo(spriteImage: HTMLImageElement | HTMLCanvasElement, spriteImageData: { + x: number; + y: number; + width: number; + height: number; + pixelRatio: number; +}, haloWidth: number, haloColor: { + r: number; + g: number; + b: number; + a: number; +}): HTMLCanvasElement; +/** + * @param {HTMLImageElement} image SDF image + * @param {{x: number, y: number, width: number, height: number}} area Area to unSDF + * @param {{r: number, g: number, b: number, a: number}} color Color to use + * @return {HTMLCanvasElement} Regular image + */ +export function drawSDF(image: HTMLImageElement, area: { + x: number; + y: number; + width: number; + height: number; +}, color: { + r: number; + g: number; + b: number; + a: number; +}): HTMLCanvasElement; +export const defaultResolutions: number[]; +export type ResourceType = "Style" | "Source" | "Sprite" | "SpriteImage" | "Tiles" | "GeoJSON"; +export type Map = import("ol").Map; +export type Layer = import("ol/layer").Layer; +export type LayerGroup = import("ol/layer").Group; +export type VectorLayer = import("ol/layer").Vector; +export type VectorTileLayer = import("ol/layer").VectorTile; +export type Source = import("ol/source").Source; +export type Options = import("./apply.js").Options;