isard 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/README.md +9 -4
- package/dist/basemap/vectortiles/requests.d.ts +8 -1
- package/dist/basemap/vectortiles/requests.js +32 -4
- package/dist/basemap/vectortiles/requests.js.map +1 -1
- package/dist/basemap/vectortiles/vectors.d.ts +8 -1
- package/dist/basemap/vectortiles/vectors.js +26 -2
- package/dist/basemap/vectortiles/vectors.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +15 -9
- package/dist/basemap/vectortiles.js +3 -1
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +4 -4
- package/dist/bind/layers.js +10 -2
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/tileset.d.ts +21 -0
- package/dist/data/tileset.js +101 -0
- package/dist/data/tileset.js.map +1 -0
- package/dist/decoder.worker.js +3 -3
- package/dist/decoder.worker.js.map +3 -3
- package/dist/engine-loader.d.ts +2 -2
- package/dist/engine-loader.js +9 -3
- package/dist/engine-loader.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/layers/features.d.ts +7 -0
- package/dist/layers/features.js +21 -5
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/layers.js +2 -0
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/tiles3d.d.ts +6 -0
- package/dist/layers/tiles3d.js +57 -3
- package/dist/layers/tiles3d.js.map +1 -1
- package/dist/layers/vectors.d.ts +3 -0
- package/dist/layers/vectors.js +4 -0
- package/dist/layers/vectors.js.map +1 -1
- package/dist/map/events.js +1 -0
- package/dist/map/events.js.map +1 -1
- package/dist/map/quality.d.ts +33 -0
- package/dist/map/quality.js +61 -0
- package/dist/map/quality.js.map +1 -0
- package/dist/map.d.ts +22 -1
- package/dist/map.js +87 -8
- package/dist/map.js.map +1 -1
- package/dist/react/IsardMap.d.ts +1 -0
- package/dist/react/IsardMap.js +2 -0
- package/dist/react/IsardMap.js.map +1 -1
- package/dist/react/VectorGeometry.d.ts +4 -0
- package/dist/react/VectorGeometry.js +6 -3
- package/dist/react/VectorGeometry.js.map +1 -1
- package/dist/react/VectorTiles.d.ts +5 -1
- package/dist/react/VectorTiles.js +8 -0
- package/dist/react/VectorTiles.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/types.d.ts +22 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/interaction.d.ts +4 -0
- package/dist/ui/interaction.js +53 -2
- package/dist/ui/interaction.js.map +1 -1
- package/dist/wasm/isard.d.ts +30 -6
- package/dist/wasm/isard.js +61 -7
- package/dist/wasm/isard_core.d.ts +20 -6
- package/dist/wasm/isard_core.js +41 -7
- package/dist/workers/basemap/protocol.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAqB,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQ/F,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAE,UAAU,EAA+B,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAyB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAsB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAqB,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAgD,UAAU,EAAE,MAAM,8BAA8B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,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n *\n * The layers other than the raster ones are made in `vectortiles/` (one module each), from what they use of the\n * instance (`VectorTilesContext`); the style's loading is in `vectortiles/style.ts`.\n */\n\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport { type LoadedSprite, loadSprites, readPixels, spriteSources } from '../layers/icons.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelLayer } from '../layers/models.ts';\nimport type { RasterLayer } from '../layers/raster.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Placement } from '../types.ts';\nimport { clamp } from '../util/math.ts';\nimport type { BasemapWork, Sprite } from '../workers/basemap/protocol.ts';\nimport type { LabelCandidate, Style, StyleLayer } from './vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './vectortiles/context.ts';\nimport { extrusions, type VectorExtrusionOptions } from './vectortiles/extrusions.ts';\nimport { type FurnitureOptions, furniture } from './vectortiles/furniture.ts';\nimport { type LabelsOptions, labels, size, tileLabels } from './vectortiles/labels.ts';\nimport { type LampsOptions, lamps } from './vectortiles/lamps.ts';\nimport type { TileRequests } from './vectortiles/requests.ts';\nimport { type StreetWindLayer, type StreetWindOptions, streetWind } from './vectortiles/street-wind.ts';\nimport {\n type LoadedStyle,\n loadStyle,\n OPENFREEMAP_STYLES,\n PLAN_STYLES,\n styleAttribution,\n VECTOR_BASEMAPS,\n} from './vectortiles/style.ts';\nimport { VECTOR_MOVE_REFRESH_MS } from './vectortiles/tiles.ts';\nimport { type TreesOptions, trees } from './vectortiles/trees.ts';\nimport { dashes, type VectorsOptions, vectors } from './vectortiles/vectors.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n// The names the package and its tests import from here, now made in `vectortiles/`\nexport { dashes, OPENFREEMAP_STYLES, PLAN_STYLES, size, styleAttribution, tileLabels, VECTOR_BASEMAPS };\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** Its first raster layer: the ground its labels follow */\n private ground: RasterLayer | undefined;\n /** What its layers made in `vectortiles/` use of it */\n private readonly context: VectorTilesContext;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<LoadedStyle>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = loadStyle(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n this.context = {\n map,\n ready: this.ready,\n layers: this.layers,\n cleanup: this.cleanup,\n iconPrefix: this.iconPrefix,\n destroyed: () => this.destroyed,\n ground: () => this.ground,\n broadcast: (message) => {\n this.pool.broadcast(message);\n },\n request: (vz, vx, vy, work, signal) => this.request(vz, vx, vy, work, signal),\n renderer: (select, extra, again) => this.renderer(select, extra, { again }),\n loadSprites: (sprite) => this.loadSprites(sprite),\n addSprites: () => this.addSprites(),\n followView: (layer, update, requests, moving) => {\n this.followView(layer, update, requests, moving);\n },\n stopWith: (layer, stop) => {\n this.stopWith(layer, stop);\n },\n };\n }\n\n /** The style's sprites (their JSON and their images), loaded once, for the fill patterns and the icons */\n private sprites: Promise<LoadedSprite[]> | undefined;\n\n /** The style's sprites, kept once all of them came: one that failed is asked for again by the next layer */\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n if (this.sprites) return this.sprites;\n\n const wanted = spriteSources(sprite).length;\n const loading: Promise<LoadedSprite[]> = loadSprites(sprite)\n .catch(() => [])\n .then((loaded) => {\n if (loaded.length < wanted && this.sprites === loading) {\n console.warn(\n `isard: ${wanted - loaded.length} of the style's sprites not loaded, its icons and patterns missing`,\n );\n this.sprites = undefined;\n }\n\n return loaded;\n });\n\n this.sprites = loading;\n\n return loading;\n }\n\n /** The style's sprites added to the map's icons, once */\n private spritesAdded: Promise<void> | undefined;\n\n /** The style's sprites among the map's icons (under `iconPrefix`), added once: the labels' icons, the fills'\n * patterns */\n private addSprites(): Promise<void> {\n this.spritesAdded ??= this.ready.then(async ({ style }) => {\n if (!style.sprite) return;\n (await this.loadSprites(style.sprite)).forEach((sprite) => {\n if (!this.destroyed) this.map.icons.addSprite(this.iconPrefix, sprite.icons, () => readPixels(sprite.image));\n });\n });\n\n return this.spritesAdded;\n }\n\n /** Prefix of the names of its sprites' images among the map's icons */\n private get iconPrefix(): string {\n return `${this.namespace}/`;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n\n return this.map.track(this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal));\n }\n\n /** Sends a renderer of these layers to every worker (`again`: under that key, restyled), with the style's sprites if\n * it `draws` the tiles into images with patterns (the raster path: the others take their images in the page) */\n private async renderer(\n select: (layer: StyleLayer) => boolean,\n extra: StyleLayer[],\n { again, draws = false }: { again?: string | undefined; draws?: boolean } = {},\n ): Promise<Renderer> {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = again ?? rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = draws && layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The images are downloaded once, copied to each worker\n const sprites: Sprite[] = patterns && style.sprite ? await this.loadSprites(style.sprite) : [];\n\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({ type: 'init', key, tiles, maxzoom, layers, rasters, ...(sprites.length ? { sprites } : {}) });\n if (!again) this.renderers.push(key);\n\n return { key, maxzoom, layers };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(\n options: {\n layers?: (layer: StyleLayer) => boolean;\n extraLayers?: StyleLayer[];\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n } & Placement = {},\n ): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers, { draws: true });\n\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = clamp(z - 1, 0, maxzoom);\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n\n this.layers.push(layer);\n this.ground ??= layer;\n\n return layer;\n }\n\n /**\n * An extrusion layer of the polygons of the style's fill layers that `layers` keeps (by default its buildings: the\n * fill or fill-extrusion layers of PLAN IGN's `bati_surf` or OpenMapTiles' `building`), raised by the style\n * given (`height`, `base`, `color`, `ramp`…; the properties of the tiles' features). Its tiles follow the view: at\n * the source's deepest level, the `maxTiles` nearest to the center, from `minZoom` on (15 by default); the tiles\n * leaving the view are dropped.\n */\n extrusions<P = Record<string, unknown>>(options: VectorExtrusionOptions<P> = {}): ExtrusionLayer<P> {\n return extrusions<P>(this.context, options);\n }\n\n /**\n * The wind through the streets around the view, as particles at street level (`height`, default 3 metres) between\n * the style's buildings (`layers`, default its `building` and `bati_surf` layers): their footprints laid on a grid of\n * `cell` metres (default 4) over a square of `size` metres (default 1200) around the view's center, the flow of the\n * air round them a potential flow (it goes round the blocks and faster through the narrow streets; no wake behind\n * them), computed in a worker by the grid module from street level (`minZoom`, default 15) and again when the view\n * leaves the square's middle. `wind` is the wind far away (east and north, m/s, default a light breeze from the\n * south-west); `setWind` changes it at once (the flow is linear in it: nothing computed again), from a model's hour\n * (`windAt`) for instance; `computed` resolves once the first square's flow is there. The other options are the flow\n * layer's (`addFlow`)\n */\n streetWind(options: StreetWindOptions = {}): StreetWindLayer {\n return streetWind(this.context, options);\n }\n\n /**\n * Trees on the style's woods, forests and grass (or the fill layers `layers` keeps) as 3D models, from street level\n * (`minZoom`, default 15): the workers scatter them over the polygons of the vector tiles around the view, `spacing`\n * metres apart (by style layer: 9 in woods, 25 on grass, by default) on a jittered grid, the same trees whenever a\n * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its\n * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the\n * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default\n * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000). The models load the\n * engine with 3D Tiles.\n */\n trees(options: TreesOptions = {}): ModelLayer {\n return trees(this.context, options);\n }\n\n /**\n * Street lamps along the style's streets (the road line layers, or those `layers` keeps) as 3D models, from street\n * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every\n * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of\n * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).\n * The models load the engine with 3D Tiles.\n */\n lamps(options: LampsOptions = {}): ModelLayer {\n return lamps(this.context, options);\n }\n\n /**\n * The street furniture as 3D models, from OpenMapTiles' points of interest of the street: bus shelters at the bus\n * stops, waste baskets, post boxes, drinking fountains (Wallace's in Paris), bicycle racks, each facing its street;\n * benches along the pedestrian streets and the paths of the parks and gardens. Placed by the workers, one instanced\n * draw a kind, all of them near the camera and fewer away from it. The layer returned holds the other kinds' (its\n * `companions`); removed with it\n */\n furniture(options: FurnitureOptions = {}): ModelLayer {\n return furniture(this.context, options);\n }\n\n /**\n * A layer drawing the style's fills, lines and buildings (or those `layers` keeps; backgrounds as fills, the\n * `fill-extrusion` layers raised into buildings by their height and base height) as geometry instead of images: the\n * workers cut the vector tiles in view into polygons and lines, which the engine draws on the globe and the relief,\n * in the style's order, each style layer over its zoom range. Sharp at any zoom\n * and pitch, picked by feature (`pick` gives its properties and style layer), restyled without cutting the tiles\n * again (`setPaintProperty`, `setLayoutProperty`). Its tiles follow the view, while it moves too, coarser far away in a\n * tilted view, and those leaving it stay until the ones replacing them are there; past the source's deepest level,\n * cut again from its tiles down to level 18 (overzoom: their styles those of their level; a filter reading the zoom\n * holds at the whole zoom under the camera's, as MapLibre evaluates it). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says, their joins as their `line-join` says (and `line-miter-limit`),\n * offset by `line-offset`; the colors follow the camera's zoom; the fills', lines' and buildings' patterns from the\n * style's sprite (the fills' over the relief too; on the globe, their average color there), the circle layers' points\n * as circles facing the screen, the lines' blur, the fills' and lines' translations. The buildings' roofs (`roofs`)\n * as their data says (`roof:shape`, `roof:height`; flat without, the default), generated from their outline where\n * they have none (`'generated'`), or all flat. `raster` stays the lighter path for heavy styles and small devices.\n * At night (`setSun`) the line layers `streets` keeps glow (by default those whose id names\n * a road, not its casing, a railway, a path or a tunnel).\n */\n vectors(options: VectorsOptions = {}): VectorLayer {\n return vectors(this.context, options);\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. With a raster layer of\n * the style (`raster`), the tiles follow the levels the ground is drawn at: a tilted view takes coarser tiles far\n * away, with the few labels of a lower zoom, as near the camera it takes the fine ones. Without, the tiles around\n * the center at the zoom of the view. It stays above the layers added after it unless one is moved over it.\n */\n labels(options: LabelsOptions = {}): SymbolLayer<LabelCandidate> {\n return labels(this.context, options);\n }\n\n /**\n * Makes a layer's tiles follow the view: `update` now and where the camera stops (`moveend`), `moving` every\n * `VECTOR_MOVE_REFRESH_MS` while it moves; the `requests` aborted when destroyed or the layer removed\n */\n private followView(\n layer: Layer,\n update: () => Promise<unknown>,\n requests: TileRequests,\n moving: () => unknown,\n ): void {\n const refresh = () => {\n update().catch(() => undefined);\n };\n const pace = { timer: 0 };\n const follow = () => {\n if (pace.timer) return;\n pace.timer = window.setTimeout(() => {\n pace.timer = 0;\n Promise.resolve(moving()).catch(() => undefined);\n }, VECTOR_MOVE_REFRESH_MS);\n };\n const [offMove, offEnd] = [this.map.on('move', follow), this.map.on('moveend', refresh)];\n\n this.stopWith(layer, () => {\n offMove();\n offEnd();\n clearTimeout(pace.timer);\n requests.abortAll();\n });\n refresh();\n }\n\n /** Calls `stop` when destroyed or once `layer` is removed, whichever comes first */\n private stopWith(layer: Layer, stop: () => void): void {\n const once = { done: false };\n const run = () => {\n if (once.done) return;\n once.done = true;\n stop();\n };\n\n this.cleanup.push(run);\n layer.whenRemoved.push(run);\n }\n\n /** Removes its layers from the map (those still there) and stops its workers' work */\n remove(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.cleanup.forEach((off) => {\n off();\n });\n this.cleanup.length = 0;\n this.layers.forEach((layer) => {\n if (this.map.hasLayer(layer)) layer.remove();\n });\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprites (the workers have theirs), and their icons\n this.sprites\n ?.then((sprites) => {\n sprites.forEach((sprite) => {\n sprite.image.close();\n });\n this.map.icons.remove(this.iconPrefix, true);\n })\n .catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n this.renderers.forEach((key) => {\n this.pool.broadcast({ type: 'drop', key });\n });\n }\n this.renderers.length = 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAqB,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQ/F,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAE,UAAU,EAA+B,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAyB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAsB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAqB,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAgD,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAEL,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAqB,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAuB,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAuB,WAAW,EAAE,YAAY,EAAE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AAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n *\n * The layers other than the raster ones are made in `vectortiles/` (one module each), from what they use of the\n * instance (`VectorTilesContext`); the style's loading is in `vectortiles/style.ts`.\n */\n\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport { type LoadedSprite, loadSprites, readPixels, spriteSources } from '../layers/icons.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelLayer } from '../layers/models.ts';\nimport type { RasterLayer } from '../layers/raster.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Placement } from '../types.ts';\nimport { clamp } from '../util/math.ts';\nimport type { BasemapWork, Sprite } from '../workers/basemap/protocol.ts';\nimport type { LabelCandidate, Style, StyleLayer } from './vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './vectortiles/context.ts';\nimport { extrusions, type VectorExtrusionOptions } from './vectortiles/extrusions.ts';\nimport { type FurnitureOptions, furniture } from './vectortiles/furniture.ts';\nimport { type LabelsOptions, labels, size, tileLabels } from './vectortiles/labels.ts';\nimport { type LampsOptions, lamps } from './vectortiles/lamps.ts';\nimport type { TileRequests } from './vectortiles/requests.ts';\nimport { type StreetWindLayer, type StreetWindOptions, streetWind } from './vectortiles/street-wind.ts';\nimport {\n type LoadedStyle,\n loadStyle,\n OPENFREEMAP_STYLES,\n PLAN_STYLES,\n styleAttribution,\n VECTOR_BASEMAPS,\n} from './vectortiles/style.ts';\nimport { VECTOR_MOVE_REFRESH_MS } from './vectortiles/tiles.ts';\nimport { type TreesOptions, trees } from './vectortiles/trees.ts';\nimport { dashes, type VectorsOptions, vectors } from './vectortiles/vectors.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n// The names the package and its tests import from here, now made in `vectortiles/`\nexport { dashes, OPENFREEMAP_STYLES, PLAN_STYLES, size, styleAttribution, tileLabels, VECTOR_BASEMAPS };\n\n/** The options of `VectorTiles.raster` */\nexport interface VectorRasterOptions extends Placement {\n /** The style layers drawn (default all but the symbols) */\n layers?: (layer: StyleLayer) => boolean;\n /** Style layers of the same source drawn after them */\n extraLayers?: StyleLayer[];\n /** Texture size of its tiles (512 by default: sharp lines) */\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n}\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** Its first raster layer: the ground its labels follow */\n private ground: RasterLayer | undefined;\n /** What its layers made in `vectortiles/` use of it */\n private readonly context: VectorTilesContext;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<LoadedStyle>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = loadStyle(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n this.context = {\n map,\n ready: this.ready,\n layers: this.layers,\n cleanup: this.cleanup,\n iconPrefix: this.iconPrefix,\n destroyed: () => this.destroyed,\n ground: () => this.ground,\n broadcast: (message) => {\n this.pool.broadcast(message);\n },\n request: (vz, vx, vy, work, signal) => this.request(vz, vx, vy, work, signal),\n renderer: (select, extra, again) => this.renderer(select, extra, { again }),\n loadSprites: (sprite) => this.loadSprites(sprite),\n addSprites: () => this.addSprites(),\n followView: (layer, update, requests, moving) => {\n this.followView(layer, update, requests, moving);\n },\n stopWith: (layer, stop) => {\n this.stopWith(layer, stop);\n },\n };\n }\n\n /** The style's sprites (their JSON and their images), loaded once, for the fill patterns and the icons */\n private sprites: Promise<LoadedSprite[]> | undefined;\n\n /** The style's sprites, kept once all of them came: one that failed is asked for again by the next layer */\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n if (this.sprites) return this.sprites;\n\n const wanted = spriteSources(sprite).length;\n const loading: Promise<LoadedSprite[]> = loadSprites(sprite)\n .catch(() => [])\n .then((loaded) => {\n if (loaded.length < wanted && this.sprites === loading) {\n console.warn(\n `isard: ${wanted - loaded.length} of the style's sprites not loaded, its icons and patterns missing`,\n );\n this.sprites = undefined;\n }\n\n return loaded;\n });\n\n this.sprites = loading;\n\n return loading;\n }\n\n /** The style's sprites added to the map's icons, once */\n private spritesAdded: Promise<void> | undefined;\n\n /** The style's sprites among the map's icons (under `iconPrefix`), added once: the labels' icons, the fills'\n * patterns */\n private addSprites(): Promise<void> {\n this.spritesAdded ??= this.ready.then(async ({ style }) => {\n if (!style.sprite) return;\n (await this.loadSprites(style.sprite)).forEach((sprite) => {\n if (!this.destroyed) this.map.icons.addSprite(this.iconPrefix, sprite.icons, () => readPixels(sprite.image));\n });\n });\n\n return this.spritesAdded;\n }\n\n /** Prefix of the names of its sprites' images among the map's icons */\n private get iconPrefix(): string {\n return `${this.namespace}/`;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n\n return this.map.track(this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal));\n }\n\n /** Sends a renderer of these layers to every worker (`again`: under that key, restyled), with the style's sprites if\n * it `draws` the tiles into images with patterns (the raster path: the others take their images in the page) */\n private async renderer(\n select: (layer: StyleLayer) => boolean,\n extra: StyleLayer[],\n { again, draws = false }: { again?: string | undefined; draws?: boolean } = {},\n ): Promise<Renderer> {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = again ?? rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = draws && layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The images are downloaded once, copied to each worker\n const sprites: Sprite[] = patterns && style.sprite ? await this.loadSprites(style.sprite) : [];\n\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({ type: 'init', key, tiles, maxzoom, layers, rasters, ...(sprites.length ? { sprites } : {}) });\n if (!again) this.renderers.push(key);\n\n return { key, maxzoom, layers };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(options: VectorRasterOptions = {}): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers, { draws: true });\n\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = clamp(z - 1, 0, maxzoom);\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n\n this.layers.push(layer);\n this.ground ??= layer;\n\n return layer;\n }\n\n /**\n * An extrusion layer of the polygons of the style's fill layers that `layers` keeps (by default its buildings: the\n * fill or fill-extrusion layers of PLAN IGN's `bati_surf` or OpenMapTiles' `building`), raised by the style\n * given (`height`, `base`, `color`, `ramp`…; the properties of the tiles' features). Its tiles follow the view: at\n * the source's deepest level, the `maxTiles` nearest to the center, from `minZoom` on (15 by default); the tiles\n * leaving the view are dropped.\n */\n extrusions<P = Record<string, unknown>>(options: VectorExtrusionOptions<P> = {}): ExtrusionLayer<P> {\n return extrusions<P>(this.context, options);\n }\n\n /**\n * The wind through the streets around the view, as particles at street level (`height`, default 3 metres) between\n * the style's buildings (`layers`, default its `building` and `bati_surf` layers): their footprints laid on a grid of\n * `cell` metres (default 4) over a square of `size` metres (default 1200) around the view's center, the flow of the\n * air round them a potential flow (it goes round the blocks and faster through the narrow streets; no wake behind\n * them), computed in a worker by the grid module from street level (`minZoom`, default 15) and again when the view\n * leaves the square's middle. `wind` is the wind far away (east and north, m/s, default a light breeze from the\n * south-west); `setWind` changes it at once (the flow is linear in it: nothing computed again), from a model's hour\n * (`windAt`) for instance; `computed` resolves once the first square's flow is there. The other options are the flow\n * layer's (`addFlow`)\n */\n streetWind(options: StreetWindOptions = {}): StreetWindLayer {\n return streetWind(this.context, options);\n }\n\n /**\n * Trees on the style's woods, forests and grass (or the fill layers `layers` keeps) as 3D models, from street level\n * (`minZoom`, default 15): the workers scatter them over the polygons of the vector tiles around the view, `spacing`\n * metres apart (by style layer: 9 in woods, 25 on grass, by default) on a jittered grid, the same trees whenever a\n * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its\n * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the\n * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default\n * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000). The models load the\n * engine with 3D Tiles.\n */\n trees(options: TreesOptions = {}): ModelLayer {\n return trees(this.context, options);\n }\n\n /**\n * Street lamps along the style's streets (the road line layers, or those `layers` keeps) as 3D models, from street\n * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every\n * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of\n * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).\n * The models load the engine with 3D Tiles.\n */\n lamps(options: LampsOptions = {}): ModelLayer {\n return lamps(this.context, options);\n }\n\n /**\n * The street furniture as 3D models, from OpenMapTiles' points of interest of the street: bus shelters at the bus\n * stops, waste baskets, post boxes, drinking fountains (Wallace's in Paris), bicycle racks, each facing its street;\n * benches along the pedestrian streets and the paths of the parks and gardens. Placed by the workers, one instanced\n * draw a kind, all of them near the camera and fewer away from it. The layer returned holds the other kinds' (its\n * `companions`); removed with it\n */\n furniture(options: FurnitureOptions = {}): ModelLayer {\n return furniture(this.context, options);\n }\n\n /**\n * A layer drawing the style's fills, lines and buildings (or those `layers` keeps; backgrounds as fills, the\n * `fill-extrusion` layers raised into buildings by their height and base height) as geometry instead of images: the\n * workers cut the vector tiles in view into polygons and lines, which the engine draws on the globe and the relief,\n * in the style's order, each style layer over its zoom range. Sharp at any zoom\n * and pitch, picked by feature (`pick` gives its properties and style layer), restyled without cutting the tiles\n * again (`setPaintProperty`, `setLayoutProperty`). Its tiles follow the view, while it moves too, coarser far away in a\n * tilted view, and those leaving it stay until the ones replacing them are there; past the source's deepest level,\n * cut again from its tiles down to level 18 (overzoom: their styles those of their level; a filter reading the zoom\n * holds at the whole zoom under the camera's, as MapLibre evaluates it). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says, their joins as their `line-join` says (and `line-miter-limit`),\n * offset by `line-offset`; the colors follow the camera's zoom; the fills', lines' and buildings' patterns from the\n * style's sprite (the fills' over the relief too; on the globe, their average color there), the circle layers' points\n * as circles facing the screen, the lines' blur, the fills' and lines' translations. The buildings' roofs (`roofs`)\n * as their data says (`roof:shape`, `roof:height`; flat without, the default), generated from their outline where\n * they have none (`'generated'`), or all flat. `raster` stays the lighter path for heavy styles and small devices.\n * At night (`setSun`) the line layers `streets` keeps glow (by default those whose id names\n * a road, not its casing, a railway, a path or a tunnel).\n */\n vectors(options: VectorsOptions = {}): VectorLayer {\n return vectors(this.context, options);\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. With a raster layer of\n * the style (`raster`), the tiles follow the levels the ground is drawn at: a tilted view takes coarser tiles far\n * away, with the few labels of a lower zoom, as near the camera it takes the fine ones. Without, the tiles around\n * the center at the zoom of the view. It stays above the layers added after it unless one is moved over it.\n */\n labels(options: LabelsOptions = {}): SymbolLayer<LabelCandidate> {\n return labels(this.context, options);\n }\n\n /**\n * Makes a layer's tiles follow the view: `update` now and where the camera stops (`moveend`), `moving` every\n * `VECTOR_MOVE_REFRESH_MS` while it moves, and again after a pause when tiles failed; the `requests` aborted when\n * destroyed or the layer removed\n */\n private followView(\n layer: Layer,\n update: () => Promise<unknown>,\n requests: TileRequests,\n moving: () => unknown,\n ): void {\n const refresh = () => {\n update().catch(() => undefined);\n };\n const pace = { timer: 0 };\n const follow = () => {\n if (pace.timer) return;\n pace.timer = window.setTimeout(() => {\n pace.timer = 0;\n Promise.resolve(moving()).catch(() => undefined);\n }, VECTOR_MOVE_REFRESH_MS);\n };\n const [offMove, offEnd] = [this.map.on('move', follow), this.map.on('moveend', refresh)];\n\n requests.retryWith(refresh);\n\n this.stopWith(layer, () => {\n offMove();\n offEnd();\n clearTimeout(pace.timer);\n requests.abortAll();\n });\n refresh();\n }\n\n /** Calls `stop` when destroyed or once `layer` is removed, whichever comes first */\n private stopWith(layer: Layer, stop: () => void): void {\n const once = { done: false };\n const run = () => {\n if (once.done) return;\n once.done = true;\n stop();\n };\n\n this.cleanup.push(run);\n layer.whenRemoved.push(run);\n }\n\n /** Removes its layers from the map (those still there) and stops its workers' work */\n remove(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.cleanup.forEach((off) => {\n off();\n });\n this.cleanup.length = 0;\n this.layers.forEach((layer) => {\n if (this.map.hasLayer(layer)) layer.remove();\n });\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprites (the workers have theirs), and their icons\n this.sprites\n ?.then((sprites) => {\n sprites.forEach((sprite) => {\n sprite.image.close();\n });\n this.map.icons.remove(this.iconPrefix, true);\n })\n .catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n this.renderers.forEach((key) => {\n this.pool.broadcast({ type: 'drop', key });\n });\n }\n this.renderers.length = 0;\n }\n}\n"]}
|
package/dist/basemap.worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ie=(e,t)=>Error(`isard: ${String(e)}: HTTP ${t}`),kt=async(e,t)=>{let n=await fetch(e,t);if(!n.ok)throw ie(e,n.status);return n};class le{capacity;evict;entries=new Map;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.entries.delete(e),this.entries.set(e,t);for(let[n,r]of this.entries){if(this.entries.size<=this.capacity)break;this.entries.delete(n),this.evict?.(r,n)}}delete(e){return this.entries.delete(e)}values(){return this.entries.values()}clear(){this.entries.clear()}}var vt=[];var Rt=(e)=>{vt=e};var oe=(e,t={})=>{let n=String(e),r=vt.filter(([s])=>n.startsWith(s));if(r.length===0)return t;let o=new Headers(t.headers);return r.forEach(([,s])=>{Object.entries(s).forEach(([a,i])=>{o.set(a,i)})}),{...t,headers:o}};var zn=96,Hn=(e,t,n,r,o,s)=>{let a=new Uint8ClampedArray(s*s*4),i=s/o,c=o+1;for(let l=0;l<s;l+=1){let u=(l+0.5)/i,d=Math.min(o-1,Math.floor(u)),f=u-d;for(let p=0;p<s;p+=1){let _=(p+0.5)/i,y=Math.min(o-1,Math.floor(_)),A=_-y,m=2*(d*c+y),M=m+2*c,b=(1-A)*(1-f),w=A*(1-f),T=(1-A)*f,v=A*f,g=b*r[m]+w*r[m+2]+T*r[M]+v*r[M+2],x=b*r[m+1]+w*r[m+3]+T*r[M+1]+v*r[M+3],h=g-0.5,k=x-0.5;if(!(h>-1&&k>-1&&h<t&&k<n))continue;let S=Math.floor(h),R=Math.floor(k),N=h-S,W=k-R,B=0,P=0,U=0,I=0;for(let E=0;E<4;E+=1){let C=S+(E&1),V=R+(E>>1);if(C<0||V<0||C>=t||V>=n)continue;let H=4*(V*t+C),z=(E&1?N:1-N)*(E>>1?W:1-W)*e[H+3];B+=z*e[H],P+=z*e[H+1],U+=z*e[H+2],I+=z}if(I<=0)continue;let F=4*(l*s+p);a[F]=B/I,a[F+1]=P/I,a[F+2]=U/I,a[F+3]=I}}return a},Tt=(e=zn)=>{let t=new Map,n=new Set,r=(l)=>{n.delete(l),l.then((u)=>u?.close(),()=>{return})},o=(l)=>{if(t.has(l))n.add(l);else r(l)},s=new le(e,o),a=(l)=>{let u=(t.get(l)??1)-1;if(u>0)t.set(l,u);else if(t.delete(l),n.has(l))r(l)},i=(l)=>{let u=()=>{let f=(async()=>{let p=await fetch(l,oe(l));if(p.status===404||p.status===204||p.status===410)return null;if(!p.ok)throw ie(l,p.status);return createImageBitmap(await p.blob())})();return f.catch(()=>s.delete(l)),s.set(l,f),f},d=s.get(l)??u();return t.set(d,(t.get(d)??0)+1),d};return{draw:async(l,u)=>{let d=l.sources.map((f)=>[f,i(f.url)]);try{let f=await Promise.all(d.map(async([m,M])=>[m,await M]));if(u.throwIfAborted(),!f.some(([,m])=>m))return null;let _=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!_)throw Error("isard: no 2D canvas to reproject the tiles");f.forEach(([m,M])=>{if(M)_.drawImage(M,m.x,m.y,m.w,m.h)});let y=_.getImageData(0,0,l.width,l.height).data,A=Hn(y,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(A,l.size,l.size),{premultiplyAlpha:"none"})}finally{d.forEach(([,f])=>{a(f)})}},cache:s,close:()=>{[...s.values()].forEach(o),s.clear()}}};var xe=(e,t,n)=>Math.max(t,Math.min(n,e));var zo=Math.PI/180,Et=40075016.686,Ho=Et/360;var It=(e)=>e*360-180,Ft=(e)=>Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI;var rt=(e)=>Et*Math.cos(Math.atan(Math.sinh(Math.PI*(1-2*e)))),_e=(e,t)=>rt((t+0.5)/2**e)/2**e,K=(e,t,n,r)=>e.replaceAll("{z}",String(t)).replaceAll("{x}",String(n)).replaceAll("{y}",String(r));var fe=256,Jn=(e,t,n=Number.NEGATIVE_INFINITY)=>{let r=e.length>>2,o=new Float32Array(r);if(t==="terrarium")for(let s=0,a=0;s<r;s+=1,a+=4){let i=e[a]*256+e[a+1]+e[a+2]/256-32768;o[s]=i>n?i:n}else for(let s=0,a=0;s<r;s+=1,a+=4){let i=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;o[s]=i>n?i:n}return o},Nt=async(e,t,n,r,o)=>{let s=await fetch(e,oe(e,{signal:r}));if(s.status===404||s.status===204||s.status===410)return null;if(!s.ok)throw ie(e,s.status);let a=await createImageBitmap(await s.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{o.canvas??=new OffscreenCanvas(fe,fe);let i=o.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("isard: no 2D context");return i.imageSmoothingEnabled=!1,i.clearRect(0,0,fe,fe),i.drawImage(a,0,0,fe,fe),Jn(i.getImageData(0,0,fe,fe).data,t,n)}finally{a.close()}};var jn="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",ot,qn=(e)=>{if(!ot){let t=jn.split(" ");ot=new Map(Array.from({length:Math.floor(t.length/2)},(n,r)=>[t[2*r]??"",t[2*r+1]??""]))}return ot.get(e)},ze=(e)=>Number.isFinite(e)?xe(e,0,1):0,Ot=(e)=>{if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((r)=>r+r).join(""):e,n=(r)=>Number.parseInt(t.slice(r,r+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]},$n=(e)=>{if(e===void 0)return 1;return ze(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))},Yn=(e,t,n)=>{let r=n<0.5?n*(1+t):n+t-n*t,o=2*n-r,s=(a)=>{let i=(a%1+1)%1;if(i<0.16666666666666666)return o+(r-o)*6*i;if(i<0.5)return r;if(i<0.6666666666666666)return o+(r-o)*(0.6666666666666666-i)*6;return o};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]},Pt=(e)=>{if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Ot(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=qn(t);if(n)return Ot(n);let r=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!r?.[1]||r[2]===void 0)return;let o=r[2].split(/[\s,/]+/).filter(Boolean);if(o.length<3||o.slice(0,3).some((u)=>Number.isNaN(Number.parseFloat(u))))return;let s=$n(o[3]);if(r[1].startsWith("rgb")){let u=(d)=>ze(d.endsWith("%")?Number.parseFloat(d)/100:Number.parseFloat(d)/255);return[u(o[0]??""),u(o[1]??""),u(o[2]??""),s]}let a=Number.parseFloat(o[0]??"")/360,[i,c,l]=Yn(a,ze(Number.parseFloat(o[1]??"")/100),ze(Number.parseFloat(o[2]??"")/100));return[i,c,l,s]};var be=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);var Gn=["Unknown","Point","LineString","Polygon"],Z=(e,t)=>({zoom:t,properties:e.properties,type:Gn[e.type]??"Unknown"}),ce=(e)=>Pt(e),Je=([e,t,n,r])=>`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${r})`,Wt=(e,t,n,r=1)=>{let o=n-t;if(o===0)return 0;let s=e-t;return r===1?s/o:(r**s-1)/(r**o-1)},it=(e,t,n)=>{if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let r=ce(e),o=ce(t);if(r&&o){let s=(a)=>r[a]+(o[a]-r[a])*n;return Je([s(0),s(1),s(2),s(3)])}if(Array.isArray(e)&&Array.isArray(t))return e.map((s,a)=>it(s,t[a],n));return n<0.5?e:t},Dt=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops),Kn=(e,t)=>{let n=e.property===void 0?t.zoom:t.properties[e.property],r=e.stops,o=e.type??(e.property===void 0||typeof r[0]?.[0]==="number"?"exponential":"categorical");if(o==="identity")return n??e.default;if(o==="categorical")return r.find(([u])=>u===n)?.[1]??e.default;if(typeof n!=="number"||!r.length)return e.default??r[0]?.[1];let s=([u])=>{if(Array.isArray(u))return Number.NaN;return be(u)?Number(u.zoom):Number(u)},a=r[0];if(!a)return e.default;if(n<=s(a))return a[1];let i=r.findIndex((u,d)=>d>0&&Boolean(r[d-1])&&Boolean(u)&&n<s(u)),[c,l]=[r[i-1],r[i]];if(i<0||!c||!l)return r.at(-1)?.[1];if(o==="interval")return c[1];return it(c[1],l[1],Wt(n,s(c),s(l),e.base??1))},st=(e)=>e,Lt={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t},Bt=(e,t,n)=>{let r=(a)=>typeof a==="object"&&a!==null?String(a):a,[o,s]=[r(t),r(n)];return typeof o==="string"&&typeof s==="string"?Lt[e](o,s):Lt[e](Number(o),Number(s))},He=(e,t)=>{if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0},Zn=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]),ve=(e)=>Array.isArray(e)&&typeof e[0]==="string"&&Zn.has(e[0]),Ut=new Set,ke=(e)=>e===void 0||e===null?"":String(e),ae=(e,t)=>{if(Dt(e))return Kn(e,t);if(!Array.isArray(e))return e;let[n,...r]=e;if(typeof n!=="string")return e;let o=(i)=>ae(r[i]??null,t),s=(i)=>Number(o(i)),a=()=>r.map((i,c)=>s(c));switch(n){case"literal":return r[0];case"zoom":return t.zoom;case"get":return He(t,o(0));case"has":return He(t,o(0))!==void 0;case"!has":return He(t,o(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return r.map((i,c)=>ke(o(c))).join("");case"format":return r.map((i,c)=>i!==null&&typeof i==="object"&&!Array.isArray(i)?"":ke(o(c))).join("");case"image":return o(0);case"number-format":{let i=be(r[1])?r[1]:{},c=(u)=>{let d=i[u];return typeof d==="number"?d:void 0},l=s(0);if(!Number.isFinite(l))return"";return l.toLocaleString(typeof i.locale==="string"?i.locale:void 0,{minimumFractionDigits:c("min-fraction-digits"),maximumFractionDigits:c("max-fraction-digits")})}case"to-number":{for(let i=0;i<r.length;i+=1){let c=o(i),l=typeof c==="string"&&c.trim()===""?Number.NaN:Number(c);if(c!==null&&c!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return ke(o(0));case"to-boolean":{let i=o(0);return!(i===""||i===0||i===!1||i===null||i===void 0||Number.isNaN(i))}case"to-color":case"number":case"string":case"boolean":{let i={"to-color":(c)=>ce(c)!==void 0,number:(c)=>typeof c==="number",string:(c)=>typeof c==="string",boolean:(c)=>typeof c==="boolean"};for(let c=0;c<r.length;c+=1){let l=o(c);if(i[n]?.(l))return l}return r.length?o(r.length-1):null}case"typeof":{let i=o(0);if(i===null||i===void 0)return"null";return Array.isArray(i)?"array":typeof i}case"length":{let i=o(0);return typeof i==="string"||Array.isArray(i)?i.length:0}case"at":{let i=o(1);return Array.isArray(i)?i[s(0)]??null:null}case"upcase":return ke(o(0)).toUpperCase();case"downcase":return ke(o(0)).toLowerCase();case"coalesce":for(let i=0;i<r.length;i+=1){let c=o(i);if(c!==void 0&&c!==null)return c}return null;case"!":return!o(0);case"all":return r.every((i,c)=>Boolean(o(c)));case"any":return r.some((i,c)=>Boolean(o(c)));case"==":return o(0)===o(1);case"!=":return o(0)!==o(1);case"<":case"<=":case">":case">=":return Bt(n,o(0),o(1));case"in":{let i=o(1),c=o(0);if(typeof i==="string")return i.includes(String(c));return Array.isArray(i)&&i.includes(c)}case"case":{let i=r.findIndex((c,l)=>l%2===0&&l+1<r.length&&Boolean(o(l)));return i<0?o(r.length-1):o(i+1)}case"match":{let i=o(0),c=r.findIndex((l,u)=>u%2===1&&u+1<r.length&&(Array.isArray(l)?st(l).includes(i):l===i));return c<0?o(r.length-1):o(c+1)}case"step":{let i=s(0),c=o(1);for(let l=2;l+1<r.length;l+=2)if(i>=Number(r[l]))c=o(l+1);else break;return c}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let i=r[0],c=s(1),l=Array.isArray(i)&&i[0]==="exponential"?Number(i[1]):1,u=Array.from({length:Math.floor((r.length-2)/2)},(y,A)=>[Number(r[2+2*A]),r[3+2*A]??null]),d=u[0];if(!d)return null;if(c<=d[0])return ae(d[1],t);let f=u.findIndex((y,A)=>A>0&&c<y[0]),[p,_]=[u[f-1],u[f]];if(f<0||!p||!_)return ae(u.at(-1)?.[1]??null,t);return it(ae(p[1],t),ae(_[1],t),Wt(c,p[0],_[0],l))}case"rgb":case"rgba":return Je([s(0)/255,s(1)/255,s(2)/255,r.length>3?s(3):1]);case"+":return a().reduce((i,c)=>i+c,0);case"*":return a().reduce((i,c)=>i*c,1);case"-":return r.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Ut.has(n))Ut.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}},Xn=new Set(["==","!=","<","<=",">",">="]),je=(e)=>{if(e.type==="line")return"line";if(e.type==="fill-extrusion")return"extrusion";if(e.type==="circle")return"circle";return e.type==="fill"||e.type==="background"?"fill":void 0},Qn=(e)=>{let[t,n,...r]=e;if(typeof t!=="string"||typeof n!=="string"||r.some(Array.isArray))return!1;if(Xn.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"},er=(e,t)=>{let[n,r,...o]=e,s=He(t,r);switch(n){case"==":return s===o[0];case"!=":return s!==o[0];case"<":case"<=":case">":case">=":return Bt(n,s,o[0]);case"in":return st(o).includes(s);case"!in":return!st(o).includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}},Ct=new WeakMap,Vt=(e)=>{if(!Array.isArray(e))return()=>Boolean(e);let t=Ct.get(e);if(t)return t;let r=(()=>{let o=e[0];if(o==="all"||o==="any"||o==="none"){let s=e.slice(1).map(Vt);if(o==="all")return(a)=>s.every((i)=>i(a));if(o==="any")return(a)=>s.some((i)=>i(a));return(a)=>!s.some((i)=>i(a))}if(Qn(e))return(s)=>er(e,s);return(s)=>Boolean(ae(e,s))})();return Ct.set(e,r),r},Q=(e,t)=>{if(e===void 0||e===null)return!0;return Vt(e)(t)},at=(e)=>Array.isArray(e)&&(e[0]==="zoom"||e.some(at)),tr=new Set(["get","has","!has","geometry-type","properties","id"]),me=(e)=>{if(e!==void 0&&Dt(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(tr.has(e[0]))return!0;return e.some((t)=>me(t))},ct=(e,t)=>{if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(r,o)=>{let s=t.properties[o];return s===void 0?"":String(s)});let n=ae(e,t);if(Array.isArray(n))return n.filter((r)=>typeof r==="string").join("");return n===void 0||n===null?"":String(n)},zt=(e)=>/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`,lt=(e)=>{let t=new Set,n=(i)=>i.filter((c,l)=>l>=3&&l%2===1).map(Number),r=(i)=>{if(!Array.isArray(i))return;let c=(l)=>Array.isArray(l)&&l[0]==="zoom";if((i[0]==="interpolate"||i[0]==="interpolate-hcl"||i[0]==="interpolate-lab")&&c(i[2]))n(i).forEach((l)=>{t.add(l)});else if(i[0]==="step"&&c(i[1]))n(i).forEach((l)=>{t.add(l),t.add(l-0.01)});i.forEach(r)};r(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[s,a]=[Math.min(...o),Math.max(...o)];return o.push(...Array.from({length:Math.floor(a)-Math.ceil(s)+1},(i,c)=>Math.ceil(s)+c)),[...new Set(o)].sort((i,c)=>i-c).map((i)=>[i,Number(ae(e,{zoom:i,properties:{},type:"Unknown"}))])};class Fe{static __wrap(e){let t=Object.create(Fe.prototype);return t.__wbg_ptr=e,Ht.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ht.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_gridset_free(e,0)}count(){return D.gridset_count(this.__wbg_ptr)>>>0}meta(e){let t,n;try{let r=D.gridset_meta(this.__wbg_ptr,e);return t=r[0],n=r[1],ft(r[0],r[1])}finally{D.__wbindgen_free(t,n,1)}}values(e){return D.gridset_values(this.__wbg_ptr,e)}}if(Symbol.dispose)Fe.prototype[Symbol.dispose]=Fe.prototype.free;class Ne{static __wrap(e){let t=Object.create(Ne.prototype);return t.__wbg_ptr=e,Jt.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Jt.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_streetflow_free(e,0)}eastU(){return D.streetflow_eastU(this.__wbg_ptr)}eastV(){return D.streetflow_eastV(this.__wbg_ptr)}northU(){return D.streetflow_northU(this.__wbg_ptr)}northV(){return D.streetflow_northV(this.__wbg_ptr)}}if(Symbol.dispose)Ne.prototype[Symbol.dispose]=Ne.prototype.free;function qt(e){let t=ar(e,D.__wbindgen_malloc),n=ye,r=D.readGrids(t,n);if(r[2])throw lr(r[1]);return Fe.__wrap(r[0])}function $t(e,t,n,r,o,s){let a=cr(e,D.__wbindgen_malloc),i=ye,c=jt(t,D.__wbindgen_malloc),l=ye,u=jt(n,D.__wbindgen_malloc),d=ye,f=D.streetFlow(a,i,c,l,u,d,r,o,s);return Ne.__wrap(f)}function nr(){return{__proto__:null,"./isard_grid_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(ft(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(rr(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return ft(t,n)},__wbindgen_init_externref_table:function(){let t=D.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_gridset_free(e,1)),Jt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_streetflow_free(e,1));function rr(e,t){return e=e>>>0,or().subarray(e/4,e/4+t)}var Re=null;function or(){if(Re===null||Re.byteLength===0)Re=new Float32Array(D.memory.buffer);return Re}var Te=null;function sr(){if(Te===null||Te.byteLength===0)Te=new Float64Array(D.memory.buffer);return Te}function ft(e,t){return fr(e>>>0,t)}var Ee=null;function ir(){if(Ee===null||Ee.byteLength===0)Ee=new Uint32Array(D.memory.buffer);return Ee}var Ie=null;function Yt(){if(Ie===null||Ie.byteLength===0)Ie=new Uint8Array(D.memory.buffer);return Ie}function jt(e,t){let n=t(e.length*4,4)>>>0;return ir().set(e,n/4),ye=e.length,n}function ar(e,t){let n=t(e.length*1,1)>>>0;return Yt().set(e,n/1),ye=e.length,n}function cr(e,t){let n=t(e.length*8,8)>>>0;return sr().set(e,n/8),ye=e.length,n}function lr(e){let t=D.__wbindgen_externrefs.get(e);return D.__externref_table_dealloc(e),t}var qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qe.decode();var ur=2146435072,ut=0;function fr(e,t){if(ut+=t,ut>=ur)qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qe.decode(),ut=t;return qe.decode(Yt().subarray(e,e+t))}var ye=0,mr,pr,D;function dr(e,t){return pr=e,D=e.exports,mr=t,Re=null,Te=null,Ee=null,Ie=null,D.__wbindgen_start(),D}async function br(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Gt(e){if(D!==void 0)return D;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_grid_bg.wasm",import.meta.url);let t=nr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await br(await e,t);return dr(n,r)}var mt={},Kt=async(e)=>{let t=mt.ready??Gt({module_or_path:e});mt.ready=t,await t.catch((n)=>{throw mt.ready=void 0,n})},Zt=async(e,t,n,r,o)=>{await Kt(o);let s=$t(e.points,e.ringStart,e.polygonStart,t,n,r);try{return{eastU:s.eastU(),eastV:s.eastV(),northU:s.northU(),northV:s.northV()}}finally{s.free()}},yr=(e)=>typeof e==="object"&&e!==null&&("name"in e)&&("width"in e)&&("height"in e)&&("bounds"in e)&&Array.isArray(e.bounds),Xt=async(e,t)=>{await Kt(t);let n=qt(e);try{let r=[],o=[];for(let s=0;s<n.count();s++){let a=JSON.parse(n.meta(s));if(!yr(a))throw Error("isard: a grid without its description");r.push(a),o.push(n.values(s))}return{grids:r,values:o}}finally{n.free()}};var he=6,Qt=4;var en=(e)=>e*7919%360,pt=["shelter","bin","postbox","fountain","rack","bench"];class dt{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let r=this.buf[this.pos++]??0,o=r&127;if(n<4)e|=o<<7*n;else if(n===4)e|=(o&15)<<28,t|=o>>4;else t|=o<<7*n-32;if(r<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new dt(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=hr.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var hr=new TextDecoder,gr=(e)=>{let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t},wr=(e)=>{let t=[],n,[r,o]=[0,0];while(e.more){let s=e.varint(),a=s&7,i=s>>3;if(a===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let c=0;c<i&&e.more;c+=1){if(r+=e.sint(),o+=e.sint(),a===1)n=[],t.push(n);n?.push(r,o)}}return t},bt=(e,t)=>{let n=new Map,r=new dt(e);while(r.more){let o=r.varint();if(o>>3!==3){r.skip(o&7);continue}let s=r.sub(),a="",i=4096,c=[],l=[],u=[];while(s.more){let f=s.varint();switch(f>>3){case 1:a=s.string();break;case 2:u.push(s.sub());break;case 3:c.push(s.string());break;case 4:l.push(gr(s.sub()));break;case 5:i=s.varint();break;default:s.skip(f&7)}}if(t&&!t.has(a))continue;let d=[];for(let f of u){let p=1,_={},y=[];while(f.more){let A=f.varint();switch(A>>3){case 2:{let m=f.sub();while(m.more){let M=c[m.varint()],b=l[m.varint()];if(M!==void 0&&b!==void 0)_[M]=b}break}case 3:p=Math.min(3,Math.max(1,f.varint()));break;case 4:y=wr(f.sub());break;default:f.skip(A&7)}}d.push({type:p,properties:_,geometry:y})}n.set(a,{extent:i,features:d})}return n};var xr=127,_r=16384,Ar=["unknown","mvt","png","jpeg","webp","avif"],Mr=(e)=>(4**e-1)/3,Sr=(e,t,n)=>{if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let r=2**e;if(t<0||n<0||t>=r||n>=r)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[o,s]=[t,n],a=0;for(let i=r/2;i>=1;i/=2){let c=(o&i)>0?1:0,l=(s&i)>0?1:0;if(a+=i*i*(3*c^l),l===0){if(c===1)[o,s]=[i-1-o,i-1-s];[o,s]=[s,o]}}return Mr(e)+a};class rn{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}var tn=(e)=>{let t=new rn(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let r=[],o=0;for(let s=0;s<n;s+=1)o+=t.next(),r.push({tileId:o,offset:0,length:0,runLength:1});for(let s of r)s.runLength=t.next();for(let s of r)s.length=t.next();return r.forEach((s,a)=>{let i=t.next(),c=r[a-1];s.offset=i===0&&c?c.offset+c.length:i-1}),r},kr=(e,t)=>{let[n,r]=[0,e.length-1];while(n<=r){let s=n+r>>1,a=e[s];if(!a)break;if(a.tileId===t)return a;if(a.tileId<t)n=s+1;else r=s-1}let o=e[r];if(!o)return;if(o.runLength===0||t-o.tileId<o.runLength)return o;return},vr=(e)=>{if(e.length<xr||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(o)=>Number(t.getBigUint64(o,!0)),r=(o)=>t.getInt32(o,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Ar[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[r(102),r(106),r(110),r(114)],center:[r(119),r(123),t.getUint8(118)]}},$e=async(e,t)=>{if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())},Rr=67108864;class on{source;head;leaves=new le(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let r=await fetch(this.source,oe(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}}));if(!r.ok)throw ie(this.source,r.status);if(r.status===206)return new Uint8Array(await r.arrayBuffer());if(Number(r.headers.get("Content-Length"))>Rr)throw await r.body?.cancel(),Error(`isard: ${this.source}: the server ignores range requests (HTTP 206 expected)`);let s=r.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=s,s.catch(()=>{this.whole=void 0}),(await s).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,_r),t=vr(e),{rootDirectoryOffset:n,rootDirectoryLength:r}=t,o=n+r<=e.length?e.subarray(n,n+r):await this.range(n,r),s=tn(await $e(o,t.internalCompression));return{header:t,root:s}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await $e(t,e.internalCompression)),r=JSON.parse(n);return be(r)?r:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,r=this.leaves.get(n);if(r)return r;let o=this.range(n,t.length).then(async(s)=>tn(await $e(s,e.internalCompression)));return o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o),o}async tile(e,t,n,r){let{header:o,root:s}=await this.load();if(e<o.minZoom||e>o.maxZoom)return;let a=Sr(e,t,n),i=s;for(let c=0;c<4;c+=1){let l=kr(i,a);if(!l)return;if(l.runLength>0){let u=await this.range(o.tileDataOffset+l.offset,l.length,r);return $e(u,o.tileCompression)}i=await this.leaf(o,l)}throw Error("isard: PMTiles directories nested too deep")}}var nn=new le(16),Tr=(e)=>{let t=nn.get(e);if(t)return t;let n=new on(e);return nn.set(e,n),n};var yt=(e,t)=>{let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,r="",o,s,a]=n;return Tr(r).tile(Number(o),Number(s),Number(a),t)};var gt=(e,t)=>{let n=e.sprites.find((o)=>Boolean(o.icons[t])),r=n?.icons[t];return n&&r?{icon:r,image:n.image}:void 0},Pe=new Map,sn=96,Oe=new le(sn),an=(e)=>Math.max(16,Math.ceil(sn/Math.max(1,e))),Ye=new Set,J=new Set,ht=new le(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return})),cn=(e,t="auto")=>{let n=ht.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let i=await o;return i&&createImageBitmap(new Blob([i]))}let a=await fetch(e,oe(e,{priority:t}));if(a.status===404||a.status===204)return;if(!a.ok)throw ie(e,a.status);return createImageBitmap(await a.blob())})();return r.catch(()=>ht.delete(e)),ht.set(e,r),r},ee=(e,t="auto")=>{let n=Oe.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let s=await o;return s&&bt(s)}for(let s=0;;s+=1){let i=await fetch(e,oe(e,{priority:t}));if(i.status===404||i.status===204)return;if(i.ok)return bt(new Uint8Array(await i.arrayBuffer()));if(s>=2)throw ie(e,i.status);await new Promise((c)=>setTimeout(c,400*(s+1)))}})();return r.catch(()=>Oe.delete(e)),Oe.set(e,r),r},ln=(e,t,n,r)=>{let o=xe(t-1,0,e.maxzoom),s=t-o,a=2**Math.max(0,s),[i,c]=s>=0?[Math.floor(n/a),Math.floor(r/a)]:[n,r],l=K(e.tiles,o,i,c),u=1/a;return{url:l,vz:o,vx:i,vy:c,part:u,ox:n%a*u,oy:r%a*u}},L=(e,t,n,r,o)=>{let s=e[t]?.[n];if(s===void 0)return o;let a=Array.isArray(s)&&!ve(s)?s:ae(s,r);return a===void 0||a===null?o:a},pe=(e,t)=>{let n=ce(e)??[0,0,0,1];return Je([n[0],n[1],n[2],n[3]*t])},Le=(e,t)=>{if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)},Y=(e,t,n,r,o,s)=>{let a=2**e;return[It((t+o/r)/a),Ft((n+s/r)/a)]};var Er=300,un=(e,t,n)=>{let r=Boolean(L(e,"layout",`${t}-allow-overlap`,n,!1)),o=Boolean(L(e,"layout",`${t}-ignore-placement`,n,!1));if(r&&o)return!0;if(r)return"allow";return o?"ignore":!1},fn=(e,t)=>Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t,Ir=(e)=>{let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,r=n,o=n,s=r]=t;return[n,r,o,s]},Fr=(e,t)=>{if(t==="uppercase")return e.toUpperCase();if(t==="lowercase")return e.toLowerCase();return e},Ae=(e,t)=>{let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let r=[];if(!(n>0)||!(t>0))return r;let o=Math.min(t/2,n/2),s=0;for(let a=2;a+1<e.length;a+=2){let[i,c,l,u]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],d=Math.hypot(l-i,u-c);while(d>0&&o<=s+d){let f=(o-s)/d;r.push([i+(l-i)*f,c+(u-c)*f,i,c,l,u,o]),o+=t}s+=d}return r},Ke=(e,t,n)=>{let[r=0,o=0,s=0,a=0,i=0,c=0]=e,l=Math.hypot(i-s,c-a)||1,u=t%2===0?1:-1,[d,f]=[-(c-a)/l*u,(i-s)/l*u];return[r+d*n,o+f*n,Math.atan2(-d,f)*180/Math.PI]},Nr=(e,t,n)=>{let r=[],o=0;for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],u=Math.hypot(c-a,l-i),[d,f]=[o,o+u];if(o=f,u<=0||f<t||d>n)continue;let p=(_)=>[a+(c-a)*(_-d)/u,i+(l-i)*(_-d)/u];if(r.length===0)r.push(...p(Math.max(t,d)));r.push(...p(Math.min(n,f)))}return r},Or=(e,t,n,r,o)=>{let s=L(e,"layout","icon-rotation-alignment",n,"auto"),a=String(L(e,"layout","icon-text-fit",n,"none")),i=L(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:me(e.layout?.["icon-size"])?Number(L(e,"layout","icon-size",n,1)):o(e),anchor:String(L(e,"layout","icon-anchor",n,"center")),offset:fn(L(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(L(e,"layout","icon-rotate",n,0))||0,alignment:s==="map"||s==="auto"&&r==="line"?"map":"viewport",overlap:un(e,"icon",n),optional:Boolean(L(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:Ir(i),color:String(L(e,"paint","icon-color",n,"#000")),opacity:Number(L(e,"paint","icon-opacity",n,1))}},Ge=16,Pr=(e,t,n)=>{let r=[],o=new Map,s=4096;e.layers.forEach((c)=>{if(c.type!=="fill-extrusion"||!Le(c,n))return;let l=t.get(c["source-layer"]??"");if(!l)return;s=l.extent;for(let u of l.features){let d=Z(u,n);if(u.type!==3||!Q(c.filter,d))continue;let f=Number(L(c,"paint","fill-extrusion-height",d,0));if(!(f>0))continue;let p=[1/0,1/0,-1/0,-1/0];for(let _ of u.geometry)for(let y=0;y+1<_.length;y+=2){let[A,m]=[_[y]??0,_[y+1]??0];p[0]=Math.min(p[0],A),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],A),p[3]=Math.max(p[3],m)}r.push({rings:u.geometry,height:f,box:p})}});let a=(c)=>Math.max(0,Math.min(Ge-1,Math.floor(c/s*Ge)));r.forEach(({box:c},l)=>{for(let u=a(c[1]);u<=a(c[3]);u++)for(let d=a(c[0]);d<=a(c[2]);d++){let f=u*Ge+d,p=o.get(f);if(p)p.push(l);else o.set(f,[l])}});let i=(c,l,u)=>{let d=!1;for(let f of c)for(let p=0,_=f.length-2;p+1<f.length;_=p,p+=2){let[y,A,m,M]=[f[p]??0,f[p+1]??0,f[_]??0,f[_+1]??0];if(A>u!==M>u&&l<(m-y)*(u-A)/(M-A)+y)d=!d}return d};return(c,l)=>(o.get(a(l)*Ge+a(c))??[]).reduce((u,d)=>{let f=r[d];return f&&i(f.rings,c,l)?Math.max(u??0,f.height):u},void 0)},mn=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a,zoom:i=n,roofs:c=!1}=t,l=K(e.tiles,n,r,o),u=await ee(l,a);if(!u||J.has(s))return[];let d=[],f=c?Pr(e,u,i):()=>{return},p=new Map,_=(m)=>{let M=p.get(m);if(M!==void 0)return M;let b=m.layout?.["text-size"]??16,w=ve(b)?lt(b):b;return p.set(m,w),w},y=new Map,A=(m)=>{let M=y.get(m);if(M!==void 0)return M;let b=m.layout?.["icon-size"]??1,w=ve(b)?lt(b):b;return y.set(m,w),w};return e.layers.forEach((m,M)=>{let b=m.layout??{};if(m.type!=="symbol"||!Le(m,i))return;if(b["text-field"]===void 0&&b["icon-image"]===void 0)return;let w=u.get(m["source-layer"]??"");if(!w)return;let T={zoom:i,properties:{},type:"Unknown"},v=L(m,"layout","symbol-placement",T,"point")==="line"?"line":"point",g=v==="line"&&L(m,"layout","text-rotation-alignment",T,"auto")!=="viewport";for(let x of w.features){let h=Z(x,i);if(!Q(m.filter,h))continue;let k=ct(b["text-field"],h).trim(),S=ct(b["icon-image"],h).trim();if(!k&&!S)continue;let R=Fr(k,L(m,"layout","text-transform",h,"none")),N=L(m,"layout","text-font",h,["Noto Sans Regular"]),W=zt(Array.isArray(N)&&typeof N[0]==="string"?N[0]:"Noto Sans Regular"),B={layer:M,text:R,font:W,size:me(m.layout?.["text-size"])?Number(L(m,"layout","text-size",h,16)):_(m),color:String(L(m,"paint","text-color",h,"#000")),haloColor:String(L(m,"paint","text-halo-color",h,"rgba(0,0,0,0)")),haloWidth:Number(L(m,"paint","text-halo-width",h,0)),anchor:String(L(m,"layout","text-anchor",h,"center")),offset:fn(L(m,"layout","text-offset",h,[0,0]),[0,0]),maxWidth:Number(L(m,"layout","text-max-width",h,10)),lineHeight:Number(L(m,"layout","text-line-height",h,1.2)),overlap:un(m,"text",h),...g?{textAlong:g}:{},...L(m,"layout","text-optional",h,!1)?{textOptional:!0}:{},...S?{icon:Or(m,S,h,v,A)}:{}};if(x.type===1)for(let P of x.geometry)for(let U=0;U+1<P.length;U+=2){let[I,F]=[P[U]??0,P[U+1]??0];if(I<0||F<0||I>=w.extent||F>=w.extent)continue;let[E,C]=Y(n,r,o,w.extent,I,F),V=f(I,F);d.push({...B,lon:E,lat:C,...V===void 0?{}:{height:V}})}else if(!R&&v==="line"){let P=Number(L(m,"layout","symbol-spacing",h,250))*w.extent/(512*2**(i-n));for(let U of x.geometry)for(let[I=0,F=0,E=0,C=0,V=0,H=0]of Ae(U,Math.max(P,1))){if(I<0||F<0||I>=w.extent||F>=w.extent)continue;let[z,te]=Y(n,r,o,w.extent,I,F),[G,ne]=Y(n,r,o,w.extent,V,H),[X,re]=Y(n,r,o,w.extent,E,C);d.push({...B,lon:z,lat:te,along:[G-X,ne-re]})}}else if(R&&g){let P=w.extent/(512*2**(i-n)),U=Number(L(m,"layout","symbol-spacing",h,250))*P;for(let I of x.geometry){let F=0;for(let E=2;E+1<I.length;E+=2)F+=Math.hypot((I[E]??0)-(I[E-2]??0),(I[E+1]??0)-(I[E-1]??0));if(F<w.extent/32)continue;for(let[E=0,C=0,V=0,H=0,z=0,te=0,G=0]of Ae(I,Math.max(U,1))){if(E<0||C<0||E>=w.extent||C>=w.extent)continue;let ne=Math.min(G,F-G,Er*P),X=Nr(I,G-ne,G+ne),re=[];for(let Ve=0;Ve+1<X.length;Ve+=2)re.push(...Y(n,r,o,w.extent,X[Ve]??0,X[Ve+1]??0));let[Me,Se]=Y(n,r,o,w.extent,E,C),[nt,Dn]=Y(n,r,o,w.extent,z,te),[Bn,Vn]=Y(n,r,o,w.extent,V,H);d.push({...B,lon:Me,lat:Se,along:[nt-Bn,Dn-Vn],...re.length>=4?{path:re}:{}})}}}else{let P,U=0;for(let F of x.geometry){let E=0;for(let C=2;C+1<F.length;C+=2)E+=Math.hypot((F[C]??0)-(F[C-2]??0),(F[C+1]??0)-(F[C-1]??0));if(E>U)U=E,P=F}if(!P||U<w.extent/32)continue;let I=U/2;for(let F=2;F+1<P.length;F+=2){let[E,C,V,H]=[P[F-2]??0,P[F-1]??0,P[F]??0,P[F+1]??0],z=Math.hypot(V-E,H-C);if(z>=I&&z>0){let[te,G]=[E+(V-E)*I/z,C+(H-C)*I/z];if(te<0||G<0||te>=w.extent||G>=w.extent)break;let[ne,X]=Y(n,r,o,w.extent,te,G),[re,Me]=Y(n,r,o,w.extent,V,H),[Se,nt]=Y(n,r,o,w.extent,E,C);d.push({...B,lon:ne,lat:X,...v==="line"?{along:[re-Se,Me-nt]}:{}});break}I-=z}}}}),d};var pn=(e)=>{let t=e.leaf_type,n=typeof e.nature==="string"?e.nature:"";if(t==="needleleaved"||/conif/i.test(n))return 1;if(t==="broadleaved"||/feuillu/i.test(n))return 0;if(t==="mixed"||/mixte/i.test(n))return 0.5;if(e.class==="wood")return e.subclass==="forest"?0.35:0.15;return 0};var Ze=(e,t)=>{let n=e.length/he,r=n>t?t/n:1,o=[];for(let s=0;s<n;s+=1)if(r>=1||(e[s*he+Qt]??0)<r)o.push(...e.slice(s*he,(s+1)*he));return Float64Array.from(o)},se=(e,t,n,r)=>{let o=Math.imul(e^2654435769,2246822507)^Math.imul(t^3266489909,668265263);return o=Math.imul(o^o>>>15^Math.imul(n,374761393),739982445),o=Math.imul(o^o>>>13^Math.imul(r,695872825),695872825),((o^o>>>16)>>>0)/4294967296},ge=(e,t,n)=>e.reduce((r,o)=>{let s=o.length/2,a=0;for(let i=0,c=s-1;i<s;c=i,i+=1){let[l,u,d,f]=[o[i*2]??0,o[i*2+1]??0,o[c*2]??0,o[c*2+1]??0];if(u>n!==f>n&&t<(d-l)*(n-u)/(f-u)+l)a+=1}return a%2===1?!r:r},!1),Lr=(e,t,n,r,o=Number.POSITIVE_INFINITY)=>{let s=e[0]??[],a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let T=0;T+1<s.length;T+=2){let[v,g]=[s[T]??0,s[T+1]??0];a[0]=Math.min(a[0]??v,v),a[1]=Math.min(a[1]??g,g),a[2]=Math.max(a[2]??v,v),a[3]=Math.max(a[3]??g,g)}let[i,c]=[Math.max(0,a[0]??0),Math.max(0,a[1]??0)],[l,u]=[Math.min(t,a[2]??0),Math.min(t,a[3]??0)];if(!(n>0)||i>=l||c>=u)return[];let d=(l-i)/n*((u-c)/n),f=d>o?n*Math.sqrt(d/o):n,[p,_,y,A]=[Math.floor(i/f),Math.ceil(l/f),Math.floor(c/f),Math.ceil(u/f)],[m,M,b]=r,w=Math.imul(m+1,16777619)^Math.imul(M,1540483477)^Math.imul(b,461845907);return Array.from({length:Math.max(0,A-y)},(T,v)=>y+v).flatMap((T)=>Array.from({length:Math.max(0,_-p)},(v,g)=>p+g).flatMap((v)=>{let g=(v+se(w,v,T,1))*f,x=(T+se(w,v,T,2))*f;if(g<0||x<0||g>=t||x>=t||!ge(e,g,x))return[];return[[g,x,se(w,v,T,3)]]}))},dn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxTrees:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||J.has(s))return;let d=_e(n,o),f=[];e.layers.forEach((A,m)=>{let M=a[m]??0,b=u.get(A["source-layer"]??"");if(!b||!(M>0))return;let w=M/d*b.extent;b.features.forEach((T)=>{if(T.type!==3||!Q(A.filter,Z(T,n)))return;let v=pn(T.properties);T.geometry.reduce((x,h)=>{let k=0;for(let S=0;S+1<h.length;S+=2){let R=(S+2)%h.length;k+=(h[S]??0)*(h[R+1]??0)-(h[R]??0)*(h[S+1]??0)}if(k>0)x.push([h]);else if(k<0)x.at(-1)?.push(h);return x},[]).forEach((x)=>{Lr(x,b.extent,w,[n,r,o],i*4).forEach(([h,k,S])=>{f.push([h,k,S,b.extent,v])})})})});let p=f.length>i?i/f.length:1,_=f.filter(([,,A])=>p>=1||se(Math.floor(A*2147483648),n,r,o)<p),y=new Float64Array(_.length*he);return _.forEach(([A,m,M,b,w],T)=>{let[v,g]=Y(n,r,o,b,A,m),x=se(Math.floor(M*2147483648),7,11,13),h=se(Math.floor(M*2147483648),3,5,17)<w?1:0;y.set([v,g,0.75+0.5*M,en(M),x,h],T*he)}),y};var Ur={bus_stop:"shelter",waste_basket:"bin",post_box:"postbox",drinking_water:"fountain",bicycle_parking:"rack"},Cr=new Set(["primary","secondary","tertiary","minor","service","trunk"]),Wr=25,bn={street:[24,3.2],path:[18,1.3]},Dr=(e)=>e.filter((t)=>t.type===1),yn=async(e,t)=>{let{z:n,x:r,y:o,id:s,maxObjects:a,priority:i}=t,c=K(e.tiles,n,r,o),l=await ee(c,i);if(!l||J.has(s))return;let u=l.get("poi"),d=l.get("transportation"),f=d?.extent??u?.extent??4096,p=f/_e(n,o),_=(d?.features??[]).filter((g)=>g.type===2&&Cr.has(String(g.properties.class))),y=(l.get("landcover")?.features??[]).filter((g)=>g.type===3&&String(g.properties.class)==="grass").map((g)=>{let x=g.geometry[0]??[],h=x.filter((S,R)=>R%2===0),k=x.filter((S,R)=>R%2===1);return{rings:g.geometry,bounds:[Math.min(...h),Math.min(...k),Math.max(...h),Math.max(...k)]}}),A=(g,x)=>y.some(({rings:h,bounds:[k=0,S=0,R=0,N=0]})=>g>=k&&g<=R&&x>=S&&x<=N&&ge(h,g,x)),m=[],M=(g,x,h,k,S)=>{if(g<0||x<0||g>=f||x>=f)return;let[R,N]=Y(n,r,o,f,g,x);m.push(R,N,1,h,k,pt.indexOf(S))},b=Wr*p,w=new Map,T=(g,x)=>(g+32768)*65536+x+32768;_.forEach((g)=>{g.geometry.forEach((x)=>{for(let h=2;h+1<x.length;h+=2){let[k,S,R,N]=[x[h-2]??0,x[h-1]??0,x[h]??0,x[h+1]??0],[W,B]=[Math.floor(Math.min(k,R)/b),Math.floor(Math.max(k,R)/b)],[P,U]=[Math.floor(Math.min(S,N)/b),Math.floor(Math.max(S,N)/b)];for(let I=W;I<=B;I+=1)for(let F=P;F<=U;F+=1){let E=w.get(T(I,F))??[];E.push(k,S,R,N),w.set(T(I,F),E)}}})});let v=(g,x,h)=>{let[k,S,R]=[b*b,0,0],[N,W]=[Math.floor(g/b),Math.floor(x/b)];for(let B=N-1;B<=N+1;B+=1)for(let P=W-1;P<=W+1;P+=1){let U=w.get(T(B,P))??[];for(let I=0;I+3<U.length;I+=4){let[F,E,C,V]=[U[I]??0,U[I+1]??0,U[I+2]??0,U[I+3]??0],[H,z]=[C-F,V-E],te=H*H+z*z,G=te>0?Math.max(0,Math.min(1,((g-F)*H+(x-E)*z)/te)):0,[ne,X]=[F+G*H-g,E+G*z-x],re=ne*ne+X*X;if(re<k)[k,S,R]=[re,ne,X]}}if(S===0&&R===0)return h;return Math.atan2(S,-R)*180/Math.PI};return Dr(u?.features??[]).forEach((g)=>{let x=Ur[String(g.properties.subclass)];if(!x)return;g.geometry.forEach(([h=0,k=0])=>{let S=se(Math.floor(h),Math.floor(k),pt.indexOf(x),31);M(h,k,v(h,k,S*360),S,x)})}),(d?.features??[]).forEach((g)=>{let x=String(g.properties.subclass),h=String(g.properties.class)==="path"&&x==="pedestrian",k=String(g.properties.class)==="path"&&(x==="footway"||x==="path");if(g.type!==2||!(h||k))return;let[S,R]=h?bn.street:bn.path;g.geometry.forEach((N)=>{Ae(N,S*p).forEach((W,B)=>{let[P=0,U=0,,,,,I=0]=W;if(k&&!A(P,U))return;let F=se(Math.floor(P),Math.floor(U),Math.floor(I),37);M(...Ke(W,B,R*p),F,"bench")})})}),Ze(m,a)};var hn={flat:1,skillion:1,hipped:2,"half-hipped":2,side_hipped:2,dome:2,onion:2,round:2,gabled:3,saltbox:3,pyramidal:4,cone:4,mansard:5,gambrel:5},Br=255,gn=(e)=>e==="generated"?Br:hn[e],wn=(e,t)=>be(e)?t.map((n)=>e[n]).find((n)=>n!==void 0):void 0,xn=(e,t)=>{let n=wn(e,["roof:shape","roof_shape"]);if(t==="flat")return;if(typeof n==="string"&&hn[n]!==void 0)return n;return t==="generated"?"generated":void 0},_n=(e)=>Number(wn(e,["roof:height","roof_height"])??Number.NaN);var wt=32,j={color:0,second:4,size:8,size2:16,range:24,blur:26,landmark:26,patternRatio:27,fillPattern:28,linePattern:29};class Be{static __wrap(e){let t=Object.create(Be.prototype);return t.__wbg_ptr=e,An.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,An.unregister(this),e}free(){let e=this.__destroy_into_raw();O.__wbg_tessellatedtile_free(e,0)}blockIndices(){return O.tessellatedtile_blockIndices(this.__wbg_ptr)}blockRanges(){let e=O.tessellatedtile_blockRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}blocks(){return O.tessellatedtile_blocks(this.__wbg_ptr)}bounds(){let e=O.tessellatedtile_bounds(this.__wbg_ptr);var t=Hr(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*8,8),t}fillRanges(){let e=O.tessellatedtile_fillRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}indices(){return O.tessellatedtile_indices(this.__wbg_ptr)}lineRanges(){let e=O.tessellatedtile_lineRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}lineTable(){return O.tessellatedtile_lineTable(this.__wbg_ptr)}pieces(){return O.tessellatedtile_pieces(this.__wbg_ptr)}prism(){return O.tessellatedtile_prism(this.__wbg_ptr)!==0}vertices(){return O.tessellatedtile_vertices(this.__wbg_ptr)}}if(Symbol.dispose)Be.prototype[Symbol.dispose]=Be.prototype.free;function Sn(e,t,n,r,o,s,a,i,c,l,u,d,f,p,_,y,A){let m=Xe(e,O.__wbindgen_malloc),M=q,b=de(t,O.__wbindgen_malloc),w=q,T=de(n,O.__wbindgen_malloc),v=q,g=de(r,O.__wbindgen_malloc),x=q,h=de(o,O.__wbindgen_malloc),k=q,S=Xe(s,O.__wbindgen_malloc),R=q,N=de(a,O.__wbindgen_malloc),W=q,B=de(i,O.__wbindgen_malloc),P=q,U=de(c,O.__wbindgen_malloc),I=q,F=Mn(l,O.__wbindgen_malloc),E=q,C=Mn(u,O.__wbindgen_malloc),V=q,H=qr(d,O.__wbindgen_malloc),z=q,te=Xe(f,O.__wbindgen_malloc),G=q,ne=de(p,O.__wbindgen_malloc),X=q,re=Xe(A,O.__wbindgen_malloc),Me=q,Se=O.tessellateVectorTile(m,M,b,w,T,v,g,x,h,k,S,R,N,W,B,P,U,I,F,E,C,V,H,z,te,G,ne,X,_,y,re,Me);return Be.__wrap(Se)}function Vr(){return{__proto__:null,"./isard_tess_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(jr(t,n))},__wbg_new_from_slice_37a3c3a194266cb8:function(t,n){return new Uint32Array(Qe(t,n))},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(Jr(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(zr(t,n))},__wbindgen_init_externref_table:function(){let t=O.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var An=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>O.__wbg_tessellatedtile_free(e,1));function zr(e,t){return e=e>>>0,kn().subarray(e/4,e/4+t)}function Hr(e,t){return e=e>>>0,vn().subarray(e/8,e/8+t)}function Qe(e,t){return e=e>>>0,Rn().subarray(e/4,e/4+t)}function Jr(e,t){return e=e>>>0,_t().subarray(e/1,e/1+t)}var Ue=null;function kn(){if(Ue===null||Ue.byteLength===0)Ue=new Float32Array(O.memory.buffer);return Ue}var Ce=null;function vn(){if(Ce===null||Ce.byteLength===0)Ce=new Float64Array(O.memory.buffer);return Ce}function jr(e,t){return Yr(e>>>0,t)}var We=null;function Rn(){if(We===null||We.byteLength===0)We=new Uint32Array(O.memory.buffer);return We}var De=null;function _t(){if(De===null||De.byteLength===0)De=new Uint8Array(O.memory.buffer);return De}function de(e,t){let n=t(e.length*4,4)>>>0;return Rn().set(e,n/4),q=e.length,n}function Mn(e,t){let n=t(e.length*1,1)>>>0;return _t().set(e,n/1),q=e.length,n}function qr(e,t){let n=t(e.length*4,4)>>>0;return kn().set(e,n/4),q=e.length,n}function Xe(e,t){let n=t(e.length*8,8)>>>0;return vn().set(e,n/8),q=e.length,n}var et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});et.decode();var $r=2146435072,xt=0;function Yr(e,t){if(xt+=t,xt>=$r)et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),et.decode(),xt=t;return et.decode(_t().subarray(e,e+t))}var q=0,Gr,Kr,O;function Zr(e,t){return Kr=e,O=e.exports,Gr=t,Ue=null,Ce=null,We=null,De=null,O.__wbindgen_start(),O}async function Xr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Tn(e){if(O!==void 0)return O;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_tess_bg.wasm",import.meta.url);let t=Vr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await Xr(await e,t);return Zr(n,r)}var tt=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a}=t,i=K(e.tiles,n,r,o),c=await ee(i,a),l={points:[],ringStart:[],polygonStart:[],feature:[]},u=[];if(!c||J.has(s))return;let d=new Set,f=2**n;return e.layers.forEach((p)=>{let _=c.get(p["source-layer"]??"");if(!_)return;_.features.forEach((y)=>{if(y.type!==3||d.has(y)||!Q(p.filter,Z(y,n)))return;d.add(y);let A=u.length;u.push(y.properties),y.geometry.forEach((m)=>{let M=0;for(let b=0;b+1<m.length;b+=2){let w=(b+2)%m.length;M+=(m[b]??0)*(m[w+1]??0)-(m[w]??0)*(m[b+1]??0)}if(M===0)return;if(M>0||l.polygonStart.length===0||l.feature.at(-1)!==A)l.polygonStart.push(l.ringStart.length),l.feature.push(A);l.ringStart.push(l.points.length/2);for(let b=0;b+1<m.length;b+=2)l.points.push((r+(m[b]??0)/_.extent)/f,(o+(m[b+1]??0)/_.extent)/f)})})}),l.ringStart.push(l.points.length/2),l.polygonStart.push(l.ringStart.length-1),{arrays:{points:Float64Array.from(l.points),ringStart:Uint32Array.from(l.ringStart),polygonStart:Uint32Array.from(l.polygonStart),feature:Uint32Array.from(l.feature)},properties:u}},Qr=new Set(["theatre","museum","place_of_worship","castle","monument","attraction","town_hall"]),eo=(e)=>(e?.get("poi")?.features??[]).filter((t)=>t.type===1&&Qr.has(String(t.properties.class))).flatMap((t)=>t.geometry.flat()),At=(e)=>{let[t,n,r,o]=[1/0,1/0,-1/0,-1/0];for(let s=0;s+1<e.length;s+=2)[t,n]=[Math.min(t,e[s]??0),Math.min(n,e[s+1]??0)],[r,o]=[Math.max(r,e[s]??0),Math.max(o,e[s+1]??0)];return[t,n,r,o]},to=(e,t)=>{if(t.length===0)return!1;let[n,r,o,s]=At(e[0]??[]);for(let a=0;a+1<t.length;a+=2){let[i,c]=[t[a]??0,t[a+1]??0];if(i>=n&&i<=o&&c>=r&&c<=s&&ge(e,i,c))return!0}return!1},En=(e)=>{let t=e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1],n=Math.max(1,e.length/2-(t?1:0)),[r,o]=[0,0];for(let s=0;s<n;s+=1)[r,o]=[r+(e[s*2]??0),o+(e[s*2+1]??0)];return[r/n,o/n]},no=(e,t)=>{let n=e.filter((s)=>s.type===3),r=n.filter((s)=>to(s.geometry,t)),o=new Set(r);return r.forEach((s)=>{let[a,i,c,l]=At(s.geometry[0]??[]),u=En(s.geometry[0]??[]);n.forEach((d)=>{if(o.has(d))return;let[f,p,_,y]=At(d.geometry[0]??[]);if(_<a||f>c||y<i||p>l)return;if(ge(s.geometry,...En(d.geometry[0]??[]))||ge(d.geometry,...u))o.add(d)})}),o},ro={line:(e)=>e!==1,circle:(e)=>e===1,fill:(e)=>e===3,extrusion:(e)=>e===3},oo=(e,t)=>{let n=xn(e,t);return[n===void 0?0:gn(n)??0,_n(e)]},so=24,io=(e,t,n,r)=>{if(!at(e.filter))return Q(e.filter,Z(t,n))?[0,0]:void 0;let o,s=0;for(let a=n-1;a<=r;a+=1)if(Q(e.filter,Z(t,a)))o??=a,s=a+1;else if(o!==void 0)break;return o===void 0?void 0:[o<=n-1?0:o,s>r?99:s]},ao=(e,t)=>{let n=e.slice(),r=[[0,0,(o)=>o>=0],[0,t,(o)=>o<=t],[1,0,(o)=>o>=0],[1,t,(o)=>o<=t]];for(let[o,s,a]of r){let i=[],c=n.length/2;for(let l=0;l<c;l+=1){let[u,d]=[n[l*2]??0,n[l*2+1]??0],f=(l+1)%c,[p,_]=[n[f*2]??0,n[f*2+1]??0],[y,A]=o===0?[u,p]:[d,_];if(a(y))i.push(u,d);if(a(y)!==a(A)){let m=(s-y)/(A-y);i.push(o===0?s:u+(p-u)*m,o===0?d+(_-d)*m:s)}}if(n=i,n.length===0)break}return n},co=0.00048828125,lo=(e,t)=>{let n=e.length/2;if(n<=2)return[...e];let r=new Uint8Array(n),o=[[0,n-1]],s=t*t;r[0]=1,r[n-1]=1;while(o.length>0){let[a,i]=o.pop()??[0,0],[c,l,u,d]=[e[a*2]??0,e[a*2+1]??0,e[i*2]??0,e[i*2+1]??0],[f,p]=[u-c,d-l],_=f*f+p*p,[y,A]=[-1,s];for(let m=a+1;m<i;m+=1){let[M,b]=[(e[m*2]??0)-c,(e[m*2+1]??0)-l],w=_>0?Math.max(0,Math.min(1,(M*f+b*p)/_)):0,T=(M-w*f)**2+(b-w*p)**2;if(T>A)[y,A]=[m,T]}if(y>=0)r[y]=1,o.push([a,y],[y,i])}return e.filter((a,i)=>r[i>>1]===1)},uo=(e,t)=>{let n=[],r=[],o=()=>{if(r.length>=4)n.push(r);r=[]};for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],[u,d]=[c-a,l-i],[f,p]=[0,1];for(let[_,y]of[[-u,a],[u,t-a],[-d,i],[d,t-i]])if(_===0){if(y<0)p=-1}else if(_<0)f=Math.max(f,y/_);else p=Math.min(p,y/_);if(f>p){o();continue}if(r.length===0||f>0)o(),r.push(a+u*f,i+d*f);if(r.push(a+u*p,i+d*p),p<1)o()}return o(),n},fo=(e,t)=>e>=t?[e-0.5,e+1,e+3,e+6]:[e-0.5,e-0.16666666666666666,e+0.16666666666666666,e+0.5],mo=(e,t,n,r,o)=>{let s=2**n,[a,i]=[r*t,o*t],c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];e.forEach((p)=>{for(let _=0;_+1<p.length;_+=2){let[y,A]=[(p[_]??0)*s-a,(p[_+1]??0)*s-i];c[0]=Math.min(c[0]??y,y),c[1]=Math.min(c[1]??A,A),c[2]=Math.max(c[2]??y,y),c[3]=Math.max(c[3]??A,A)}});let[l=0,u=0,d=0,f=0]=c;if(d<=0||f<=0||l>=t||u>=t)return;return e.map((p)=>p.map((_,y)=>_*s-(y%2===0?a:i)))},po=(e)=>{let t=[],n=[],r=[],o=[];return{add:(i,c,l,u,d,f=!1)=>{let p=(b,w,T)=>L(c,"paint",b,{...l,zoom:T},w),_=`${c.type}-opacity`,y=me(c.paint?.[_]),A=(b)=>{let[w,T,v,g]=ce(p(f?"fill-outline-color":`${c.type}-color`,"#000",b))??[0,0,0,1];return[w,T,v,g*(y?Number(p(_,1,b)):1)]},m=Array(wt).fill(0),M=e[3]-e[0]>1.5?e[1]:e[3];if(m.splice(j.color,8,...A(e[0]),...A(M)),m.splice(j.range,2,...d),!f&&["fill","background","line","fill-extrusion"].includes(c.type)){let b=p(`${c.type}-pattern`,"",(e[0]+M)/2);if(typeof b==="string"&&b){let w=n.indexOf(b);m[c.type==="fill"||c.type==="background"?j.fillPattern:j.linePattern]=(w>=0?w:n.push(b)-1)+1}}if(c.type==="circle"){let b=(e[0]+M)/2,[w,T,v,g]=ce(p("circle-stroke-color","#000",b))??[0,0,0,1];m.splice(j.color,8,...A(b),w,T,v,g*Number(p("circle-stroke-opacity",1,b)))}return e.forEach((b,w)=>{if(m[j.size+w]=b,f){m[j.size+4+w]=1;return}if(c.type==="circle"){m[j.size+4+w]=Math.max(0,Number(p("circle-radius",5,b))||0),m[j.size2+w]=b,m[j.size2+4+w]=Math.max(0,Number(p("circle-stroke-width",0,b))||0);return}if(c.type==="fill-extrusion"){m[j.size+4+w]=Math.max(0,Number(p("fill-extrusion-height",0,b))||0),m[j.size2+w]=b,m[j.size2+4+w]=Math.max(0,Number(p("fill-extrusion-base",0,b))||0);return}if(c.type!=="line")return;if(w===0)m[j.blur]=Math.max(0,Number(p("line-blur",0,(e[0]+M)/2))||0);let T=Number(p("line-width",1,b)),v=Number(p("line-gap-width",0,b));m[j.size+4+w]=Math.max(0,v>0?v+2*T:T),m[j.size2+w]=b,m[j.size2+4+w]=Number(p("line-offset",0,b))||0}),t.push(...m),r.push(u),o.push(i),r.length-1},landmark:(i)=>{t[i*wt+j.landmark]=1},styles:t,patterns:n,properties:r,sublayer:o}},bo=(e,t,n)=>{let r={points:[],ringStart:[],polygonStart:[],feature:[],roofs:[],roofHeights:[],roofOutlines:[],roofOutlineStart:[]},o={points:[],start:[],feature:[]},s={points:[],feature:[]},a={fill:[],line:[],circle:[]},i=(u,d,f)=>[(e+u/f)/n,(t+d/f)/n],c=(u,d,f)=>{r.polygonStart.push(r.ringStart.length),r.feature.push(u),r.roofs.push(d),r.roofHeights.push(f),r.roofOutlineStart.push(r.roofOutlines.length/2)},l=()=>{a.fill.push(r.polygonStart.length),a.line.push(o.start.length),a.circle.push(s.feature.length)};return{sublayer:l,background:(u)=>{c(u,0,Number.NaN),r.ringStart.push(r.points.length/2),r.points.push(e/n,t/n,(e+1)/n,t/n,(e+1)/n,(t+1)/n,e/n,(t+1)/n)},circles:(u,d,f)=>{u.forEach((p)=>{for(let _=0;_+1<p.length;_+=2){let[y=0,A=0]=[p[_],p[_+1]];if(y<0||A<0||y>=f||A>=f)continue;s.points.push(...i(y,A,f)),s.feature.push(d)}})},lines:(u,d,f,p)=>{u.forEach((_)=>{let y=d&&_.length>=2?[..._,_[0]??0,_[1]??0]:_;uo(y,p).forEach((A)=>{let m=lo(A,p*co);o.start.push(o.points.length/2),o.feature.push(f);for(let M=0;M+1<m.length;M+=2)o.points.push(...i(m[M]??0,m[M+1]??0,p))})})},polygons:(u,d,[f,p],_)=>{let y=!1;u.forEach((A)=>{let m=0;for(let b=0;b+1<A.length;b+=2){let w=(b+2)%A.length;m+=(A[b]??0)*(A[w+1]??0)-(A[w]??0)*(A[b+1]??0)}if(m===0)return;if(m<0&&!y)return;let M=ao(A,_);if(m>0)y=M.length>=6;if(M.length<6)return;if(m>0){if(c(d,f,p),f>1&&A.some((b)=>b<0||b>_))for(let b=0;b+1<A.length;b+=2)r.roofOutlines.push(...i(A[b]??0,A[b+1]??0,_))}r.ringStart.push(r.points.length/2);for(let b=0;b+1<M.length;b+=2)r.points.push(...i(M[b]??0,M[b+1]??0,_))})},done:()=>(l(),r.ringStart.push(r.points.length/2),r.polygonStart.push(r.ringStart.length-1),r.roofOutlineStart.push(r.roofOutlines.length/2),o.start.push(o.points.length/2),{fills:{points:Float64Array.from(r.points),ringStart:Uint32Array.from(r.ringStart),polygonStart:Uint32Array.from(r.polygonStart),feature:Uint32Array.from(r.feature),fillStart:Uint32Array.from(a.fill),roofs:Uint8Array.from(r.roofs),roofHeights:Float32Array.from(r.roofHeights),roofOutlines:Float64Array.from(r.roofOutlines),roofOutlineStart:Uint32Array.from(r.roofOutlineStart),roofMetres:rt((t+0.5)/n)},lines:{points:Float64Array.from(o.points),start:Uint32Array.from(o.start),feature:Uint32Array.from(o.feature),lineStart:Uint32Array.from(a.line)},circles:{points:Float64Array.from(s.points),feature:Uint32Array.from(s.feature),circleStart:Uint32Array.from(a.circle)},tile:Float64Array.of(e/n,t/n,(e+1)/n,(t+1)/n)})}},In=async(e,t,n)=>{let{z:r,x:o,y:s,id:a,priority:i,deepest:c=e.maxzoom,roofs:l="data"}=t,u=Math.max(0,r-e.maxzoom),[d,f,p]=[r-u,Math.floor(o/2**u),Math.floor(s/2**u)],[_,y]=[o-f*2**u,s-p*2**u],A=await ee(K(e.tiles,d,f,p),i);if(J.has(a))return;let m=eo(A),M=new Map,b=(v)=>{let g=M.get(v)??(m.length>0?no(v,m):new Set);return M.set(v,g),g},w=po(fo(r,Math.max(c,e.maxzoom))),T=r>=Math.max(c,e.maxzoom)?so:r;return e.layers.forEach((v,g)=>{n?.sublayer();let x=je(v),h=v.type==="fill"&&v.paint?.["fill-outline-color"]!==void 0&&v.paint?.["fill-antialias"]!==!1;if(!x)return;if(v.type==="background"){let S=w.add(g,v,{zoom:r,properties:{},type:"Unknown"},{},[0,0]);n?.background(S);return}let k=A?.get(v["source-layer"]??"");k?.features.forEach((S)=>{if(!ro[x](S.type))return;let R=Z(S,r),N=io(v,S,r,T);if(!N)return;let W=u>0?mo(S.geometry,k.extent,u,_,y):S.geometry;if(!W)return;let B=w.add(g,v,R,S.properties,N),P=h?w.add(g,v,R,S.properties,N,!0):-1;if(x==="extrusion"&&b(k.features).has(S))w.landmark(B);if(!n)return;if(x==="circle"){n.circles(W,B,k.extent);return}if(x==="line"){n.lines(W,S.type===3,B,k.extent);return}if(P>=0)n.lines(W,!0,P,k.extent);let U=x==="extrusion"?oo(S.properties,l):[0,Number.NaN];n.polygons(W,B,U,k.extent)})}),w},Fn=async(e,t)=>{let n=await In(e,t);return n&&{styles:Float32Array.from(n.styles),patterns:n.patterns}},Nn=async(e,t)=>{let n=bo(t.x,t.y,2**t.z),r=await In(e,t,n);if(!r)return;return{...n.done(),styles:Float32Array.from(r.styles),patterns:r.patterns,properties:r.properties,sublayer:Uint16Array.from(r.sublayer)}},we={},On=()=>{if(!we.url)return Promise.resolve(!1);let e=we.ready??Tn({module_or_path:we.url}).then(()=>!0,(t)=>(console.warn("isard: the tessellation module failed to load, the main thread does its work",t),!1));return we.ready=e,e},Pn=(e,t,n)=>{let{fills:r,lines:o}=e;try{let s=Sn(r.points,r.ringStart,r.polygonStart,r.feature,r.fillStart,o.points,o.start,o.feature,o.lineStart,t,r.roofs??new Uint8Array,r.roofHeights??new Float32Array,r.roofOutlines??new Float64Array,r.roofOutlineStart??new Uint32Array,r.roofMetres??0,n,e.tile??new Float64Array),a={vertices:s.vertices(),indices:s.indices(),fillRanges:s.fillRanges(),prism:s.prism(),pieces:s.pieces(),lineTable:s.lineTable(),lineRanges:s.lineRanges(),blocks:s.blocks(),blockIndices:s.blockIndices(),blockRanges:s.blockRanges(),bounds:s.bounds()};return s.free(),a}catch(s){console.warn("isard: the tessellation module failed, the main thread does its work",s),we.ready=Promise.resolve(!1);return}};var yo={primary:8,secondary:7,tertiary:6,minor:5,service:4},Ln=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxLamps:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||J.has(s))return;let d=_e(n,o),f=new Set,p=[];return e.layers.forEach((_)=>{let y=u.get(_["source-layer"]??"");if(!y)return;let A=y.extent/d;y.features.forEach((m)=>{let M=yo[String(m.properties.class)];if(m.type!==2||M===void 0||f.has(m)||!Q(_.filter,Z(m,n)))return;f.add(m),m.geometry.forEach((b)=>{Ae(b,a*A).forEach((w,T)=>{let[v,g,x]=Ke(w,T,M*A);if(v<0||g<0||v>=y.extent||g>=y.extent)return;let[h,k]=Y(n,r,o,y.extent,v,g),S=se(Math.floor(v),Math.floor(g),Math.floor(w[6]??0),29);p.push(h,k,1,x,S,0)})})})}),Ze(p,i)};var ho=new Set(["butt","round","square"]),go=new Set(["bevel","miter","round"]),wo=(e)=>ho.has(e),xo=(e)=>go.has(e),_o=(e)=>wo(e)?e:"butt",Ao=(e)=>xo(e)?e:"miter",Mo=(e,t)=>{if(e.patterns.has(t))return e.patterns.get(t);let r=(()=>{let o=gt(e,t);if(!o||!(o.icon.width>0)||!(o.icon.height>0))return;let{icon:s}=o,a=new OffscreenCanvas(s.width,s.height);return a.getContext("2d")?.drawImage(o.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),a})();return e.patterns.set(t,r),r},Mt=new Map,So=(e)=>{let t=Mt.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("isard: no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}},ko=(e)=>{let t=Mt.get(e.width)??[];if(Mt.set(e.width,t),t.length<4)t.push(e)},vo=(e,t,n)=>{if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})},Un=async(e,t)=>{let{z:n,x:r,y:o,size:s,id:a,priority:i}=t,c=ln(e,n,r,o),l=await ee(c.url,i);if(J.has(a))return;let{canvas:u,g:d}=So(s);try{return await Ro(e,c,l,u,d,n,r,o,s,a,i)}finally{ko(u)}},Ro=async(e,t,n,r,o,s,a,i,c,l,u)=>{let d=Math.max(0,s-1),f=c/256,p=!1,_=!1;for(let y of e.layers){if(!Le(y,d))continue;let A={zoom:d,properties:{},type:"Unknown"};if(y.type==="background"){let x=L(y,"paint","background-color",A,"#000"),h=Number(L(y,"paint","background-opacity",A,1));if(o.fillStyle=pe(x,h),o.fillRect(0,0,c,c),(ce(x)??[0,0,0,1])[3]*h>=1)_=!0;p=!0;continue}if(y.type==="raster"){let x=y.source===void 0?void 0:e.rasters[y.source];if(!x)continue;let h=xe(s-(x.tileSize>=512?1:0),0,x.maxzoom),k=2**(s-h),S=K(x.tiles,h,Math.floor(a/k),Math.floor(i/k)),R=await cn(S,u);if(J.has(l))return;if(!R)continue;let[N,W]=[R.width/k,R.height/k];o.globalAlpha=Number(L(y,"paint","raster-opacity",A,1)),o.drawImage(R,a%k*N,i%k*W,N,W,0,0,c,c),o.globalAlpha=1,p=!0;continue}let m=n?.get(y["source-layer"]??"");if(!m)continue;let M=c/(m.extent*t.part),[b,w]=[t.ox*m.extent,t.oy*m.extent],T=(x,h)=>{o.beginPath();for(let k of x.geometry){for(let S=0;S+1<k.length;S+=2){let[R,N]=[((k[S]??0)-b)*M,((k[S+1]??0)-w)*M];if(S===0)o.moveTo(R,N);else o.lineTo(R,N)}if(h)o.closePath()}},v=new Map,g=(x,h,k,S)=>{let R=v.get(h),N=R??me(y[x]?.[h]);if(R===void 0)v.set(h,N);return L(y,x,h,N?k:A,S)};for(let x of m.features){let h=Z(x,d);if(!Q(y.filter,h))continue;if(y.type==="fill-extrusion"&&x.type===3)T(x,!0),o.fillStyle=pe(g("paint","fill-extrusion-color",h,"#000"),Number(g("paint","fill-extrusion-opacity",h,1))),o.fill("evenodd"),p=!0;else if(y.type==="fill"&&x.type===3){let k=Number(g("paint","fill-opacity",h,1)),S=g("paint","fill-pattern",h,void 0);T(x,!0);let R=typeof S==="string"?gt(e,S)?.icon:void 0,N=R&&typeof S==="string"&&Mo(e,S);if(R&&N){let W=o.createPattern(N,"repeat");if(W)W.setTransform(new DOMMatrix().scale(f/(R.pixelRatio??1))),o.globalAlpha=k,o.fillStyle=W,o.fill("evenodd"),o.globalAlpha=1}else{o.fillStyle=pe(g("paint","fill-color",h,"#000"),k),o.fill("evenodd");let W=g("paint","fill-outline-color",h,void 0);if(W!==void 0)o.strokeStyle=pe(W,k),o.lineWidth=f,o.setLineDash([]),o.stroke()}p=!0}else if(y.type==="line"&&x.type!==1){let k=Number(g("paint","line-width",h,1));if(k<=0)continue;let S=Number(g("paint","line-gap-width",h,0));o.strokeStyle=pe(g("paint","line-color",h,"#000"),Number(g("paint","line-opacity",h,1))),o.lineWidth=(S>0?S+2*k:k)*f,o.lineCap=_o(g("layout","line-cap",h,"butt")),o.lineJoin=Ao(g("layout","line-join",h,"miter"));let R=g("paint","line-dasharray",h,void 0);o.setLineDash(Array.isArray(R)?R.map((N)=>Number(N)*k*f):[]),T(x,x.type===3),o.stroke(),p=!0}else if(y.type==="circle"&&x.type===1){let k=Number(g("paint","circle-radius",h,5))*f;o.fillStyle=pe(g("paint","circle-color",h,"#000"),Number(g("paint","circle-opacity",h,1)));let S=Number(g("paint","circle-stroke-width",h,0))*f;o.strokeStyle=pe(g("paint","circle-stroke-color",h,"#000"),Number(g("paint","circle-stroke-opacity",h,1))),o.lineWidth=S;for(let R of x.geometry)for(let N=0;N+1<R.length;N+=2)if(o.beginPath(),o.arc(((R[N]??0)-b)*M,((R[N+1]??0)-w)*M,k,0,2*Math.PI),o.fill(),S>0)o.stroke();p=!0}}}if(!p&&!n)return null;return vo(r,o,_)};var Cn=async(e,t)=>{let{z:n,tiles:r,bounds:o,width:s,height:a,iterations:i,module:c,priority:l,id:u}=t,[d,f,p,_]=o,y=[],A=[],m=[],M=2**n;for(let b=0;b+1<r.length;b+=2){let w=r[b]??0,T=(w%M+M)%M,v=(w-T)/M,g=await tt(e,{z:n,x:T,y:r[b+1]??0,id:u,priority:l});if(J.has(u))throw Error("aborted");if(!g)continue;let{points:x,ringStart:h,polygonStart:k}=g.arrays;for(let S=0;S+1<k.length;S++){let[R,N]=[k[S]??0,k[S+1]??0],W=h[R]??0,B=h[N]??0,[P,U,I,F]=[1/0,1/0,-1/0,-1/0];for(let E=W;E<B;E++){let[C,V]=[(x[E*2]??0)+v,x[E*2+1]??0];P=Math.min(P,C),U=Math.min(U,V),I=Math.max(I,C),F=Math.max(F,V)}if(I<d||P>p||F<f||U>_)continue;m.push(A.length);for(let E=R;E<N;E++){A.push(y.length/2);for(let C=h[E]??0;C<(h[E+1]??0);C++)y.push(((x[C*2]??0)+v-d)/(p-d)*s,((x[C*2+1]??0)-f)/(_-f)*a)}}}return A.push(y.length/2),m.push(A.length-1),Zt({points:Float64Array.from(y),ringStart:Uint32Array.from(A),polygonStart:Uint32Array.from(m)},s,a,i,c)};var St=new Map,To={},Wn=Tt(),ue=(e,t=[])=>self.postMessage(e,t),Eo=({fills:e,lines:t,circles:n,styles:r,sublayer:o,mesh:s})=>[e.points,e.ringStart,e.polygonStart,e.feature,e.fillStart,e.roofs,e.roofHeights,e.roofOutlines,e.roofOutlineStart,t.points,t.start,t.feature,t.lineStart,n?.points,n?.feature,n?.circleStart,r,o,s?.vertices,s?.indices,s?.fillRanges,s?.pieces,s?.lineTable,s?.lineRanges,s?.blocks,s?.blockIndices,s?.blockRanges,s?.bounds].flatMap((a)=>a?[a.buffer]:[]),Io={render:async(e,t)=>{let n=await Un(e,t);return n?[{image:n},[n]]:void 0},labels:async(e,t)=>[{labels:await mn(e,t)},[]],polygons:async(e,t)=>{let n=await tt(e,t);if(!n)return;let{points:r,ringStart:o,polygonStart:s,feature:a}=n.arrays;return[{polygons:n},[r.buffer,o.buffer,s.buffer,a.buffer]]},trees:async(e,t)=>{let n=await dn(e,t);return n&&[{trees:n},[n.buffer]]},furniture:async(e,t)=>{let n=await yn(e,t);return n&&[{furniture:n},[n.buffer]]},lamps:async(e,t)=>{let n=await Ln(e,t);return n&&[{lamps:n},[n.buffer]]},street:async(e,t)=>{let n=await Cn(e,t);return[{street:n},[n.eastU,n.eastV,n.northU,n.northV].map((r)=>r.buffer)]},vectors:async(e,t)=>{if(t.styles){let a=await Fn(e,t);return a&&[a,[a.styles.buffer]]}let n=await Nn(e,t);if(!n)return;let r=Uint8Array.from(e.layers,(a)=>je(a)==="extrusion"?1:0),o=await On()?Pn(n,r,t.prism===!0):void 0,s=o?{...n,mesh:o}:n;return[{vectors:s},Eo(s)]}},Fo=(e,t,n)=>Io[t](e,n);self.onmessage=async({data:e})=>{if(e.type==="headers"){Rt(e.rules);return}if(e.type==="tess"){we.url=e.url;return}if(e.type==="init"){if(e.workers!==void 0)Oe.capacity=an(e.workers);Pe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){Pe.get(e.key)?.sprites.forEach((t)=>{t.image.close()}),Pe.delete(e.key);return}if(e.type==="abort"){if(Ye.has(e.id))J.add(e.id);St.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"||e.type==="grids"){await Oo(e);return}Ye.add(e.id);try{let t=Pe.get(e.key);if(!t)throw Error(`isard: no renderer ${e.key}`);let n=await Fo(t,e.type,e);if(n)ue({id:e.id,...n[0]},n[1]);else ue({id:e.id,missing:!0})}catch(t){ue({id:e.id,error:String(t)})}finally{Ye.delete(e.id),J.delete(e.id)}};var No=async(e,t)=>(await kt(e,oe(e,{signal:t}))).arrayBuffer(),Oo=async(e)=>{let t=new AbortController;St.set(e.id,t);try{if(e.type==="grids"){let{module:n,url:r,bytes:o}=e,s=o??(r?await No(r,t.signal):new ArrayBuffer(0)),{grids:a,values:i}=await Xt(new Uint8Array(s),n);ue({id:e.id,grids:a,values:i},i.map((c)=>c.buffer))}else if(e.type==="heights"){let n=await Nt(e.url,e.encoding,e.floor,t.signal,To);if(n)ue({id:e.id,heights:n},[n.buffer]);else ue({id:e.id,missing:!0})}else{Wn.cache.capacity=e.cached;let n=await Wn.draw(e.job,t.signal);if(n)ue({id:e.id,image:n},[n]);else ue({id:e.id,missing:!0})}}catch(n){ue({id:e.id,error:String(n)})}finally{St.delete(e.id)}};
|
|
1
|
+
var ie=(e,t)=>Error(`isard: ${String(e)}: HTTP ${t}`),kt=async(e,t)=>{let n=await fetch(e,t);if(!n.ok)throw ie(e,n.status);return n};class le{capacity;evict;entries=new Map;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.entries.delete(e),this.entries.set(e,t);for(let[n,r]of this.entries){if(this.entries.size<=this.capacity)break;this.entries.delete(n),this.evict?.(r,n)}}delete(e){return this.entries.delete(e)}values(){return this.entries.values()}clear(){this.entries.clear()}}var vt=[];var Rt=(e)=>{vt=e};var oe=(e,t={})=>{let n=String(e),r=vt.filter(([s])=>n.startsWith(s));if(r.length===0)return t;let o=new Headers(t.headers);return r.forEach(([,s])=>{Object.entries(s).forEach(([a,i])=>{o.set(a,i)})}),{...t,headers:o}};var Hn=96,Jn=(e,t,n,r,o,s)=>{let a=new Uint8ClampedArray(s*s*4),i=s/o,c=o+1;for(let l=0;l<s;l+=1){let u=(l+0.5)/i,p=Math.min(o-1,Math.floor(u)),f=u-p;for(let d=0;d<s;d+=1){let w=(d+0.5)/i,h=Math.min(o-1,Math.floor(w)),A=w-h,m=2*(p*c+h),M=m+2*c,b=(1-A)*(1-f),x=A*(1-f),T=(1-A)*f,E=A*f,_=b*r[m]+x*r[m+2]+T*r[M]+E*r[M+2],g=b*r[m+1]+x*r[m+3]+T*r[M+1]+E*r[M+3],y=_-0.5,S=g-0.5;if(!(y>-1&&S>-1&&y<t&&S<n))continue;let k=Math.floor(y),v=Math.floor(S),R=y-k,U=S-v,B=0,P=0,L=0,I=0;for(let N=0;N<4;N+=1){let W=k+(N&1),V=v+(N>>1);if(W<0||V<0||W>=t||V>=n)continue;let J=4*(V*t+W),z=(N&1?R:1-R)*(N>>1?U:1-U)*e[J+3];B+=z*e[J],P+=z*e[J+1],L+=z*e[J+2],I+=z}if(I<=0)continue;let F=4*(l*s+d);a[F]=B/I,a[F+1]=P/I,a[F+2]=L/I,a[F+3]=I}}return a},Tt=(e=Hn)=>{let t=new Map,n=new Set,r=(l)=>{n.delete(l),l.then((u)=>u?.close(),()=>{return})},o=(l)=>{if(t.has(l))n.add(l);else r(l)},s=new le(e,o),a=(l)=>{let u=(t.get(l)??1)-1;if(u>0)t.set(l,u);else if(t.delete(l),n.has(l))r(l)},i=(l)=>{let u=()=>{let f=(async()=>{let d=await fetch(l,oe(l));if(d.status===404||d.status===204||d.status===410)return null;if(!d.ok)throw ie(l,d.status);return createImageBitmap(await d.blob())})();return f.catch(()=>s.delete(l)),s.set(l,f),f},p=s.get(l)??u();return t.set(p,(t.get(p)??0)+1),p};return{draw:async(l,u)=>{let p=l.sources.map((f)=>[f,i(f.url)]);try{let f=await Promise.all(p.map(async([m,M])=>[m,await M]));if(u.throwIfAborted(),!f.some(([,m])=>m))return null;let w=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!w)throw Error("isard: no 2D canvas to reproject the tiles");f.forEach(([m,M])=>{if(M)w.drawImage(M,m.x,m.y,m.w,m.h)});let h=w.getImageData(0,0,l.width,l.height).data,A=Jn(h,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(A,l.size,l.size),{premultiplyAlpha:"none"})}finally{p.forEach(([,f])=>{a(f)})}},cache:s,close:()=>{[...s.values()].forEach(o),s.clear()}}};var xe=(e,t,n)=>Math.max(t,Math.min(n,e));var Ho=Math.PI/180,Et=40075016.686,Jo=Et/360;var It=(e)=>e*360-180,Ft=(e)=>Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI;var rt=(e)=>Et*Math.cos(Math.atan(Math.sinh(Math.PI*(1-2*e)))),_e=(e,t)=>rt((t+0.5)/2**e)/2**e,K=(e,t,n,r)=>e.replaceAll("{z}",String(t)).replaceAll("{x}",String(n)).replaceAll("{y}",String(r));var fe=256,jn=(e,t,n=Number.NEGATIVE_INFINITY)=>{let r=e.length>>2,o=new Float32Array(r);if(t==="terrarium")for(let s=0,a=0;s<r;s+=1,a+=4){let i=e[a]*256+e[a+1]+e[a+2]/256-32768;o[s]=i>n?i:n}else for(let s=0,a=0;s<r;s+=1,a+=4){let i=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;o[s]=i>n?i:n}return o},Nt=async(e,t,n,r,o)=>{let s=await fetch(e,oe(e,{signal:r}));if(s.status===404||s.status===204||s.status===410)return null;if(!s.ok)throw ie(e,s.status);let a=await createImageBitmap(await s.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{o.canvas??=new OffscreenCanvas(fe,fe);let i=o.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("isard: no 2D context");return i.imageSmoothingEnabled=!1,i.clearRect(0,0,fe,fe),i.drawImage(a,0,0,fe,fe),jn(i.getImageData(0,0,fe,fe).data,t,n)}finally{a.close()}};var qn="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",ot,$n=(e)=>{if(!ot){let t=qn.split(" ");ot=new Map(Array.from({length:Math.floor(t.length/2)},(n,r)=>[t[2*r]??"",t[2*r+1]??""]))}return ot.get(e)},ze=(e)=>Number.isFinite(e)?xe(e,0,1):0,Ot=(e)=>{if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((r)=>r+r).join(""):e,n=(r)=>Number.parseInt(t.slice(r,r+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]},Yn=(e)=>{if(e===void 0)return 1;return ze(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))},Gn=(e,t,n)=>{let r=n<0.5?n*(1+t):n+t-n*t,o=2*n-r,s=(a)=>{let i=(a%1+1)%1;if(i<0.16666666666666666)return o+(r-o)*6*i;if(i<0.5)return r;if(i<0.6666666666666666)return o+(r-o)*(0.6666666666666666-i)*6;return o};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]},Pt=(e)=>{if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Ot(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=$n(t);if(n)return Ot(n);let r=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!r?.[1]||r[2]===void 0)return;let o=r[2].split(/[\s,/]+/).filter(Boolean);if(o.length<3||o.slice(0,3).some((u)=>Number.isNaN(Number.parseFloat(u))))return;let s=Yn(o[3]);if(r[1].startsWith("rgb")){let u=(p)=>ze(p.endsWith("%")?Number.parseFloat(p)/100:Number.parseFloat(p)/255);return[u(o[0]??""),u(o[1]??""),u(o[2]??""),s]}let a=Number.parseFloat(o[0]??"")/360,[i,c,l]=Gn(a,ze(Number.parseFloat(o[1]??"")/100),ze(Number.parseFloat(o[2]??"")/100));return[i,c,l,s]};var be=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);var Kn=["Unknown","Point","LineString","Polygon"],Z=(e,t)=>({zoom:t,properties:e.properties,type:Kn[e.type]??"Unknown"}),ce=(e)=>Pt(e),Je=([e,t,n,r])=>`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${r})`,Wt=(e,t,n,r=1)=>{let o=n-t;if(o===0)return 0;let s=e-t;return r===1?s/o:(r**s-1)/(r**o-1)},it=(e,t,n)=>{if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let r=ce(e),o=ce(t);if(r&&o){let s=(a)=>r[a]+(o[a]-r[a])*n;return Je([s(0),s(1),s(2),s(3)])}if(Array.isArray(e)&&Array.isArray(t))return e.map((s,a)=>it(s,t[a],n));return n<0.5?e:t},Dt=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops),Zn=(e,t)=>{let n=e.property===void 0?t.zoom:t.properties[e.property],r=e.stops,o=e.type??(e.property===void 0||typeof r[0]?.[0]==="number"?"exponential":"categorical");if(o==="identity")return n??e.default;if(o==="categorical")return r.find(([u])=>u===n)?.[1]??e.default;if(typeof n!=="number"||!r.length)return e.default??r[0]?.[1];let s=([u])=>{if(Array.isArray(u))return Number.NaN;return be(u)?Number(u.zoom):Number(u)},a=r[0];if(!a)return e.default;if(n<=s(a))return a[1];let i=r.findIndex((u,p)=>p>0&&Boolean(r[p-1])&&Boolean(u)&&n<s(u)),[c,l]=[r[i-1],r[i]];if(i<0||!c||!l)return r.at(-1)?.[1];if(o==="interval")return c[1];return it(c[1],l[1],Wt(n,s(c),s(l),e.base??1))},st=(e)=>e,Lt={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t},Bt=(e,t,n)=>{let r=(a)=>typeof a==="object"&&a!==null?String(a):a,[o,s]=[r(t),r(n)];return typeof o==="string"&&typeof s==="string"?Lt[e](o,s):Lt[e](Number(o),Number(s))},He=(e,t)=>{if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0},Xn=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]),ve=(e)=>Array.isArray(e)&&typeof e[0]==="string"&&Xn.has(e[0]),Ut=new Set,ke=(e)=>e===void 0||e===null?"":String(e),ae=(e,t)=>{if(Dt(e))return Zn(e,t);if(!Array.isArray(e))return e;let[n,...r]=e;if(typeof n!=="string")return e;let o=(i)=>ae(r[i]??null,t),s=(i)=>Number(o(i)),a=()=>r.map((i,c)=>s(c));switch(n){case"literal":return r[0];case"zoom":return t.zoom;case"get":return He(t,o(0));case"has":return He(t,o(0))!==void 0;case"!has":return He(t,o(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return r.map((i,c)=>ke(o(c))).join("");case"format":return r.map((i,c)=>i!==null&&typeof i==="object"&&!Array.isArray(i)?"":ke(o(c))).join("");case"image":return o(0);case"number-format":{let i=be(r[1])?r[1]:{},c=(u)=>{let p=i[u];return typeof p==="number"?p:void 0},l=s(0);if(!Number.isFinite(l))return"";return l.toLocaleString(typeof i.locale==="string"?i.locale:void 0,{minimumFractionDigits:c("min-fraction-digits"),maximumFractionDigits:c("max-fraction-digits")})}case"to-number":{for(let i=0;i<r.length;i+=1){let c=o(i),l=typeof c==="string"&&c.trim()===""?Number.NaN:Number(c);if(c!==null&&c!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return ke(o(0));case"to-boolean":{let i=o(0);return!(i===""||i===0||i===!1||i===null||i===void 0||Number.isNaN(i))}case"to-color":case"number":case"string":case"boolean":{let i={"to-color":(c)=>ce(c)!==void 0,number:(c)=>typeof c==="number",string:(c)=>typeof c==="string",boolean:(c)=>typeof c==="boolean"};for(let c=0;c<r.length;c+=1){let l=o(c);if(i[n]?.(l))return l}return r.length?o(r.length-1):null}case"typeof":{let i=o(0);if(i===null||i===void 0)return"null";return Array.isArray(i)?"array":typeof i}case"length":{let i=o(0);return typeof i==="string"||Array.isArray(i)?i.length:0}case"at":{let i=o(1);return Array.isArray(i)?i[s(0)]??null:null}case"upcase":return ke(o(0)).toUpperCase();case"downcase":return ke(o(0)).toLowerCase();case"coalesce":for(let i=0;i<r.length;i+=1){let c=o(i);if(c!==void 0&&c!==null)return c}return null;case"!":return!o(0);case"all":return r.every((i,c)=>Boolean(o(c)));case"any":return r.some((i,c)=>Boolean(o(c)));case"==":return o(0)===o(1);case"!=":return o(0)!==o(1);case"<":case"<=":case">":case">=":return Bt(n,o(0),o(1));case"in":{let i=o(1),c=o(0);if(typeof i==="string")return i.includes(String(c));return Array.isArray(i)&&i.includes(c)}case"case":{let i=r.findIndex((c,l)=>l%2===0&&l+1<r.length&&Boolean(o(l)));return i<0?o(r.length-1):o(i+1)}case"match":{let i=o(0),c=r.findIndex((l,u)=>u%2===1&&u+1<r.length&&(Array.isArray(l)?st(l).includes(i):l===i));return c<0?o(r.length-1):o(c+1)}case"step":{let i=s(0),c=o(1);for(let l=2;l+1<r.length;l+=2)if(i>=Number(r[l]))c=o(l+1);else break;return c}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let i=r[0],c=s(1),l=Array.isArray(i)&&i[0]==="exponential"?Number(i[1]):1,u=Array.from({length:Math.floor((r.length-2)/2)},(h,A)=>[Number(r[2+2*A]),r[3+2*A]??null]),p=u[0];if(!p)return null;if(c<=p[0])return ae(p[1],t);let f=u.findIndex((h,A)=>A>0&&c<h[0]),[d,w]=[u[f-1],u[f]];if(f<0||!d||!w)return ae(u.at(-1)?.[1]??null,t);return it(ae(d[1],t),ae(w[1],t),Wt(c,d[0],w[0],l))}case"rgb":case"rgba":return Je([s(0)/255,s(1)/255,s(2)/255,r.length>3?s(3):1]);case"+":return a().reduce((i,c)=>i+c,0);case"*":return a().reduce((i,c)=>i*c,1);case"-":return r.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Ut.has(n))Ut.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}},Qn=new Set(["==","!=","<","<=",">",">="]),je=(e)=>{if(e.type==="line")return"line";if(e.type==="fill-extrusion")return"extrusion";if(e.type==="circle")return"circle";return e.type==="fill"||e.type==="background"?"fill":void 0},er=(e)=>{let[t,n,...r]=e;if(typeof t!=="string"||typeof n!=="string"||r.some(Array.isArray))return!1;if(Qn.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"},tr=(e,t)=>{let[n,r,...o]=e,s=He(t,r);switch(n){case"==":return s===o[0];case"!=":return s!==o[0];case"<":case"<=":case">":case">=":return Bt(n,s,o[0]);case"in":return st(o).includes(s);case"!in":return!st(o).includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}},Ct=new WeakMap,Vt=(e)=>{if(!Array.isArray(e))return()=>Boolean(e);let t=Ct.get(e);if(t)return t;let r=(()=>{let o=e[0];if(o==="all"||o==="any"||o==="none"){let s=e.slice(1).map(Vt);if(o==="all")return(a)=>s.every((i)=>i(a));if(o==="any")return(a)=>s.some((i)=>i(a));return(a)=>!s.some((i)=>i(a))}if(er(e))return(s)=>tr(e,s);return(s)=>Boolean(ae(e,s))})();return Ct.set(e,r),r},Q=(e,t)=>{if(e===void 0||e===null)return!0;return Vt(e)(t)},at=(e)=>Array.isArray(e)&&(e[0]==="zoom"||e.some(at)),nr=new Set(["get","has","!has","geometry-type","properties","id"]),me=(e)=>{if(e!==void 0&&Dt(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(nr.has(e[0]))return!0;return e.some((t)=>me(t))},ct=(e,t)=>{if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(r,o)=>{let s=t.properties[o];return s===void 0?"":String(s)});let n=ae(e,t);if(Array.isArray(n))return n.filter((r)=>typeof r==="string").join("");return n===void 0||n===null?"":String(n)},zt=(e)=>/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`,lt=(e)=>{let t=new Set,n=(i)=>i.filter((c,l)=>l>=3&&l%2===1).map(Number),r=(i)=>{if(!Array.isArray(i))return;let c=(l)=>Array.isArray(l)&&l[0]==="zoom";if((i[0]==="interpolate"||i[0]==="interpolate-hcl"||i[0]==="interpolate-lab")&&c(i[2]))n(i).forEach((l)=>{t.add(l)});else if(i[0]==="step"&&c(i[1]))n(i).forEach((l)=>{t.add(l),t.add(l-0.01)});i.forEach(r)};r(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[s,a]=[Math.min(...o),Math.max(...o)];return o.push(...Array.from({length:Math.floor(a)-Math.ceil(s)+1},(i,c)=>Math.ceil(s)+c)),[...new Set(o)].sort((i,c)=>i-c).map((i)=>[i,Number(ae(e,{zoom:i,properties:{},type:"Unknown"}))])};class Fe{static __wrap(e){let t=Object.create(Fe.prototype);return t.__wbg_ptr=e,Ht.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ht.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_gridset_free(e,0)}count(){return D.gridset_count(this.__wbg_ptr)>>>0}meta(e){let t,n;try{let r=D.gridset_meta(this.__wbg_ptr,e);return t=r[0],n=r[1],ft(r[0],r[1])}finally{D.__wbindgen_free(t,n,1)}}values(e){return D.gridset_values(this.__wbg_ptr,e)}}if(Symbol.dispose)Fe.prototype[Symbol.dispose]=Fe.prototype.free;class Ne{static __wrap(e){let t=Object.create(Ne.prototype);return t.__wbg_ptr=e,Jt.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Jt.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_streetflow_free(e,0)}eastU(){return D.streetflow_eastU(this.__wbg_ptr)}eastV(){return D.streetflow_eastV(this.__wbg_ptr)}northU(){return D.streetflow_northU(this.__wbg_ptr)}northV(){return D.streetflow_northV(this.__wbg_ptr)}}if(Symbol.dispose)Ne.prototype[Symbol.dispose]=Ne.prototype.free;function qt(e){let t=cr(e,D.__wbindgen_malloc),n=ye,r=D.readGrids(t,n);if(r[2])throw ur(r[1]);return Fe.__wrap(r[0])}function $t(e,t,n,r,o,s){let a=lr(e,D.__wbindgen_malloc),i=ye,c=jt(t,D.__wbindgen_malloc),l=ye,u=jt(n,D.__wbindgen_malloc),p=ye,f=D.streetFlow(a,i,c,l,u,p,r,o,s);return Ne.__wrap(f)}function rr(){return{__proto__:null,"./isard_grid_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(ft(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(or(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return ft(t,n)},__wbindgen_init_externref_table:function(){let t=D.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_gridset_free(e,1)),Jt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_streetflow_free(e,1));function or(e,t){return e=e>>>0,sr().subarray(e/4,e/4+t)}var Re=null;function sr(){if(Re===null||Re.byteLength===0)Re=new Float32Array(D.memory.buffer);return Re}var Te=null;function ir(){if(Te===null||Te.byteLength===0)Te=new Float64Array(D.memory.buffer);return Te}function ft(e,t){return mr(e>>>0,t)}var Ee=null;function ar(){if(Ee===null||Ee.byteLength===0)Ee=new Uint32Array(D.memory.buffer);return Ee}var Ie=null;function Yt(){if(Ie===null||Ie.byteLength===0)Ie=new Uint8Array(D.memory.buffer);return Ie}function jt(e,t){let n=t(e.length*4,4)>>>0;return ar().set(e,n/4),ye=e.length,n}function cr(e,t){let n=t(e.length*1,1)>>>0;return Yt().set(e,n/1),ye=e.length,n}function lr(e,t){let n=t(e.length*8,8)>>>0;return ir().set(e,n/8),ye=e.length,n}function ur(e){let t=D.__wbindgen_externrefs.get(e);return D.__externref_table_dealloc(e),t}var qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qe.decode();var fr=2146435072,ut=0;function mr(e,t){if(ut+=t,ut>=fr)qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qe.decode(),ut=t;return qe.decode(Yt().subarray(e,e+t))}var ye=0,pr,dr,D;function br(e,t){return dr=e,D=e.exports,pr=t,Re=null,Te=null,Ee=null,Ie=null,D.__wbindgen_start(),D}async function yr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Gt(e){if(D!==void 0)return D;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_grid_bg.wasm",import.meta.url);let t=rr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await yr(await e,t);return br(n,r)}var mt={},Kt=async(e)=>{let t=mt.ready??Gt({module_or_path:e});mt.ready=t,await t.catch((n)=>{throw mt.ready=void 0,n})},Zt=async(e,t,n,r,o)=>{await Kt(o);let s=$t(e.points,e.ringStart,e.polygonStart,t,n,r);try{return{eastU:s.eastU(),eastV:s.eastV(),northU:s.northU(),northV:s.northV()}}finally{s.free()}},hr=(e)=>typeof e==="object"&&e!==null&&("name"in e)&&("width"in e)&&("height"in e)&&("bounds"in e)&&Array.isArray(e.bounds),Xt=async(e,t)=>{await Kt(t);let n=qt(e);try{let r=[],o=[];for(let s=0;s<n.count();s++){let a=JSON.parse(n.meta(s));if(!hr(a))throw Error("isard: a grid without its description");r.push(a),o.push(n.values(s))}return{grids:r,values:o}}finally{n.free()}};var he=6,Qt=4;var en=(e)=>e*7919%360,pt=["shelter","bin","postbox","fountain","rack","bench"];class dt{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let r=this.buf[this.pos++]??0,o=r&127;if(n<4)e|=o<<7*n;else if(n===4)e|=(o&15)<<28,t|=o>>4;else t|=o<<7*n-32;if(r<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new dt(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=gr.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var gr=new TextDecoder,wr=(e)=>{let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t},xr=(e)=>{let t=[],n,[r,o]=[0,0];while(e.more){let s=e.varint(),a=s&7,i=s>>3;if(a===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let c=0;c<i&&e.more;c+=1){if(r+=e.sint(),o+=e.sint(),a===1)n=[],t.push(n);n?.push(r,o)}}return t},bt=(e,t)=>{let n=new Map,r=new dt(e);while(r.more){let o=r.varint();if(o>>3!==3){r.skip(o&7);continue}let s=r.sub(),a="",i=4096,c=[],l=[],u=[];while(s.more){let f=s.varint();switch(f>>3){case 1:a=s.string();break;case 2:u.push(s.sub());break;case 3:c.push(s.string());break;case 4:l.push(wr(s.sub()));break;case 5:i=s.varint();break;default:s.skip(f&7)}}if(t&&!t.has(a))continue;let p=[];for(let f of u){let d=1,w={},h=[];while(f.more){let A=f.varint();switch(A>>3){case 2:{let m=f.sub();while(m.more){let M=c[m.varint()],b=l[m.varint()];if(M!==void 0&&b!==void 0)w[M]=b}break}case 3:d=Math.min(3,Math.max(1,f.varint()));break;case 4:h=xr(f.sub());break;default:f.skip(A&7)}}p.push({type:d,properties:w,geometry:h})}n.set(a,{extent:i,features:p})}return n};var _r=127,Ar=16384,Mr=["unknown","mvt","png","jpeg","webp","avif"],Sr=(e)=>(4**e-1)/3,kr=(e,t,n)=>{if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let r=2**e;if(t<0||n<0||t>=r||n>=r)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[o,s]=[t,n],a=0;for(let i=r/2;i>=1;i/=2){let c=(o&i)>0?1:0,l=(s&i)>0?1:0;if(a+=i*i*(3*c^l),l===0){if(c===1)[o,s]=[i-1-o,i-1-s];[o,s]=[s,o]}}return Sr(e)+a};class rn{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}var tn=(e)=>{let t=new rn(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let r=[],o=0;for(let s=0;s<n;s+=1)o+=t.next(),r.push({tileId:o,offset:0,length:0,runLength:1});for(let s of r)s.runLength=t.next();for(let s of r)s.length=t.next();return r.forEach((s,a)=>{let i=t.next(),c=r[a-1];s.offset=i===0&&c?c.offset+c.length:i-1}),r},vr=(e,t)=>{let[n,r]=[0,e.length-1];while(n<=r){let s=n+r>>1,a=e[s];if(!a)break;if(a.tileId===t)return a;if(a.tileId<t)n=s+1;else r=s-1}let o=e[r];if(!o)return;if(o.runLength===0||t-o.tileId<o.runLength)return o;return},Rr=(e)=>{if(e.length<_r||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(o)=>Number(t.getBigUint64(o,!0)),r=(o)=>t.getInt32(o,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Mr[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[r(102),r(106),r(110),r(114)],center:[r(119),r(123),t.getUint8(118)]}},$e=async(e,t)=>{if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())},Tr=67108864;class on{source;head;leaves=new le(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let r=await fetch(this.source,oe(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}}));if(!r.ok)throw ie(this.source,r.status);if(r.status===206)return new Uint8Array(await r.arrayBuffer());if(Number(r.headers.get("Content-Length"))>Tr)throw await r.body?.cancel(),Error(`isard: ${this.source}: the server ignores range requests (HTTP 206 expected)`);let s=r.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=s,s.catch(()=>{this.whole=void 0}),(await s).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,Ar),t=Rr(e),{rootDirectoryOffset:n,rootDirectoryLength:r}=t,o=n+r<=e.length?e.subarray(n,n+r):await this.range(n,r),s=tn(await $e(o,t.internalCompression));return{header:t,root:s}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await $e(t,e.internalCompression)),r=JSON.parse(n);return be(r)?r:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,r=this.leaves.get(n);if(r)return r;let o=this.range(n,t.length).then(async(s)=>tn(await $e(s,e.internalCompression)));return o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o),o}async tile(e,t,n,r){let{header:o,root:s}=await this.load();if(e<o.minZoom||e>o.maxZoom)return;let a=kr(e,t,n),i=s;for(let c=0;c<4;c+=1){let l=vr(i,a);if(!l)return;if(l.runLength>0){let u=await this.range(o.tileDataOffset+l.offset,l.length,r);return $e(u,o.tileCompression)}i=await this.leaf(o,l)}throw Error("isard: PMTiles directories nested too deep")}}var nn=new le(16),Er=(e)=>{let t=nn.get(e);if(t)return t;let n=new on(e);return nn.set(e,n),n};var yt=(e,t)=>{let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,r="",o,s,a]=n;return Er(r).tile(Number(o),Number(s),Number(a),t)};var gt=(e,t)=>{let n=e.sprites.find((o)=>Boolean(o.icons[t])),r=n?.icons[t];return n&&r?{icon:r,image:n.image}:void 0},Pe=new Map,sn=96,Oe=new le(sn),an=(e)=>Math.max(16,Math.ceil(sn/Math.max(1,e))),cn=30000,Ye=new Set,j=new Set,ht=new le(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return})),ln=(e,t="auto")=>{let n=ht.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let i=await o;return i&&createImageBitmap(new Blob([i]))}let s={priority:t,signal:AbortSignal.timeout(cn)},a=await fetch(e,oe(e,s));if(a.status===404||a.status===204)return;if(!a.ok)throw ie(e,a.status);return createImageBitmap(await a.blob())})();return r.catch(()=>ht.delete(e)),ht.set(e,r),r},ee=(e,t="auto")=>{let n=Oe.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let s=await o;return s&&bt(s)}for(let s=0;;s+=1){let a={priority:t,signal:AbortSignal.timeout(cn)},i=await fetch(e,oe(e,a));if(i.status===404||i.status===204)return;if(i.ok)return bt(new Uint8Array(await i.arrayBuffer()));if(s>=2)throw ie(e,i.status);await new Promise((c)=>setTimeout(c,400*(s+1)))}})();return r.catch(()=>Oe.delete(e)),Oe.set(e,r),r},un=(e,t,n,r)=>{let o=xe(t-1,0,e.maxzoom),s=t-o,a=2**Math.max(0,s),[i,c]=s>=0?[Math.floor(n/a),Math.floor(r/a)]:[n,r],l=K(e.tiles,o,i,c),u=1/a;return{url:l,vz:o,vx:i,vy:c,part:u,ox:n%a*u,oy:r%a*u}},C=(e,t,n,r,o)=>{let s=e[t]?.[n];if(s===void 0)return o;let a=Array.isArray(s)&&!ve(s)?s:ae(s,r);return a===void 0||a===null?o:a},pe=(e,t)=>{let n=ce(e)??[0,0,0,1];return Je([n[0],n[1],n[2],n[3]*t])},Le=(e,t)=>{if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)},H=(e,t,n,r,o,s)=>{let a=2**e;return[It((t+o/r)/a),Ft((n+s/r)/a)]};var Ir=300,fn=(e,t,n)=>{let r=Boolean(C(e,"layout",`${t}-allow-overlap`,n,!1)),o=Boolean(C(e,"layout",`${t}-ignore-placement`,n,!1));if(r&&o)return!0;if(r)return"allow";return o?"ignore":!1},mn=(e,t)=>Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t,Fr=(e)=>{let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,r=n,o=n,s=r]=t;return[n,r,o,s]},Nr=(e,t)=>{if(t==="uppercase")return e.toUpperCase();if(t==="lowercase")return e.toLowerCase();return e},Ae=(e,t)=>{let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let r=[];if(!(n>0)||!(t>0))return r;let o=Math.min(t/2,n/2),s=0;for(let a=2;a+1<e.length;a+=2){let[i,c,l,u]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],p=Math.hypot(l-i,u-c);while(p>0&&o<=s+p){let f=(o-s)/p;r.push([i+(l-i)*f,c+(u-c)*f,i,c,l,u,o]),o+=t}s+=p}return r},Ke=(e,t,n)=>{let[r=0,o=0,s=0,a=0,i=0,c=0]=e,l=Math.hypot(i-s,c-a)||1,u=t%2===0?1:-1,[p,f]=[-(c-a)/l*u,(i-s)/l*u];return[r+p*n,o+f*n,Math.atan2(-p,f)*180/Math.PI]},Or=(e,t,n)=>{let r=[],o=0;for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],u=Math.hypot(c-a,l-i),[p,f]=[o,o+u];if(o=f,u<=0||f<t||p>n)continue;let d=(w)=>[a+(c-a)*(w-p)/u,i+(l-i)*(w-p)/u];if(r.length===0)r.push(...d(Math.max(t,p)));r.push(...d(Math.min(n,f)))}return r},Pr=(e,t,n,r,o)=>{let s=C(e,"layout","icon-rotation-alignment",n,"auto"),a=String(C(e,"layout","icon-text-fit",n,"none")),i=C(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:me(e.layout?.["icon-size"])?Number(C(e,"layout","icon-size",n,1)):o(e),anchor:String(C(e,"layout","icon-anchor",n,"center")),offset:mn(C(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(C(e,"layout","icon-rotate",n,0))||0,alignment:s==="map"||s==="auto"&&r==="line"?"map":"viewport",overlap:fn(e,"icon",n),optional:Boolean(C(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:Fr(i),color:String(C(e,"paint","icon-color",n,"#000")),opacity:Number(C(e,"paint","icon-opacity",n,1))}},Ge=16,Lr=(e,t,n)=>{let r=[],o=new Map,s=4096;e.layers.forEach((c)=>{if(c.type!=="fill-extrusion"||!Le(c,n))return;let l=t.get(c["source-layer"]??"");if(!l)return;s=l.extent;for(let u of l.features){let p=Z(u,n);if(u.type!==3||!Q(c.filter,p))continue;let f=Number(C(c,"paint","fill-extrusion-height",p,0));if(!(f>0))continue;let d=[1/0,1/0,-1/0,-1/0];for(let w of u.geometry)for(let h=0;h+1<w.length;h+=2){let[A,m]=[w[h]??0,w[h+1]??0];d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],m),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],m)}r.push({rings:u.geometry,height:f,box:d})}});let a=(c)=>Math.max(0,Math.min(Ge-1,Math.floor(c/s*Ge)));r.forEach(({box:c},l)=>{for(let u=a(c[1]);u<=a(c[3]);u++)for(let p=a(c[0]);p<=a(c[2]);p++){let f=u*Ge+p,d=o.get(f);if(d)d.push(l);else o.set(f,[l])}});let i=(c,l,u)=>{let p=!1;for(let f of c)for(let d=0,w=f.length-2;d+1<f.length;w=d,d+=2){let[h,A,m,M]=[f[d]??0,f[d+1]??0,f[w]??0,f[w+1]??0];if(A>u!==M>u&&l<(m-h)*(u-A)/(M-A)+h)p=!p}return p};return(c,l)=>(o.get(a(l)*Ge+a(c))??[]).reduce((u,p)=>{let f=r[p];return f&&i(f.rings,c,l)?Math.max(u??0,f.height):u},void 0)},pn=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a,zoom:i=n,roofs:c=!1}=t,l=K(e.tiles,n,r,o),u=await ee(l,a);if(!u||j.has(s))return[];let p=[],f=c?Lr(e,u,i):()=>{return},d=new Map,w=(m)=>{let M=d.get(m);if(M!==void 0)return M;let b=m.layout?.["text-size"]??16,x=ve(b)?lt(b):b;return d.set(m,x),x},h=new Map,A=(m)=>{let M=h.get(m);if(M!==void 0)return M;let b=m.layout?.["icon-size"]??1,x=ve(b)?lt(b):b;return h.set(m,x),x};return e.layers.forEach((m,M)=>{let b=m.layout??{};if(m.type!=="symbol"||!Le(m,i))return;if(b["text-field"]===void 0&&b["icon-image"]===void 0)return;let x=u.get(m["source-layer"]??"");if(!x)return;let T={zoom:i,properties:{},type:"Unknown"},E=C(m,"layout","symbol-placement",T,"point")==="line"?"line":"point",_=E==="line"&&C(m,"layout","text-rotation-alignment",T,"auto")!=="viewport";for(let g of x.features){let y=Z(g,i);if(!Q(m.filter,y))continue;let S=ct(b["text-field"],y).trim(),k=ct(b["icon-image"],y).trim();if(!S&&!k)continue;let v=Nr(S,C(m,"layout","text-transform",y,"none")),R=C(m,"layout","text-font",y,["Noto Sans Regular"]),U=zt(Array.isArray(R)&&typeof R[0]==="string"?R[0]:"Noto Sans Regular"),B={layer:M,text:v,font:U,size:me(m.layout?.["text-size"])?Number(C(m,"layout","text-size",y,16)):w(m),color:String(C(m,"paint","text-color",y,"#000")),haloColor:String(C(m,"paint","text-halo-color",y,"rgba(0,0,0,0)")),haloWidth:Number(C(m,"paint","text-halo-width",y,0)),anchor:String(C(m,"layout","text-anchor",y,"center")),offset:mn(C(m,"layout","text-offset",y,[0,0]),[0,0]),maxWidth:Number(C(m,"layout","text-max-width",y,10)),lineHeight:Number(C(m,"layout","text-line-height",y,1.2)),overlap:fn(m,"text",y),..._?{textAlong:_}:{},...C(m,"layout","text-optional",y,!1)?{textOptional:!0}:{},...k?{icon:Pr(m,k,y,E,A)}:{}};if(g.type===1)for(let P of g.geometry)for(let L=0;L+1<P.length;L+=2){let[I,F]=[P[L]??0,P[L+1]??0];if(I<0||F<0||I>=x.extent||F>=x.extent)continue;let[N,W]=H(n,r,o,x.extent,I,F),V=f(I,F);p.push({...B,lon:N,lat:W,...V===void 0?{}:{height:V}})}else if(!v&&E==="line"){let P=Number(C(m,"layout","symbol-spacing",y,250))*x.extent/(512*2**(i-n));for(let L of g.geometry)for(let[I=0,F=0,N=0,W=0,V=0,J=0]of Ae(L,Math.max(P,1))){if(I<0||F<0||I>=x.extent||F>=x.extent)continue;let[z,te]=H(n,r,o,x.extent,I,F),[G,ne]=H(n,r,o,x.extent,V,J),[X,re]=H(n,r,o,x.extent,N,W);p.push({...B,lon:z,lat:te,along:[G-X,ne-re]})}}else if(v&&_){let P=x.extent/(512*2**(i-n)),L=Number(C(m,"layout","symbol-spacing",y,250))*P;for(let I of g.geometry){let F=0;for(let N=2;N+1<I.length;N+=2)F+=Math.hypot((I[N]??0)-(I[N-2]??0),(I[N+1]??0)-(I[N-1]??0));if(F<x.extent/32)continue;for(let[N=0,W=0,V=0,J=0,z=0,te=0,G=0]of Ae(I,Math.max(L,1))){if(N<0||W<0||N>=x.extent||W>=x.extent)continue;let ne=Math.min(G,F-G,Ir*P),X=Or(I,G-ne,G+ne),re=[];for(let Ve=0;Ve+1<X.length;Ve+=2)re.push(...H(n,r,o,x.extent,X[Ve]??0,X[Ve+1]??0));let[Me,Se]=H(n,r,o,x.extent,N,W),[nt,Bn]=H(n,r,o,x.extent,z,te),[Vn,zn]=H(n,r,o,x.extent,V,J);p.push({...B,lon:Me,lat:Se,along:[nt-Vn,Bn-zn],...re.length>=4?{path:re}:{}})}}}else{let P,L=0;for(let F of g.geometry){let N=0;for(let W=2;W+1<F.length;W+=2)N+=Math.hypot((F[W]??0)-(F[W-2]??0),(F[W+1]??0)-(F[W-1]??0));if(N>L)L=N,P=F}if(!P||L<x.extent/32)continue;let I=L/2;for(let F=2;F+1<P.length;F+=2){let[N,W,V,J]=[P[F-2]??0,P[F-1]??0,P[F]??0,P[F+1]??0],z=Math.hypot(V-N,J-W);if(z>=I&&z>0){let[te,G]=[N+(V-N)*I/z,W+(J-W)*I/z];if(te<0||G<0||te>=x.extent||G>=x.extent)break;let[ne,X]=H(n,r,o,x.extent,te,G),[re,Me]=H(n,r,o,x.extent,V,J),[Se,nt]=H(n,r,o,x.extent,N,W);p.push({...B,lon:ne,lat:X,...E==="line"?{along:[re-Se,Me-nt]}:{}});break}I-=z}}}}),p};var dn=(e)=>{let t=e.leaf_type,n=typeof e.nature==="string"?e.nature:"";if(t==="needleleaved"||/conif/i.test(n))return 1;if(t==="broadleaved"||/feuillu/i.test(n))return 0;if(t==="mixed"||/mixte/i.test(n))return 0.5;if(e.class==="wood")return e.subclass==="forest"?0.35:0.15;return 0};var Ze=(e,t)=>{let n=e.length/he,r=n>t?t/n:1,o=[];for(let s=0;s<n;s+=1)if(r>=1||(e[s*he+Qt]??0)<r)o.push(...e.slice(s*he,(s+1)*he));return Float64Array.from(o)},se=(e,t,n,r)=>{let o=Math.imul(e^2654435769,2246822507)^Math.imul(t^3266489909,668265263);return o=Math.imul(o^o>>>15^Math.imul(n,374761393),739982445),o=Math.imul(o^o>>>13^Math.imul(r,695872825),695872825),((o^o>>>16)>>>0)/4294967296},ge=(e,t,n)=>e.reduce((r,o)=>{let s=o.length/2,a=0;for(let i=0,c=s-1;i<s;c=i,i+=1){let[l,u,p,f]=[o[i*2]??0,o[i*2+1]??0,o[c*2]??0,o[c*2+1]??0];if(u>n!==f>n&&t<(p-l)*(n-u)/(f-u)+l)a+=1}return a%2===1?!r:r},!1),Ur=(e,t,n,r,o=Number.POSITIVE_INFINITY)=>{let s=e[0]??[],a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let T=0;T+1<s.length;T+=2){let[E,_]=[s[T]??0,s[T+1]??0];a[0]=Math.min(a[0]??E,E),a[1]=Math.min(a[1]??_,_),a[2]=Math.max(a[2]??E,E),a[3]=Math.max(a[3]??_,_)}let[i,c]=[Math.max(0,a[0]??0),Math.max(0,a[1]??0)],[l,u]=[Math.min(t,a[2]??0),Math.min(t,a[3]??0)];if(!(n>0)||i>=l||c>=u)return[];let p=(l-i)/n*((u-c)/n),f=p>o?n*Math.sqrt(p/o):n,[d,w,h,A]=[Math.floor(i/f),Math.ceil(l/f),Math.floor(c/f),Math.ceil(u/f)],[m,M,b]=r,x=Math.imul(m+1,16777619)^Math.imul(M,1540483477)^Math.imul(b,461845907);return Array.from({length:Math.max(0,A-h)},(T,E)=>h+E).flatMap((T)=>Array.from({length:Math.max(0,w-d)},(E,_)=>d+_).flatMap((E)=>{let _=(E+se(x,E,T,1))*f,g=(T+se(x,E,T,2))*f;if(_<0||g<0||_>=t||g>=t||!ge(e,_,g))return[];return[[_,g,se(x,E,T,3)]]}))},bn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxTrees:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let p=_e(n,o),f=[];e.layers.forEach((A,m)=>{let M=a[m]??0,b=u.get(A["source-layer"]??"");if(!b||!(M>0))return;let x=M/p*b.extent;b.features.forEach((T)=>{if(T.type!==3||!Q(A.filter,Z(T,n)))return;let E=dn(T.properties);T.geometry.reduce((g,y)=>{let S=0;for(let k=0;k+1<y.length;k+=2){let v=(k+2)%y.length;S+=(y[k]??0)*(y[v+1]??0)-(y[v]??0)*(y[k+1]??0)}if(S>0)g.push([y]);else if(S<0)g.at(-1)?.push(y);return g},[]).forEach((g)=>{Ur(g,b.extent,x,[n,r,o],i*4).forEach(([y,S,k])=>{f.push([y,S,k,b.extent,E])})})})});let d=f.length>i?i/f.length:1,w=f.filter(([,,A])=>d>=1||se(Math.floor(A*2147483648),n,r,o)<d),h=new Float64Array(w.length*he);return w.forEach(([A,m,M,b,x],T)=>{let[E,_]=H(n,r,o,b,A,m),g=se(Math.floor(M*2147483648),7,11,13),y=se(Math.floor(M*2147483648),3,5,17)<x?1:0;h.set([E,_,0.75+0.5*M,en(M),g,y],T*he)}),h};var Cr={bus_stop:"shelter",waste_basket:"bin",post_box:"postbox",drinking_water:"fountain",bicycle_parking:"rack"},Wr=new Set(["primary","secondary","tertiary","minor","service","trunk"]),Dr=25,yn={street:[24,3.2],path:[18,1.3]},Br=(e)=>e.filter((t)=>t.type===1),hn=async(e,t)=>{let{z:n,x:r,y:o,id:s,maxObjects:a,priority:i}=t,c=K(e.tiles,n,r,o),l=await ee(c,i);if(!l||j.has(s))return;let u=l.get("poi"),p=l.get("transportation"),f=p?.extent??u?.extent??4096,d=f/_e(n,o),w=(p?.features??[]).filter((_)=>_.type===2&&Wr.has(String(_.properties.class))),h=(l.get("landcover")?.features??[]).filter((_)=>_.type===3&&String(_.properties.class)==="grass").map((_)=>{let g=_.geometry[0]??[],y=g.filter((k,v)=>v%2===0),S=g.filter((k,v)=>v%2===1);return{rings:_.geometry,bounds:[Math.min(...y),Math.min(...S),Math.max(...y),Math.max(...S)]}}),A=(_,g)=>h.some(({rings:y,bounds:[S=0,k=0,v=0,R=0]})=>_>=S&&_<=v&&g>=k&&g<=R&&ge(y,_,g)),m=[],M=(_,g,y,S,k)=>{if(_<0||g<0||_>=f||g>=f)return;let[v,R]=H(n,r,o,f,_,g);m.push(v,R,1,y,S,pt.indexOf(k))},b=Dr*d,x=new Map,T=(_,g)=>(_+32768)*65536+g+32768;w.forEach((_)=>{_.geometry.forEach((g)=>{for(let y=2;y+1<g.length;y+=2){let[S,k,v,R]=[g[y-2]??0,g[y-1]??0,g[y]??0,g[y+1]??0],[U,B]=[Math.floor(Math.min(S,v)/b),Math.floor(Math.max(S,v)/b)],[P,L]=[Math.floor(Math.min(k,R)/b),Math.floor(Math.max(k,R)/b)];for(let I=U;I<=B;I+=1)for(let F=P;F<=L;F+=1){let N=x.get(T(I,F))??[];N.push(S,k,v,R),x.set(T(I,F),N)}}})});let E=(_,g,y)=>{let[S,k,v]=[b*b,0,0],[R,U]=[Math.floor(_/b),Math.floor(g/b)];for(let B=R-1;B<=R+1;B+=1)for(let P=U-1;P<=U+1;P+=1){let L=x.get(T(B,P))??[];for(let I=0;I+3<L.length;I+=4){let[F,N,W,V]=[L[I]??0,L[I+1]??0,L[I+2]??0,L[I+3]??0],[J,z]=[W-F,V-N],te=J*J+z*z,G=te>0?Math.max(0,Math.min(1,((_-F)*J+(g-N)*z)/te)):0,[ne,X]=[F+G*J-_,N+G*z-g],re=ne*ne+X*X;if(re<S)[S,k,v]=[re,ne,X]}}if(k===0&&v===0)return y;return Math.atan2(k,-v)*180/Math.PI};return Br(u?.features??[]).forEach((_)=>{let g=Cr[String(_.properties.subclass)];if(!g)return;_.geometry.forEach(([y=0,S=0])=>{let k=se(Math.floor(y),Math.floor(S),pt.indexOf(g),31);M(y,S,E(y,S,k*360),k,g)})}),(p?.features??[]).forEach((_)=>{let g=String(_.properties.subclass),y=String(_.properties.class)==="path"&&g==="pedestrian",S=String(_.properties.class)==="path"&&(g==="footway"||g==="path");if(_.type!==2||!(y||S))return;let[k,v]=y?yn.street:yn.path;_.geometry.forEach((R)=>{Ae(R,k*d).forEach((U,B)=>{let[P=0,L=0,,,,,I=0]=U;if(S&&!A(P,L))return;let F=se(Math.floor(P),Math.floor(L),Math.floor(I),37);M(...Ke(U,B,v*d),F,"bench")})})}),Ze(m,a)};var gn={flat:1,skillion:1,hipped:2,"half-hipped":2,side_hipped:2,dome:2,onion:2,round:2,gabled:3,saltbox:3,pyramidal:4,cone:4,mansard:5,gambrel:5},Vr=255,wn=(e)=>e==="generated"?Vr:gn[e],xn=(e,t)=>be(e)?t.map((n)=>e[n]).find((n)=>n!==void 0):void 0,_n=(e,t)=>{let n=xn(e,["roof:shape","roof_shape"]);if(t==="flat")return;if(typeof n==="string"&&gn[n]!==void 0)return n;return t==="generated"?"generated":void 0},An=(e)=>Number(xn(e,["roof:height","roof_height"])??Number.NaN);var wt=32,q={color:0,second:4,size:8,size2:16,range:24,blur:26,landmark:26,patternRatio:27,fillPattern:28,linePattern:29};class Be{static __wrap(e){let t=Object.create(Be.prototype);return t.__wbg_ptr=e,Mn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Mn.unregister(this),e}free(){let e=this.__destroy_into_raw();O.__wbg_tessellatedtile_free(e,0)}blockIndices(){return O.tessellatedtile_blockIndices(this.__wbg_ptr)}blockRanges(){let e=O.tessellatedtile_blockRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}blocks(){return O.tessellatedtile_blocks(this.__wbg_ptr)}bounds(){let e=O.tessellatedtile_bounds(this.__wbg_ptr);var t=Jr(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*8,8),t}fillRanges(){let e=O.tessellatedtile_fillRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}indices(){return O.tessellatedtile_indices(this.__wbg_ptr)}lineRanges(){let e=O.tessellatedtile_lineRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}lineTable(){return O.tessellatedtile_lineTable(this.__wbg_ptr)}pieces(){return O.tessellatedtile_pieces(this.__wbg_ptr)}prism(){return O.tessellatedtile_prism(this.__wbg_ptr)!==0}vertices(){return O.tessellatedtile_vertices(this.__wbg_ptr)}}if(Symbol.dispose)Be.prototype[Symbol.dispose]=Be.prototype.free;function kn(e,t,n,r,o,s,a,i,c,l,u,p,f,d,w,h,A){let m=Xe(e,O.__wbindgen_malloc),M=Y,b=de(t,O.__wbindgen_malloc),x=Y,T=de(n,O.__wbindgen_malloc),E=Y,_=de(r,O.__wbindgen_malloc),g=Y,y=de(o,O.__wbindgen_malloc),S=Y,k=Xe(s,O.__wbindgen_malloc),v=Y,R=de(a,O.__wbindgen_malloc),U=Y,B=de(i,O.__wbindgen_malloc),P=Y,L=de(c,O.__wbindgen_malloc),I=Y,F=Sn(l,O.__wbindgen_malloc),N=Y,W=Sn(u,O.__wbindgen_malloc),V=Y,J=$r(p,O.__wbindgen_malloc),z=Y,te=Xe(f,O.__wbindgen_malloc),G=Y,ne=de(d,O.__wbindgen_malloc),X=Y,re=Xe(A,O.__wbindgen_malloc),Me=Y,Se=O.tessellateVectorTile(m,M,b,x,T,E,_,g,y,S,k,v,R,U,B,P,L,I,F,N,W,V,J,z,te,G,ne,X,w,h,re,Me);return Be.__wrap(Se)}function zr(){return{__proto__:null,"./isard_tess_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(qr(t,n))},__wbg_new_from_slice_37a3c3a194266cb8:function(t,n){return new Uint32Array(Qe(t,n))},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(jr(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(Hr(t,n))},__wbindgen_init_externref_table:function(){let t=O.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Mn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>O.__wbg_tessellatedtile_free(e,1));function Hr(e,t){return e=e>>>0,vn().subarray(e/4,e/4+t)}function Jr(e,t){return e=e>>>0,Rn().subarray(e/8,e/8+t)}function Qe(e,t){return e=e>>>0,Tn().subarray(e/4,e/4+t)}function jr(e,t){return e=e>>>0,_t().subarray(e/1,e/1+t)}var Ue=null;function vn(){if(Ue===null||Ue.byteLength===0)Ue=new Float32Array(O.memory.buffer);return Ue}var Ce=null;function Rn(){if(Ce===null||Ce.byteLength===0)Ce=new Float64Array(O.memory.buffer);return Ce}function qr(e,t){return Gr(e>>>0,t)}var We=null;function Tn(){if(We===null||We.byteLength===0)We=new Uint32Array(O.memory.buffer);return We}var De=null;function _t(){if(De===null||De.byteLength===0)De=new Uint8Array(O.memory.buffer);return De}function de(e,t){let n=t(e.length*4,4)>>>0;return Tn().set(e,n/4),Y=e.length,n}function Sn(e,t){let n=t(e.length*1,1)>>>0;return _t().set(e,n/1),Y=e.length,n}function $r(e,t){let n=t(e.length*4,4)>>>0;return vn().set(e,n/4),Y=e.length,n}function Xe(e,t){let n=t(e.length*8,8)>>>0;return Rn().set(e,n/8),Y=e.length,n}var et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});et.decode();var Yr=2146435072,xt=0;function Gr(e,t){if(xt+=t,xt>=Yr)et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),et.decode(),xt=t;return et.decode(_t().subarray(e,e+t))}var Y=0,Kr,Zr,O;function Xr(e,t){return Zr=e,O=e.exports,Kr=t,Ue=null,Ce=null,We=null,De=null,O.__wbindgen_start(),O}async function Qr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function En(e){if(O!==void 0)return O;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_tess_bg.wasm",import.meta.url);let t=zr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await Qr(await e,t);return Xr(n,r)}var tt=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a}=t,i=K(e.tiles,n,r,o),c=await ee(i,a),l={points:[],ringStart:[],polygonStart:[],feature:[]},u=[];if(!c||j.has(s))return;let p=new Set,f=2**n;return e.layers.forEach((d)=>{let w=c.get(d["source-layer"]??"");if(!w)return;w.features.forEach((h)=>{if(h.type!==3||p.has(h)||!Q(d.filter,Z(h,n)))return;p.add(h);let A=u.length;u.push(h.properties),h.geometry.forEach((m)=>{let M=0;for(let b=0;b+1<m.length;b+=2){let x=(b+2)%m.length;M+=(m[b]??0)*(m[x+1]??0)-(m[x]??0)*(m[b+1]??0)}if(M===0)return;if(M>0||l.polygonStart.length===0||l.feature.at(-1)!==A)l.polygonStart.push(l.ringStart.length),l.feature.push(A);l.ringStart.push(l.points.length/2);for(let b=0;b+1<m.length;b+=2)l.points.push((r+(m[b]??0)/w.extent)/f,(o+(m[b+1]??0)/w.extent)/f)})})}),l.ringStart.push(l.points.length/2),l.polygonStart.push(l.ringStart.length-1),{arrays:{points:Float64Array.from(l.points),ringStart:Uint32Array.from(l.ringStart),polygonStart:Uint32Array.from(l.polygonStart),feature:Uint32Array.from(l.feature)},properties:u}},eo=new Set(["theatre","museum","place_of_worship","castle","monument","attraction","town_hall"]),to=(e)=>(e?.get("poi")?.features??[]).filter((t)=>t.type===1&&eo.has(String(t.properties.class))).flatMap((t)=>t.geometry.flat()),At=(e)=>{let[t,n,r,o]=[1/0,1/0,-1/0,-1/0];for(let s=0;s+1<e.length;s+=2)[t,n]=[Math.min(t,e[s]??0),Math.min(n,e[s+1]??0)],[r,o]=[Math.max(r,e[s]??0),Math.max(o,e[s+1]??0)];return[t,n,r,o]},no=(e,t)=>{if(t.length===0)return!1;let[n,r,o,s]=At(e[0]??[]);for(let a=0;a+1<t.length;a+=2){let[i,c]=[t[a]??0,t[a+1]??0];if(i>=n&&i<=o&&c>=r&&c<=s&&ge(e,i,c))return!0}return!1},In=(e)=>{let t=e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1],n=Math.max(1,e.length/2-(t?1:0)),[r,o]=[0,0];for(let s=0;s<n;s+=1)[r,o]=[r+(e[s*2]??0),o+(e[s*2+1]??0)];return[r/n,o/n]},ro=(e,t)=>{let n=e.filter((s)=>s.type===3),r=n.filter((s)=>no(s.geometry,t)),o=new Set(r);return r.forEach((s)=>{let[a,i,c,l]=At(s.geometry[0]??[]),u=In(s.geometry[0]??[]);n.forEach((p)=>{if(o.has(p))return;let[f,d,w,h]=At(p.geometry[0]??[]);if(w<a||f>c||h<i||d>l)return;if(ge(s.geometry,...In(p.geometry[0]??[]))||ge(p.geometry,...u))o.add(p)})}),o},oo={line:(e)=>e!==1,circle:(e)=>e===1,fill:(e)=>e===3,extrusion:(e)=>e===3},so=(e,t)=>{let n=_n(e,t);return[n===void 0?0:wn(n)??0,An(e)]},io=24,ao=(e,t,n,r)=>{if(!at(e.filter))return Q(e.filter,Z(t,n))?[0,0]:void 0;let o,s=0;for(let a=n-1;a<=r;a+=1)if(Q(e.filter,Z(t,a)))o??=a,s=a+1;else if(o!==void 0)break;return o===void 0?void 0:[o<=n-1?0:o,s>r?99:s]},co=(e,t)=>{let n=e.slice(),r=[[0,0,(o)=>o>=0],[0,t,(o)=>o<=t],[1,0,(o)=>o>=0],[1,t,(o)=>o<=t]];for(let[o,s,a]of r){let i=[],c=n.length/2;for(let l=0;l<c;l+=1){let[u,p]=[n[l*2]??0,n[l*2+1]??0],f=(l+1)%c,[d,w]=[n[f*2]??0,n[f*2+1]??0],[h,A]=o===0?[u,d]:[p,w];if(a(h))i.push(u,p);if(a(h)!==a(A)){let m=(s-h)/(A-h);i.push(o===0?s:u+(d-u)*m,o===0?p+(w-p)*m:s)}}if(n=i,n.length===0)break}return n},lo=0.00048828125,uo=(e,t)=>{let n=e.length/2;if(n<=2)return[...e];let r=new Uint8Array(n),o=[[0,n-1]],s=t*t;r[0]=1,r[n-1]=1;while(o.length>0){let[a,i]=o.pop()??[0,0],[c,l,u,p]=[e[a*2]??0,e[a*2+1]??0,e[i*2]??0,e[i*2+1]??0],[f,d]=[u-c,p-l],w=f*f+d*d,[h,A]=[-1,s];for(let m=a+1;m<i;m+=1){let[M,b]=[(e[m*2]??0)-c,(e[m*2+1]??0)-l],x=w>0?Math.max(0,Math.min(1,(M*f+b*d)/w)):0,T=(M-x*f)**2+(b-x*d)**2;if(T>A)[h,A]=[m,T]}if(h>=0)r[h]=1,o.push([a,h],[h,i])}return e.filter((a,i)=>r[i>>1]===1)},fo=(e,t)=>{let n=[],r=[],o=()=>{if(r.length>=4)n.push(r);r=[]};for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],[u,p]=[c-a,l-i],[f,d]=[0,1];for(let[w,h]of[[-u,a],[u,t-a],[-p,i],[p,t-i]])if(w===0){if(h<0)d=-1}else if(w<0)f=Math.max(f,h/w);else d=Math.min(d,h/w);if(f>d){o();continue}if(r.length===0||f>0)o(),r.push(a+u*f,i+p*f);if(r.push(a+u*d,i+p*d),d<1)o()}return o(),n},mo=(e,t)=>e>=t?[e-0.5,e+1,e+3,e+6]:[e-0.5,e-0.16666666666666666,e+0.16666666666666666,e+0.5],po=(e,t,n,r,o)=>{let s=2**n,[a,i]=[r*t,o*t],c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];e.forEach((d)=>{for(let w=0;w+1<d.length;w+=2){let[h,A]=[(d[w]??0)*s-a,(d[w+1]??0)*s-i];c[0]=Math.min(c[0]??h,h),c[1]=Math.min(c[1]??A,A),c[2]=Math.max(c[2]??h,h),c[3]=Math.max(c[3]??A,A)}});let[l=0,u=0,p=0,f=0]=c;if(p<=0||f<=0||l>=t||u>=t)return;return e.map((d)=>d.map((w,h)=>w*s-(h%2===0?a:i)))},bo=(e)=>{let t=[],n=[],r=[],o=[];return{add:(i,c,l,u,p,f=!1)=>{let d=(b,x,T)=>C(c,"paint",b,{...l,zoom:T},x),w=`${c.type}-opacity`,h=me(c.paint?.[w]),A=(b)=>{let[x,T,E,_]=ce(d(f?"fill-outline-color":`${c.type}-color`,"#000",b))??[0,0,0,1];return[x,T,E,_*(h?Number(d(w,1,b)):1)]},m=Array(wt).fill(0),M=e[3]-e[0]>1.5?e[1]:e[3];if(m.splice(q.color,8,...A(e[0]),...A(M)),m.splice(q.range,2,...p),!f&&["fill","background","line","fill-extrusion"].includes(c.type)){let b=d(`${c.type}-pattern`,"",(e[0]+M)/2);if(typeof b==="string"&&b){let x=n.indexOf(b);m[c.type==="fill"||c.type==="background"?q.fillPattern:q.linePattern]=(x>=0?x:n.push(b)-1)+1}}if(c.type==="circle"){let b=(e[0]+M)/2,[x,T,E,_]=ce(d("circle-stroke-color","#000",b))??[0,0,0,1];m.splice(q.color,8,...A(b),x,T,E,_*Number(d("circle-stroke-opacity",1,b)))}return e.forEach((b,x)=>{if(m[q.size+x]=b,f){m[q.size+4+x]=1;return}if(c.type==="circle"){m[q.size+4+x]=Math.max(0,Number(d("circle-radius",5,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(d("circle-stroke-width",0,b))||0);return}if(c.type==="fill-extrusion"){m[q.size+4+x]=Math.max(0,Number(d("fill-extrusion-height",0,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(d("fill-extrusion-base",0,b))||0);return}if(c.type!=="line")return;if(x===0)m[q.blur]=Math.max(0,Number(d("line-blur",0,(e[0]+M)/2))||0);let T=Number(d("line-width",1,b)),E=Number(d("line-gap-width",0,b));m[q.size+4+x]=Math.max(0,E>0?E+2*T:T),m[q.size2+x]=b,m[q.size2+4+x]=Number(d("line-offset",0,b))||0}),t.push(...m),r.push(u),o.push(i),r.length-1},landmark:(i)=>{t[i*wt+q.landmark]=1},styles:t,patterns:n,properties:r,sublayer:o}},yo=(e,t,n)=>{let r={points:[],ringStart:[],polygonStart:[],feature:[],roofs:[],roofHeights:[],roofOutlines:[],roofOutlineStart:[]},o={points:[],start:[],feature:[]},s={points:[],feature:[]},a={fill:[],line:[],circle:[]},i=(u,p,f)=>[(e+u/f)/n,(t+p/f)/n],c=(u,p,f)=>{r.polygonStart.push(r.ringStart.length),r.feature.push(u),r.roofs.push(p),r.roofHeights.push(f),r.roofOutlineStart.push(r.roofOutlines.length/2)},l=()=>{a.fill.push(r.polygonStart.length),a.line.push(o.start.length),a.circle.push(s.feature.length)};return{sublayer:l,background:(u)=>{c(u,0,Number.NaN),r.ringStart.push(r.points.length/2),r.points.push(e/n,t/n,(e+1)/n,t/n,(e+1)/n,(t+1)/n,e/n,(t+1)/n)},circles:(u,p,f)=>{u.forEach((d)=>{for(let w=0;w+1<d.length;w+=2){let[h=0,A=0]=[d[w],d[w+1]];if(h<0||A<0||h>=f||A>=f)continue;s.points.push(...i(h,A,f)),s.feature.push(p)}})},lines:(u,p,f,d)=>{u.forEach((w)=>{let h=p&&w.length>=2?[...w,w[0]??0,w[1]??0]:w;fo(h,d).forEach((A)=>{let m=uo(A,d*lo);o.start.push(o.points.length/2),o.feature.push(f);for(let M=0;M+1<m.length;M+=2)o.points.push(...i(m[M]??0,m[M+1]??0,d))})})},polygons:(u,p,[f,d],w)=>{let h=!1;u.forEach((A)=>{let m=0;for(let b=0;b+1<A.length;b+=2){let x=(b+2)%A.length;m+=(A[b]??0)*(A[x+1]??0)-(A[x]??0)*(A[b+1]??0)}if(m===0)return;if(m<0&&!h)return;let M=co(A,w);if(m>0)h=M.length>=6;if(M.length<6)return;if(m>0){if(c(p,f,d),f>1&&A.some((b)=>b<0||b>w))for(let b=0;b+1<A.length;b+=2)r.roofOutlines.push(...i(A[b]??0,A[b+1]??0,w))}r.ringStart.push(r.points.length/2);for(let b=0;b+1<M.length;b+=2)r.points.push(...i(M[b]??0,M[b+1]??0,w))})},done:()=>(l(),r.ringStart.push(r.points.length/2),r.polygonStart.push(r.ringStart.length-1),r.roofOutlineStart.push(r.roofOutlines.length/2),o.start.push(o.points.length/2),{fills:{points:Float64Array.from(r.points),ringStart:Uint32Array.from(r.ringStart),polygonStart:Uint32Array.from(r.polygonStart),feature:Uint32Array.from(r.feature),fillStart:Uint32Array.from(a.fill),roofs:Uint8Array.from(r.roofs),roofHeights:Float32Array.from(r.roofHeights),roofOutlines:Float64Array.from(r.roofOutlines),roofOutlineStart:Uint32Array.from(r.roofOutlineStart),roofMetres:rt((t+0.5)/n)},lines:{points:Float64Array.from(o.points),start:Uint32Array.from(o.start),feature:Uint32Array.from(o.feature),lineStart:Uint32Array.from(a.line)},circles:{points:Float64Array.from(s.points),feature:Uint32Array.from(s.feature),circleStart:Uint32Array.from(a.circle)},tile:Float64Array.of(e/n,t/n,(e+1)/n,(t+1)/n)})}},Fn=async(e,t,n)=>{let{z:r,x:o,y:s,id:a,priority:i,deepest:c=e.maxzoom,roofs:l="data",covered:u=[]}=t,p=Math.max(0,r-e.maxzoom),[f,d,w]=[r-p,Math.floor(o/2**p),Math.floor(s/2**p)],[h,A]=[o-d*2**p,s-w*2**p],m=await ee(K(e.tiles,f,d,w),i);if(j.has(a))return;let M=to(m),b=new Map,x=(g)=>{let y=b.get(g)??(M.length>0?ro(g,M):new Set);return b.set(g,y),y},T=(g,y)=>{if(u.length===0)return!1;let[S=0,k=0]=g.geometry[0]??[],[v,R]=H(f,d,w,y,S,k);for(let U=0;U+3<u.length;U+=4)if(v>=(u[U]??0)&&R>=(u[U+1]??0)&&v<=(u[U+2]??0)){if(R<=(u[U+3]??0))return!0}return!1},E=bo(mo(r,Math.max(c,e.maxzoom))),_=r>=Math.max(c,e.maxzoom)?io:r;return e.layers.forEach((g,y)=>{n?.sublayer();let S=je(g),k=g.type==="fill"&&g.paint?.["fill-outline-color"]!==void 0&&g.paint?.["fill-antialias"]!==!1;if(!S)return;if(g.type==="background"){let R=E.add(y,g,{zoom:r,properties:{},type:"Unknown"},{},[0,0]);n?.background(R);return}let v=m?.get(g["source-layer"]??"");v?.features.forEach((R)=>{if(!oo[S](R.type))return;if(S==="extrusion"&&T(R,v.extent))return;let U=Z(R,r),B=ao(g,R,r,_);if(!B)return;let P=p>0?po(R.geometry,v.extent,p,h,A):R.geometry;if(!P)return;let L=E.add(y,g,U,R.properties,B),I=k?E.add(y,g,U,R.properties,B,!0):-1;if(S==="extrusion"&&x(v.features).has(R))E.landmark(L);if(!n)return;if(S==="circle"){n.circles(P,L,v.extent);return}if(S==="line"){n.lines(P,R.type===3,L,v.extent);return}if(I>=0)n.lines(P,!0,I,v.extent);let F=S==="extrusion"?so(R.properties,l):[0,Number.NaN];n.polygons(P,L,F,v.extent)})}),E},Nn=async(e,t)=>{let n=await Fn(e,t);return n&&{styles:Float32Array.from(n.styles),patterns:n.patterns}},On=async(e,t)=>{let n=yo(t.x,t.y,2**t.z),r=await Fn(e,t,n);if(!r)return;return{...n.done(),styles:Float32Array.from(r.styles),patterns:r.patterns,properties:r.properties,sublayer:Uint16Array.from(r.sublayer)}},we={},Pn=()=>{if(!we.url)return Promise.resolve(!1);let e=we.ready??En({module_or_path:we.url}).then(()=>!0,(t)=>(console.warn("isard: the tessellation module failed to load, the main thread does its work",t),!1));return we.ready=e,e},Ln=(e,t,n)=>{let{fills:r,lines:o}=e;try{let s=kn(r.points,r.ringStart,r.polygonStart,r.feature,r.fillStart,o.points,o.start,o.feature,o.lineStart,t,r.roofs??new Uint8Array,r.roofHeights??new Float32Array,r.roofOutlines??new Float64Array,r.roofOutlineStart??new Uint32Array,r.roofMetres??0,n,e.tile??new Float64Array),a={vertices:s.vertices(),indices:s.indices(),fillRanges:s.fillRanges(),prism:s.prism(),pieces:s.pieces(),lineTable:s.lineTable(),lineRanges:s.lineRanges(),blocks:s.blocks(),blockIndices:s.blockIndices(),blockRanges:s.blockRanges(),bounds:s.bounds()};return s.free(),a}catch(s){console.warn("isard: the tessellation module failed, the main thread does its work",s),we.ready=Promise.resolve(!1);return}};var ho={primary:8,secondary:7,tertiary:6,minor:5,service:4},Un=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxLamps:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let p=_e(n,o),f=new Set,d=[];return e.layers.forEach((w)=>{let h=u.get(w["source-layer"]??"");if(!h)return;let A=h.extent/p;h.features.forEach((m)=>{let M=ho[String(m.properties.class)];if(m.type!==2||M===void 0||f.has(m)||!Q(w.filter,Z(m,n)))return;f.add(m),m.geometry.forEach((b)=>{Ae(b,a*A).forEach((x,T)=>{let[E,_,g]=Ke(x,T,M*A);if(E<0||_<0||E>=h.extent||_>=h.extent)return;let[y,S]=H(n,r,o,h.extent,E,_),k=se(Math.floor(E),Math.floor(_),Math.floor(x[6]??0),29);d.push(y,S,1,g,k,0)})})})}),Ze(d,i)};var go=new Set(["butt","round","square"]),wo=new Set(["bevel","miter","round"]),xo=(e)=>go.has(e),_o=(e)=>wo.has(e),Ao=(e)=>xo(e)?e:"butt",Mo=(e)=>_o(e)?e:"miter",So=(e,t)=>{if(e.patterns.has(t))return e.patterns.get(t);let r=(()=>{let o=gt(e,t);if(!o||!(o.icon.width>0)||!(o.icon.height>0))return;let{icon:s}=o,a=new OffscreenCanvas(s.width,s.height);return a.getContext("2d")?.drawImage(o.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),a})();return e.patterns.set(t,r),r},Mt=new Map,ko=(e)=>{let t=Mt.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("isard: no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}},vo=(e)=>{let t=Mt.get(e.width)??[];if(Mt.set(e.width,t),t.length<4)t.push(e)},Ro=(e,t,n)=>{if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})},Cn=async(e,t)=>{let{z:n,x:r,y:o,size:s,id:a,priority:i}=t,c=un(e,n,r,o),l=await ee(c.url,i);if(j.has(a))return;let{canvas:u,g:p}=ko(s);try{return await To(e,c,l,u,p,n,r,o,s,a,i)}finally{vo(u)}},To=async(e,t,n,r,o,s,a,i,c,l,u)=>{let p=Math.max(0,s-1),f=c/256,d=!1,w=!1;for(let h of e.layers){if(!Le(h,p))continue;let A={zoom:p,properties:{},type:"Unknown"};if(h.type==="background"){let g=C(h,"paint","background-color",A,"#000"),y=Number(C(h,"paint","background-opacity",A,1));if(o.fillStyle=pe(g,y),o.fillRect(0,0,c,c),(ce(g)??[0,0,0,1])[3]*y>=1)w=!0;d=!0;continue}if(h.type==="raster"){let g=h.source===void 0?void 0:e.rasters[h.source];if(!g)continue;let y=xe(s-(g.tileSize>=512?1:0),0,g.maxzoom),S=2**(s-y),k=K(g.tiles,y,Math.floor(a/S),Math.floor(i/S)),v=await ln(k,u);if(j.has(l))return;if(!v)continue;let[R,U]=[v.width/S,v.height/S];o.globalAlpha=Number(C(h,"paint","raster-opacity",A,1)),o.drawImage(v,a%S*R,i%S*U,R,U,0,0,c,c),o.globalAlpha=1,d=!0;continue}let m=n?.get(h["source-layer"]??"");if(!m)continue;let M=c/(m.extent*t.part),[b,x]=[t.ox*m.extent,t.oy*m.extent],T=(g,y)=>{o.beginPath();for(let S of g.geometry){for(let k=0;k+1<S.length;k+=2){let[v,R]=[((S[k]??0)-b)*M,((S[k+1]??0)-x)*M];if(k===0)o.moveTo(v,R);else o.lineTo(v,R)}if(y)o.closePath()}},E=new Map,_=(g,y,S,k)=>{let v=E.get(y),R=v??me(h[g]?.[y]);if(v===void 0)E.set(y,R);return C(h,g,y,R?S:A,k)};for(let g of m.features){let y=Z(g,p);if(!Q(h.filter,y))continue;if(h.type==="fill-extrusion"&&g.type===3)T(g,!0),o.fillStyle=pe(_("paint","fill-extrusion-color",y,"#000"),Number(_("paint","fill-extrusion-opacity",y,1))),o.fill("evenodd"),d=!0;else if(h.type==="fill"&&g.type===3){let S=Number(_("paint","fill-opacity",y,1)),k=_("paint","fill-pattern",y,void 0);T(g,!0);let v=typeof k==="string"?gt(e,k)?.icon:void 0,R=v&&typeof k==="string"&&So(e,k);if(v&&R){let U=o.createPattern(R,"repeat");if(U)U.setTransform(new DOMMatrix().scale(f/(v.pixelRatio??1))),o.globalAlpha=S,o.fillStyle=U,o.fill("evenodd"),o.globalAlpha=1}else{o.fillStyle=pe(_("paint","fill-color",y,"#000"),S),o.fill("evenodd");let U=_("paint","fill-outline-color",y,void 0);if(U!==void 0)o.strokeStyle=pe(U,S),o.lineWidth=f,o.setLineDash([]),o.stroke()}d=!0}else if(h.type==="line"&&g.type!==1){let S=Number(_("paint","line-width",y,1));if(S<=0)continue;let k=Number(_("paint","line-gap-width",y,0));o.strokeStyle=pe(_("paint","line-color",y,"#000"),Number(_("paint","line-opacity",y,1))),o.lineWidth=(k>0?k+2*S:S)*f,o.lineCap=Ao(_("layout","line-cap",y,"butt")),o.lineJoin=Mo(_("layout","line-join",y,"miter"));let v=_("paint","line-dasharray",y,void 0);o.setLineDash(Array.isArray(v)?v.map((R)=>Number(R)*S*f):[]),T(g,g.type===3),o.stroke(),d=!0}else if(h.type==="circle"&&g.type===1){let S=Number(_("paint","circle-radius",y,5))*f;o.fillStyle=pe(_("paint","circle-color",y,"#000"),Number(_("paint","circle-opacity",y,1)));let k=Number(_("paint","circle-stroke-width",y,0))*f;o.strokeStyle=pe(_("paint","circle-stroke-color",y,"#000"),Number(_("paint","circle-stroke-opacity",y,1))),o.lineWidth=k;for(let v of g.geometry)for(let R=0;R+1<v.length;R+=2)if(o.beginPath(),o.arc(((v[R]??0)-b)*M,((v[R+1]??0)-x)*M,S,0,2*Math.PI),o.fill(),k>0)o.stroke();d=!0}}}if(!d&&!n)return null;return Ro(r,o,w)};var Wn=async(e,t)=>{let{z:n,tiles:r,bounds:o,width:s,height:a,iterations:i,module:c,priority:l,id:u}=t,[p,f,d,w]=o,h=[],A=[],m=[],M=2**n;for(let b=0;b+1<r.length;b+=2){let x=r[b]??0,T=(x%M+M)%M,E=(x-T)/M,_=await tt(e,{z:n,x:T,y:r[b+1]??0,id:u,priority:l});if(j.has(u))throw Error("aborted");if(!_)continue;let{points:g,ringStart:y,polygonStart:S}=_.arrays;for(let k=0;k+1<S.length;k++){let[v,R]=[S[k]??0,S[k+1]??0],U=y[v]??0,B=y[R]??0,[P,L,I,F]=[1/0,1/0,-1/0,-1/0];for(let N=U;N<B;N++){let[W,V]=[(g[N*2]??0)+E,g[N*2+1]??0];P=Math.min(P,W),L=Math.min(L,V),I=Math.max(I,W),F=Math.max(F,V)}if(I<p||P>d||F<f||L>w)continue;m.push(A.length);for(let N=v;N<R;N++){A.push(h.length/2);for(let W=y[N]??0;W<(y[N+1]??0);W++)h.push(((g[W*2]??0)+E-p)/(d-p)*s,((g[W*2+1]??0)-f)/(w-f)*a)}}}return A.push(h.length/2),m.push(A.length-1),Zt({points:Float64Array.from(h),ringStart:Uint32Array.from(A),polygonStart:Uint32Array.from(m)},s,a,i,c)};var St=new Map,Eo={},Dn=Tt(),ue=(e,t=[])=>self.postMessage(e,t),Io=({fills:e,lines:t,circles:n,styles:r,sublayer:o,mesh:s})=>[e.points,e.ringStart,e.polygonStart,e.feature,e.fillStart,e.roofs,e.roofHeights,e.roofOutlines,e.roofOutlineStart,t.points,t.start,t.feature,t.lineStart,n?.points,n?.feature,n?.circleStart,r,o,s?.vertices,s?.indices,s?.fillRanges,s?.pieces,s?.lineTable,s?.lineRanges,s?.blocks,s?.blockIndices,s?.blockRanges,s?.bounds].flatMap((a)=>a?[a.buffer]:[]),Fo={render:async(e,t)=>{let n=await Cn(e,t);return n?[{image:n},[n]]:void 0},labels:async(e,t)=>[{labels:await pn(e,t)},[]],polygons:async(e,t)=>{let n=await tt(e,t);if(!n)return;let{points:r,ringStart:o,polygonStart:s,feature:a}=n.arrays;return[{polygons:n},[r.buffer,o.buffer,s.buffer,a.buffer]]},trees:async(e,t)=>{let n=await bn(e,t);return n&&[{trees:n},[n.buffer]]},furniture:async(e,t)=>{let n=await hn(e,t);return n&&[{furniture:n},[n.buffer]]},lamps:async(e,t)=>{let n=await Un(e,t);return n&&[{lamps:n},[n.buffer]]},street:async(e,t)=>{let n=await Wn(e,t);return[{street:n},[n.eastU,n.eastV,n.northU,n.northV].map((r)=>r.buffer)]},vectors:async(e,t)=>{if(t.styles){let a=await Nn(e,t);return a&&[a,[a.styles.buffer]]}let n=await On(e,t);if(!n)return;let r=Uint8Array.from(e.layers,(a)=>je(a)==="extrusion"?1:0),o=await Pn()?Ln(n,r,t.prism===!0):void 0,s=o?{...n,mesh:o}:n;return[{vectors:s},Io(s)]}},No=(e,t,n)=>Fo[t](e,n);self.onmessage=async({data:e})=>{if(e.type==="headers"){Rt(e.rules);return}if(e.type==="tess"){we.url=e.url;return}if(e.type==="init"){if(e.workers!==void 0)Oe.capacity=an(e.workers);Pe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){Pe.get(e.key)?.sprites.forEach((t)=>{t.image.close()}),Pe.delete(e.key);return}if(e.type==="abort"){if(Ye.has(e.id))j.add(e.id);St.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"||e.type==="grids"){await Po(e);return}Ye.add(e.id);try{let t=Pe.get(e.key);if(!t)throw Error(`isard: no renderer ${e.key}`);let n=await No(t,e.type,e);if(n)ue({id:e.id,...n[0]},n[1]);else ue({id:e.id,missing:!0})}catch(t){ue({id:e.id,error:String(t)})}finally{Ye.delete(e.id),j.delete(e.id)}};var Oo=async(e,t)=>(await kt(e,oe(e,{signal:t}))).arrayBuffer(),Po=async(e)=>{let t=new AbortController;St.set(e.id,t);try{if(e.type==="grids"){let{module:n,url:r,bytes:o}=e,s=o??(r?await Oo(r,t.signal):new ArrayBuffer(0)),{grids:a,values:i}=await Xt(new Uint8Array(s),n);ue({id:e.id,grids:a,values:i},i.map((c)=>c.buffer))}else if(e.type==="heights"){let n=await Nt(e.url,e.encoding,e.floor,t.signal,Eo);if(n)ue({id:e.id,heights:n},[n.buffer]);else ue({id:e.id,missing:!0})}else{Dn.cache.capacity=e.cached;let n=await Dn.draw(e.job,t.signal);if(n)ue({id:e.id,image:n},[n]);else ue({id:e.id,missing:!0})}}catch(n){ue({id:e.id,error:String(n)})}finally{St.delete(e.id)}};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=726697CA6336C70A64756E2164756E21
|
|
4
4
|
//# sourceMappingURL=basemap.worker.js.map
|