From 69322a716d31affb1f9acec79f79a98ade6cb1b0 Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Sun, 29 Nov 2026 12:54:08 +0900 Subject: [PATCH] feat(map): draw Protomaps vector basemaps on map fences params.map.protomaps.url takes an https:// PMTiles archive or a {z}/{x}/{y} vector-tile template in place of raster tiles. The vendored protomaps-leaflet 5.1.0, built through bin/vendor/build.mjs with its bundled licenses, renders it on the existing Leaflet map, so markers, popups, keyboard use and click-to-load are unchanged. It loads after Leaflet and only on sites that configure it. flavor and dark_flavor follow the color mode, lang defaults to the site language (zh-Hans/zh-Hant for Chinese), and max_data_zoom defaults to 15. Failed vector tiles are counted at the source, since the renderer never reports them to Leaflet, so a basemap that cannot load hides the canvas and keeps the place list. Raster-only output is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E5Vqie6ki3BNRLF3Mc6qkK --- CHANGELOG.md | 13 + VENDOR.json | 24 +- assets/js/content-components.js | 110 ++++++-- .../protomaps-leaflet/LICENSES.txt | 242 ++++++++++++++++++ .../protomaps-leaflet.min.js | 22 ++ bin/check-params.py | 38 ++- bin/generate-config-schema.py | 11 + bin/vendor/build.mjs | 6 + bin/vendor/package-lock.json | 144 ++++++++++- bin/vendor/package.json | 6 +- hugo.yaml | 11 + layouts/_partials/content/map-config.html | 118 ++++++++- layouts/_partials/scripts.html | 13 +- schema/site-params.schema.json | 44 +++- tests/js/content-components-map.test.js | 123 ++++++++- 15 files changed, 879 insertions(+), 46 deletions(-) create mode 100644 assets/third_party/protomaps-leaflet/LICENSES.txt create mode 100644 assets/third_party/protomaps-leaflet/protomaps-leaflet.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index aec59284..16008f83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,19 @@ the `social` shortcode of 1.7.0 with a callout. A patch release only fixes. `lines` keeps its per-line prefix colours. Conflicting inputs and missing, blank or non-string source warn and drop the visual. Print shows the source as plain text. Custom shells get the dark syntax palette in the Landing stylesheet. +- **Protomaps basemaps for `map` fences.** `params.map.protomaps.url` takes an + https:// PMTiles archive (a path ending in `.pmtiles`) or a `{z}/{x}/{y}` + vector-tile template such as the Protomaps API, in place of raster `tiles`. + The vendored protomaps-leaflet `5.1.0` draws it on the existing Leaflet map, + so markers, popups, keyboard use and click-to-load stay as they are; it loads + after Leaflet and only on sites that configure it. `flavor` and + `dark_flavor` (light, dark, white, grayscale, black; default light and + dark) follow the color mode, `lang` picks label names and defaults to the + site language (Chinese as `zh-Hans` or `zh-Hant`), and `max_data_zoom` + (default 15) is the deepest zoom the tiles hold. `attribution` is still + required. A basemap whose first tiles all fail hides the canvas and keeps + the place list, as raster tiles do; setting both `tiles` and + `protomaps.url` warns and uses Protomaps. ## [1.8.0] — 2026-11-28 diff --git a/VENDOR.json b/VENDOR.json index 4c8e146c..7c889ae5 100644 --- a/VENDOR.json +++ b/VENDOR.json @@ -1,12 +1,12 @@ { "schema": 1, - "generated": "2026-11-28", + "generated": "2026-11-29", "hash": "sha256", "trees": [ { "path": "assets/third_party", - "files": 131, - "sha256": "bebaa6c3d82905d89f831220cf967ec90477875a4b789faf2d42f56c9433bdc0" + "files": 133, + "sha256": "1cfb993689d3569a48d26cd0cd1b9584a9c9867ac47bd4de6c9431cee786c7d5" }, { "path": "static/webfonts", @@ -615,6 +615,24 @@ } ], "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==" + }, + { + "name": "protomaps-leaflet", + "version": "5.1.0", + "source": "https://registry.npmjs.org/protomaps-leaflet/-/protomaps-leaflet-5.1.0.tgz", + "integrity": "sha512-N0YY1Gbw5nZ9n8VUOvwHKm/w3zhTTuaZEeMZl8doHemeM4ujGPp2otI6t4Sgqrz8iM4svx2rpG1Q17rHkOWSaA==", + "license": "BSD-3-Clause AND ISC AND MIT", + "licenseFiles": [ + "assets/third_party/protomaps-leaflet/LICENSES.txt" + ], + "build": "bin/vendor/build.mjs", + "lockfile": "bin/vendor/package-lock.json", + "artifacts": [ + { + "path": "assets/third_party/protomaps-leaflet/protomaps-leaflet.min.js", + "sha256": "bec647d021df05b448019e515fb823aad781898d1196777f4200add90955ec16" + } + ] } ] } diff --git a/assets/js/content-components.js b/assets/js/content-components.js index eb2a4d32..da4f23da 100644 --- a/assets/js/content-components.js +++ b/assets/js/content-components.js @@ -109,7 +109,7 @@ if (!component || component.begun) return; component.begun = true; if (observer) observer.unobserve(root); - loadEngine(component.engine, component.ready).then( + (component.load ? component.load() : loadEngine(component.engine, component.ready)).then( function () { unmounted.delete(root); component.mount(root); @@ -395,10 +395,12 @@ } // The hosts a click-to-load map may contact: light and dark tiles alike, with - // `{s}` shown as `*` because the request rotates through every subdomain. + // `{s}` shown as `*` because the request rotates through every subdomain, + // or the one host a Protomaps basemap reads its vector tiles from. function tileHosts(site) { var hosts = []; - [site && site.tiles, site && site.darkTiles].forEach(function (template) { + var protomaps = site && site.protomaps; + [site && site.tiles, site && site.darkTiles, protomaps && protomaps.url].forEach(function (template) { if (!template) return; try { var host = new URL(template.replace(/\{s\}/g, '*')).host.replace(/%2a/gi, '*'); @@ -470,11 +472,16 @@ var data = configOf(root, '[data-td-map-source]'); var site = configOf(document, '[data-td-map-config]'); var canvas = root.querySelector('[data-td-map-canvas]'); - if (!L || !data || !site || !site.tiles || !canvas) return; + // A Protomaps basemap is one vector source drawn in a light and a dark + // flavor; protomaps-leaflet renders it on Leaflet's canvas grid. + var vector = site && site.protomaps && site.protomaps.url ? site.protomaps : null; + if (vector && !(window.protomapsL && typeof window.protomapsL.leafletLayer === 'function')) return; + if (!L || !data || !site || !(site.tiles || vector) || !canvas) return; var places = Array.isArray(data.places) ? data.places : []; if (!places.length) return; canvas.hidden = false; - if (!site.darkTiles && typeof canvas.setAttribute === 'function') { + var hasDark = vector ? !!vector.darkFlavor : !!site.darkTiles; + if (!hasDark && typeof canvas.setAttribute === 'function') { canvas.setAttribute('data-td-map-light-tiles', ''); } var reduced = !!( @@ -543,34 +550,78 @@ if (typeof map.remove === 'function') map.remove(); }, 0); } + // protomaps-leaflet logs a failed vector tile and still paints the + // flavor's background, so Leaflet sees no tile error. Count the source's + // answers instead; an aborted request (a zoom moved on) is neither. + function countVectorTiles(current, counts) { + var views = current && current.views; + if (!views || typeof views.forEach !== 'function') return; + views.forEach(function (view) { + var get = view && view.getDisplayTile; + if (typeof get !== 'function') return; + view.getDisplayTile = function () { + return get.apply(view, arguments).then( + function (value) { + counts.loaded += 1; + return value; + }, + function (error) { + if (!error || error.name !== 'AbortError') counts.failed += 1; + throw error; + }, + ); + }; + }); + } function tiles() { if (hidden) return; - var dark = currentTheme() === 'dark' && !!site.darkTiles && !darkFailed; - var nextUrl = dark ? site.darkTiles : site.tiles; + var dark = currentTheme() === 'dark' && hasDark && !darkFailed; + var nextUrl = vector + ? dark + ? vector.darkFlavor + : vector.flavor || 'light' + : dark + ? site.darkTiles + : site.tiles; if (layer && nextUrl === currentUrl) return; if (layer) map.removeLayer(layer); currentUrl = nextUrl; - var tileOpts = { maxZoom: site.maxZoom || 19 }; - if (site.subdomains) tileOpts.subdomains = site.subdomains; - var loaded = 0; - var failed = 0; - var current = L.tileLayer(nextUrl, tileOpts); + var counts = { loaded: 0, failed: 0 }; + var current; + if (vector) { + current = window.protomapsL.leafletLayer({ + url: vector.url, + flavor: nextUrl, + lang: vector.lang || 'en', + maxDataZoom: vector.maxDataZoom || 15, + maxZoom: site.maxZoom || 19, + // The map's own control carries the site's attribution. + attribution: '', + }); + countVectorTiles(current, counts); + } else { + var tileOpts = { maxZoom: site.maxZoom || 19 }; + if (site.subdomains) tileOpts.subdomains = site.subdomains; + current = L.tileLayer(nextUrl, tileOpts); + } layer = current; if (typeof current.on === 'function') { - current.on('tileload', function () { - loaded += 1; - }); - current.on('tileerror', function () { - failed += 1; - }); + if (!vector) { + current.on('tileload', function () { + counts.loaded += 1; + }); + current.on('tileerror', function () { + counts.failed += 1; + }); + } current.on('load', function () { - if (!hidden && current === layer && loaded === 0 && failed > 0) layerFailed(dark); + if (!hidden && current === layer && counts.loaded === 0 && counts.failed > 0) layerFailed(dark); }); } current.addTo(map); } tiles(); - if (site.darkTiles) watchTheme(tiles); + if (hasDark) watchTheme(tiles); var points = []; var markers = []; places.forEach(function (place, index) { @@ -766,14 +817,27 @@ var mapSite = configOf(document, '[data-td-map-config]'); var mapClickOnly = !!(mapSite && mapSite.loading === 'click'); var mapHost = mapClickOnly ? tileHosts(mapSite).join(', ') : ''; + var mapVector = !!(mapSite && mapSite.protomaps && mapSite.protomaps.url); + function leafletReady() { + return !!window.L; + } + function protomapsReady() { + return !!window.protomapsL; + } document.querySelectorAll('[data-td-map]').forEach(function (root) { var component = { engine: 'leaflet', - ready: function () { - return !!window.L; - }, + ready: leafletReady, mount: initMap, }; + // protomaps-leaflet extends Leaflet's grid layer, so it loads second. + if (mapVector) { + component.load = function () { + return loadEngine('leaflet', leafletReady).then(function () { + return loadEngine('protomaps', protomapsReady); + }); + }; + } if (mapClickOnly) { var canvas = root.querySelector('[data-td-map-canvas]'); if (!canvas || typeof root.insertBefore !== 'function') return; diff --git a/assets/third_party/protomaps-leaflet/LICENSES.txt b/assets/third_party/protomaps-leaflet/LICENSES.txt new file mode 100644 index 00000000..d408d1a2 --- /dev/null +++ b/assets/third_party/protomaps-leaflet/LICENSES.txt @@ -0,0 +1,242 @@ +@mapbox/point-geometry 1.1.0 (ISC) +LICENSE +Copyright (c) 2024, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +@mapbox/vector-tile 2.0.5 (BSD-3-Clause) +LICENSE.txt +Copyright (c) 2024, Mapbox + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of Mapbox nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +@protomaps/basemaps 5.7.2 (BSD-3-Clause) +README.md +[TypeScript docs](https://maps.protomaps.com/typedoc/) + +## Usage + +Prepare your environment with: + +``` +nvm use +npm ci +``` + +## Generate JSON styles + +To generate a style.json for a default flavor and language: + +``` +npm run generate_style style.json https://example.com/tilejson.json light en +``` + +color2k 2.0.3 (MIT) +LICENSE +MIT License + +Copyright (c) 2020 Rico Kahler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +pbf 4.0.2 (BSD-3-Clause) +LICENSE +Copyright (c) 2024, Mapbox +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of pbf nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +pmtiles 3.2.1 (BSD-3-Clause) +README.md +# PMTiles for Browsers + NodeJS + +See the [JavaScript API docs](https://pmtiles.io/typedoc/) + +the [PMTiles](https://www.npmjs.com/package/pmtiles) package can be included via script tag or ES6 module: + +```html + +``` + +All the PMTiles exports are available under the global `pmtiles` variable e.g. `pmtiles.PMTiles`. + +As an ES6 module: `npm add pmtiles` + +```js +import { PMTiles } from "pmtiles"; +``` + +### Leaflet: Raster tileset + +Example of a raster PMTiles archive displayed in Leaflet: + +```js +import { PMTiles, leafletRasterLayer } from "pmtiles"; +const p = new PMTiles('example.pmtiles') +leafletRasterLayer(p,{attribution:'© OpenStreetMap'}).addTo(map) +```` + +[Live example](https://pmtiles.io/examples/leaflet.html) | [Code](https://github.com/protomaps/PMTiles/blob/main/js/examples/leaflet.html) + +### Leaflet: Vector tileset + +See [protomaps-leaflet](https://github.com/protomaps/protomaps-leaflet) + +## MapLibre GL JS + +Example of a PMTiles archive displayed in MapLibre GL JS: + +```js + import { Protocol } from "pmtiles"; +let protocol = new Protocol(); +maplibregl.addProtocol("pmtiles",protocol.tile); +var style = { +"version": 8, +"sources": { + "example_source": { + "type": "vector", + "url": "pmtiles://https://example.com/example.pmtiles", + "attribution": '© OpenStreetMap' + ... +``` + +[Live example](https://pmtiles.io/examples/maplibre.html) | [Code](https://github.com/protomaps/PMTiles/blob/main/js/examples/maplibre.html) + +# CORS + +See the [Protomaps Docs on Cloud Storage](https://protomaps.com/docs/pmtiles/cloud-storage) for uploading and configuring CORS for Cloudflare R2, Amazon S3, Google Cloud Storage and more. + + +potpack 1.0.2 (ISC) +LICENSE +ISC License + +Copyright (c) 2018, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + + +protomaps-leaflet 5.1.0 (BSD-3-Clause) +LICENSE +Copyright 2021-2024 Protomaps LLC + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +rbush 3.0.1 (MIT) +LICENSE +MIT License + +Copyright (c) 2016 Vladimir Agafonkin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/assets/third_party/protomaps-leaflet/protomaps-leaflet.min.js b/assets/third_party/protomaps-leaflet/protomaps-leaflet.min.js new file mode 100644 index 00000000..c8e535d5 --- /dev/null +++ b/assets/third_party/protomaps-leaflet/protomaps-leaflet.min.js @@ -0,0 +1,22 @@ +var protomapsL=(()=>{var Yi=Object.create;var Le=Object.defineProperty;var Xi=Object.getOwnPropertyDescriptor;var Ii=Object.getOwnPropertyNames;var Ri=Object.getPrototypeOf,Ai=Object.prototype.hasOwnProperty;var Ui=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Hi=(i,e)=>{for(var t in e)Le(i,t,{get:e[t],enumerable:!0})},mt=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ii(e))!Ai.call(i,a)&&a!==t&&Le(i,a,{get:()=>e[a],enumerable:!(r=Xi(e,a))||r.enumerable});return i};var Ni=(i,e,t)=>(t=i!=null?Yi(Ri(i)):{},mt(e||!i||!i.__esModule?Le(t,"default",{value:i,enumerable:!0}):t,i)),qi=i=>mt(Le({},"__esModule",{value:!0}),i);var Rt=Ui((Ke,Ge)=>{(function(i,e){typeof Ke=="object"&&typeof Ge<"u"?Ge.exports=e():typeof define=="function"&&define.amd?define(e):(i=i||self).RBush=e()})(Ke,function(){"use strict";function i(f,h,p,x,y){(function _(k,w,z,F,T){for(;F>z;){if(F-z>600){var C=F-z+1,j=w-z+1,ne=Math.log(C),ee=.5*Math.exp(2*ne/3),R=.5*Math.sqrt(ne*ee*(C-ee)/C)*(j-C/2<0?-1:1),W=Math.max(z,Math.floor(w-j*ee/C+R)),Se=Math.min(F,Math.floor(w+(C-j)*ee/C+R));_(k,w,W,Se,T)}var V=k[w],oe=z,A=F;for(e(k,z,w),T(k[F],V)>0&&e(k,z,F);oe0;)A--}T(k[z],V)===0?e(k,z,A):e(k,++A,F),A<=w&&(z=A+1),w<=A&&(F=A-1)}})(f,h,p||0,x||f.length-1,y||t)}function e(f,h,p){var x=f[h];f[h]=f[p],f[p]=x}function t(f,h){return fh?1:0}var r=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function a(f,h,p){if(!p)return h.indexOf(f);for(var x=0;x=f.minX&&h.maxY>=f.minY}function b(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function M(f,h,p,x,y){for(var _=[h,p];_.length;)if(!((p=_.pop())-(h=_.pop())<=x)){var k=h+Math.ceil((p-h)/x/2)*x;i(f,k,h,p,y),_.push(h,k,k,p)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(f){var h=this.data,p=[];if(!v(f,h))return p;for(var x=this.toBBox,y=[];h;){for(var _=0;_=0&&y[h].children.length>this._maxEntries;)this._split(y,h),h--;this._adjustParentBBoxes(x,y,h)},r.prototype._split=function(f,h){var p=f[h],x=p.children.length,y=this._minEntries;this._chooseSplitAxis(p,y,x);var _=this._chooseSplitIndex(p,y,x),k=b(p.children.splice(_,p.children.length-_));k.height=p.height,k.leaf=p.leaf,n(p,this.toBBox),n(k,this.toBBox),h?f[h-1].children.push(k):this._splitRoot(p,k)},r.prototype._splitRoot=function(f,h){this.data=b([f,h]),this.data.height=f.height+1,this.data.leaf=!1,n(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(f,h,p){for(var x,y,_,k,w,z,F,T=1/0,C=1/0,j=h;j<=p-h;j++){var ne=o(f,0,j,this.toBBox),ee=o(f,j,p,this.toBBox),R=(y=ne,_=ee,k=void 0,w=void 0,z=void 0,F=void 0,k=Math.max(y.minX,_.minX),w=Math.max(y.minY,_.minY),z=Math.min(y.maxX,_.maxX),F=Math.min(y.maxY,_.maxY),Math.max(0,z-k)*Math.max(0,F-w)),W=d(ne)+d(ee);R=h;T--){var C=f.children[T];l(k,f.leaf?y(C):C),w+=u(k)}return w},r.prototype._adjustParentBBoxes=function(f,h,p){for(var x=p;x>=0;x--)l(h[x],f)},r.prototype._condense=function(f){for(var h=f.length-1,p=void 0;h>=0;h--)f[h].children.length===0?h>0?(p=f[h-1].children).splice(p.indexOf(f[h]),1):this.clear():n(f[h],this.toBBox)},r})});var Wa={};Hi(Wa,{leafletLayer:()=>$i});function S(i,e){this.x=i,this.y=e}S.prototype={clone(){return new S(this.x,this.y)},add(i){return this.clone()._add(i)},sub(i){return this.clone()._sub(i)},multByPoint(i){return this.clone()._multByPoint(i)},divByPoint(i){return this.clone()._divByPoint(i)},mult(i){return this.clone()._mult(i)},div(i){return this.clone()._div(i)},rotate(i){return this.clone()._rotate(i)},rotateAround(i,e){return this.clone()._rotateAround(i,e)},matMult(i){return this.clone()._matMult(i)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(i){return this.x===i.x&&this.y===i.y},dist(i){return Math.sqrt(this.distSqr(i))},distSqr(i){let e=i.x-this.x,t=i.y-this.y;return e*e+t*t},angle(){return Math.atan2(this.y,this.x)},angleTo(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith(i){return this.angleWithSep(i.x,i.y)},angleWithSep(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult(i){let e=i[0]*this.x+i[1]*this.y,t=i[2]*this.x+i[3]*this.y;return this.x=e,this.y=t,this},_add(i){return this.x+=i.x,this.y+=i.y,this},_sub(i){return this.x-=i.x,this.y-=i.y,this},_mult(i){return this.x*=i,this.y*=i,this},_div(i){return this.x/=i,this.y/=i,this},_multByPoint(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint(i){return this.x/=i.x,this.y/=i.y,this},_unit(){return this._div(this.mag()),this},_perp(){let i=this.y;return this.y=this.x,this.x=-i,this},_rotate(i){let e=Math.cos(i),t=Math.sin(i),r=e*this.x-t*this.y,a=t*this.x+e*this.y;return this.x=r,this.y=a,this},_rotateAround(i,e){let t=Math.cos(i),r=Math.sin(i),a=e.x+t*(this.x-e.x)-r*(this.y-e.y),n=e.y+r*(this.x-e.x)+t*(this.y-e.y);return this.x=a,this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:S};S.convert=function(i){if(i instanceof S)return i;if(Array.isArray(i))return new S(+i[0],+i[1]);if(i.x!==void 0&&i.y!==void 0)return new S(+i.x,+i.y);throw new Error("Expected [x, y] or {x, y} point format")};var Oi=Object.defineProperty,ie=(i,e)=>Oi(i,"name",{value:e,configurable:!0});function Y(i,e){let t="script";return i==="name"?t="script":i==="name2"?t="script2":i==="name3"&&(t="script3"),[["coalesce",["get",`pgf:${i}`],["get",i]],{"text-font":["case",["==",["get",t],"Devanagari"],["literal",["Noto Sans Devanagari Regular v1"]],["literal",[e||"Noto Sans Regular"]]]}]}ie(Y,"get_name_block");function te(i,e,t){let r="name";return t==="name"?r="":t==="name2"?r="2":t==="name3"&&(r="3"),e==="Latin"?["has",`script${r}`]:i==="ja"?["all",["!=",["get",`script${r}`],"Han"],["!=",["get",`script${r}`],"Hiragana"],["!=",["get",`script${r}`],"Katakana"],["!=",["get",`script${r}`],"Mixed-Japanese"]]:["!=",["get",`script${r}`],e]}ie(te,"is_not_in_target_script");function K(i){return i==="Devanagari"?{"text-font":["literal",["Noto Sans Devanagari Regular v1"]]}:{}}ie(K,"get_font_formatting");function Ie(i){let e=Wi.find(t=>t.lang===i);return e===void 0?"Latin":e.script}ie(Ie,"get_default_script");function pt(i,e){let t=e||Ie(i),r;return t==="Devanagari"?r="pgf:":r="",["format",["coalesce",["get",`${r}name:${i}`],["get","name:en"]],K(t)]}ie(pt,"get_country_name");function Z(i,e,t){let r=e||Ie(i),a;return r==="Devanagari"?a="pgf:":a="",["case",["all",["any",["has","name"],["has","pgf:name"]],["!",["any",["has","name2"],["has","pgf:name2"]]],["!",["any",["has","name3"],["has","pgf:name3"]]]],["case",te(i,r,"name"),["case",["any",["is-supported-script",["get","name"]],["has","pgf:name"]],["format",["coalesce",["get",`${a}name:${i}`],["get","name:en"]],K(r),` +`,{},["case",["all",["!",["has",`${a}name:${i}`]],["has","name:en"],["!",["has","script"]]],"",["coalesce",["get","pgf:name"],["get","name"]]],{"text-font":["case",["==",["get","script"],"Devanagari"],["literal",["Noto Sans Devanagari Regular v1"]],["literal",[t||"Noto Sans Regular"]]]}],["get","name:en"]],["format",["coalesce",["get",`${a}name:${i}`],["get","pgf:name"],["get","name"]],K(r)]],["all",["any",["has","name"],["has","pgf:name"]],["any",["has","name2"],["has","pgf:name2"]],["!",["any",["has","name3"],["has","pgf:name3"]]]],["case",["all",te(i,r,"name"),te(i,r,"name2")],["format",["get",`${a}name:${i}`],K(r),` +`,{},...Y("name",t),` +`,{},...Y("name2",t)],["case",te(i,r,"name2"),["format",["coalesce",["get",`${a}name:${i}`],["get","pgf:name"],["get","name"]],K(r),` +`,{},...Y("name2",t)],["format",["coalesce",["get",`${a}name:${i}`],["get","pgf:name2"],["get","name2"]],K(r),` +`,{},...Y("name",t)]]],["case",["all",te(i,r,"name"),te(i,r,"name2"),te(i,r,"name3")],["format",["get",`${a}name:${i}`],K(r),` +`,{},...Y("name",t),` +`,{},...Y("name2",t),` +`,{},...Y("name3",t)],["case",["!",te(i,r,"name")],["format",["coalesce",["get",`${a}name:${i}`],["get","pgf:name"],["get","name"]],K(r),` +`,{},...Y("name2",t),` +`,{},...Y("name3",t)],["!",te(i,r,"name2")],["format",["coalesce",["get",`${a}name:${i}`],["get","pgf:name2"],["get","name2"]],K(r),` +`,{},...Y("name",t),` +`,{},...Y("name3",t)],["format",["coalesce",["get",`${a}name:${i}`],["get","pgf:name3"],["get","name3"]],K(r),` +`,{},...Y("name",t),` +`,{},...Y("name2",t)]]]]}ie(Z,"get_multiline_name");var Wi=[{lang:"ar",full_name:"Arabic",script:"Arabic"},{lang:"cs",full_name:"Czech",script:"Latin"},{lang:"bg",full_name:"Bulgarian",script:"Cyrillic"},{lang:"da",full_name:"Danish",script:"Latin"},{lang:"de",full_name:"German",script:"Latin"},{lang:"el",full_name:"Greek",script:"Greek"},{lang:"en",full_name:"English",script:"Latin"},{lang:"es",full_name:"Spanish",script:"Latin"},{lang:"et",full_name:"Estonian",script:"Latin"},{lang:"fa",full_name:"Persian",script:"Arabic"},{lang:"fi",full_name:"Finnish",script:"Latin"},{lang:"fr",full_name:"French",script:"Latin"},{lang:"ga",full_name:"Irish",script:"Latin"},{lang:"he",full_name:"Hebrew",script:"Hebrew"},{lang:"hi",full_name:"Hindi",script:"Devanagari"},{lang:"hr",full_name:"Croatian",script:"Latin"},{lang:"hu",full_name:"Hungarian",script:"Latin"},{lang:"id",full_name:"Indonesian",script:"Latin"},{lang:"it",full_name:"Italian",script:"Latin"},{lang:"ja",full_name:"Japanese",script:""},{lang:"ko",full_name:"Korean",script:"Hangul"},{lang:"lt",full_name:"Lithuanian",script:"Latin"},{lang:"lv",full_name:"Latvian",script:"Latin"},{lang:"ne",full_name:"Nepali",script:"Devanagari"},{lang:"nl",full_name:"Dutch",script:"Latin"},{lang:"no",full_name:"Norwegian",script:"Latin"},{lang:"mr",full_name:"Marathi",script:"Devanagari"},{lang:"mt",full_name:"Maltese",script:"Latin"},{lang:"pl",full_name:"Polish",script:"Latin"},{lang:"pt",full_name:"Portuguese",script:"Latin"},{lang:"ro",full_name:"Romanian",script:"Latin"},{lang:"ru",full_name:"Russian",script:"Cyrillic"},{lang:"sk",full_name:"Slovak",script:"Latin"},{lang:"sl",full_name:"Slovenian",script:"Latin"},{lang:"sv",full_name:"Swedish",script:"Latin"},{lang:"tr",full_name:"Turkish",script:"Latin"},{lang:"uk",full_name:"Ukrainian",script:"Cyrillic"},{lang:"ur",full_name:"Urdu",script:"Arabic"},{lang:"vi",full_name:"Vietnamese",script:"Latin"},{lang:"zh-Hans",full_name:"Chinese (Simplified)",script:"Han"},{lang:"zh-Hant",full_name:"Chinese (Traditional)",script:"Han"}];function gt(i,e){return[{id:"background",type:"background",paint:{"background-color":e.background}},{id:"earth",type:"fill",filter:["==","$type","Polygon"],source:i,"source-layer":"earth",paint:{"fill-color":e.earth}},...e.landcover?[{id:"landcover",type:"fill",source:i,"source-layer":"landcover",paint:{"fill-color":["match",["get","kind"],"grassland",e.landcover.grassland,"barren",e.landcover.barren,"urban_area",e.landcover.urban_area,"farmland",e.landcover.farmland,"glacier",e.landcover.glacier,"scrub",e.landcover.scrub,e.landcover.forest],"fill-opacity":["interpolate",["linear"],["zoom"],5,1,7,0]}}]:[],{id:"landuse_park",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course","wood","scrub","grassland","grass","glacier","sand","military","naval_base","airfield"],paint:{"fill-opacity":["interpolate",["linear"],["zoom"],6,0,11,1],"fill-color":["case",["in",["get","kind"],["literal",["national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course"]]],e.park_b,["==",["get","kind"],"wood"],e.wood_b,["in",["get","kind"],["literal",["scrub","grassland","grass"]]],e.scrub_b,["==",["get","kind"],"glacier"],e.glacier,["==",["get","kind"],"sand"],e.sand,["in",["get","kind"],["literal",["military","naval_base","airfield"]]],e.zoo,e.earth]}},{id:"landuse_urban_green",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","allotments","village_green","playground"],paint:{"fill-color":e.park_b,"fill-opacity":.7}},{id:"landuse_hospital",type:"fill",source:i,"source-layer":"landuse",filter:["==","kind","hospital"],paint:{"fill-color":e.hospital}},{id:"landuse_industrial",type:"fill",source:i,"source-layer":"landuse",filter:["==","kind","industrial"],paint:{"fill-color":e.industrial}},{id:"landuse_school",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","school","university","college"],paint:{"fill-color":e.school}},{id:"landuse_beach",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","beach"],paint:{"fill-color":e.beach}},{id:"landuse_zoo",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","zoo"],paint:{"fill-color":e.zoo}},{id:"landuse_aerodrome",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","aerodrome"],paint:{"fill-color":e.aerodrome}},{id:"roads_runway",type:"line",source:i,"source-layer":"roads",filter:["==","kind_detail","runway"],paint:{"line-color":e.runway,"line-width":["interpolate",["exponential",1.6],["zoom"],10,0,12,4,18,30]}},{id:"roads_taxiway",type:"line",source:i,"source-layer":"roads",minzoom:13,filter:["==","kind_detail","taxiway"],paint:{"line-color":e.runway,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,15,6]}},{id:"landuse_runway",type:"fill",source:i,"source-layer":"landuse",filter:["any",["in","kind","runway","taxiway"]],paint:{"fill-color":e.runway}},{id:"water",type:"fill",filter:["==","$type","Polygon"],source:i,"source-layer":"water",paint:{"fill-color":e.water}},{id:"water_stream",type:"line",source:i,"source-layer":"water",minzoom:14,filter:["in","kind","stream"],paint:{"line-color":e.water,"line-width":.5}},{id:"water_river",type:"line",source:i,"source-layer":"water",minzoom:9,filter:["in","kind","river"],paint:{"line-color":e.water,"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1,18,12]}},{id:"landuse_pedestrian",type:"fill",source:i,"source-layer":"landuse",filter:["in","kind","pedestrian","dam"],paint:{"fill-color":e.pedestrian}},{id:"landuse_pier",type:"fill",source:i,"source-layer":"landuse",filter:["==","kind","pier"],paint:{"fill-color":e.pier}},{id:"roads_tunnels_other_casing",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["in","kind","other","path"]],paint:{"line-color":e.tunnel_other_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_tunnels_minor_casing",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","minor_road"]],paint:{"line-color":e.tunnel_minor_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_tunnels_link_casing",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["has","is_link"]],paint:{"line-color":e.tunnel_link_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_tunnels_major_casing",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":e.tunnel_major_casing,"line-dasharray":[3,2],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_tunnels_highway_casing",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":e.tunnel_highway_casing,"line-dasharray":[6,.5],"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_tunnels_other",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["in","kind","other","path"]],paint:{"line-color":e.tunnel_other,"line-dasharray":[4.5,.5],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_tunnels_minor",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","minor_road"]],paint:{"line-color":e.tunnel_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_tunnels_link",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["has","is_link"]],paint:{"line-color":e.tunnel_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_tunnels_major",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==","kind","major_road"]],paint:{"line-color":e.tunnel_major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_tunnels_highway",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_tunnel"],["==",["get","kind"],"highway"],["!",["has","is_link"]]],paint:{"line-color":e.tunnel_highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}},{id:"buildings",type:"fill",source:i,"source-layer":"buildings",filter:["in","kind","building","building_part"],paint:{"fill-color":e.buildings,"fill-opacity":.5}},{id:"roads_pier",type:"line",source:i,"source-layer":"roads",filter:["==","kind_detail","pier"],paint:{"line-color":e.pier,"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,.5,20,16]}},{id:"roads_minor_service_casing",type:"line",source:i,"source-layer":"roads",minzoom:13,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["==","kind_detail","service"]],paint:{"line-color":e.minor_service_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,18,8],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,.8]}},{id:"roads_minor_casing",type:"line",source:i,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["!=","kind_detail","service"]],paint:{"line-color":e.minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1]}},{id:"roads_link_casing",type:"line",source:i,"source-layer":"roads",minzoom:13,filter:["has","is_link"],paint:{"line-color":e.minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1.5]}},{id:"roads_major_casing_late",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":e.major_casing_late,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_highway_casing_late",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":e.highway_casing_late,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_other",type:"line",source:i,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["in","kind","other","path"],["!=","kind_detail","pier"]],paint:{"line-color":e.other,"line-width":["interpolate",["exponential",1.6],["zoom"],14,.5,20,12]}},{id:"roads_link",type:"line",source:i,"source-layer":"roads",filter:["has","is_link"],paint:{"line-color":e.link,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_minor_service",type:"line",source:i,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["==","kind_detail","service"]],paint:{"line-color":e.minor_service,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,18,8]}},{id:"roads_minor",type:"line",source:i,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","minor_road"],["!=","kind_detail","service"]],paint:{"line-color":["interpolate",["exponential",1.6],["zoom"],11,e.minor_a,16,e.minor_b],"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_major_casing_early",type:"line",source:i,"source-layer":"roads",maxzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":e.major_casing_early,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,13],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1]}},{id:"roads_major",type:"line",source:i,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":e.major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_highway_casing_early",type:"line",source:i,"source-layer":"roads",maxzoom:12,filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":e.highway_casing_early,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1]}},{id:"roads_highway",type:"line",source:i,"source-layer":"roads",filter:["all",["!has","is_tunnel"],["!has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":e.highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}},{id:"roads_rail",type:"line",source:i,"source-layer":"roads",filter:["==","kind","rail"],paint:{"line-dasharray":[.3,.75],"line-opacity":.5,"line-color":e.railway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,.15,18,9]}},{id:"boundaries_country",type:"line",source:i,"source-layer":"boundaries",filter:["<=","kind_detail",2],paint:{"line-color":e.boundaries,"line-width":.7,"line-dasharray":["step",["zoom"],["literal",[2,0]],4,["literal",[2,1]]]}},{id:"boundaries",type:"line",source:i,"source-layer":"boundaries",filter:[">","kind_detail",2],paint:{"line-color":e.boundaries,"line-width":.4,"line-dasharray":["step",["zoom"],["literal",[2,0]],4,["literal",[2,1]]]}},{id:"roads_bridges_other_casing",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["in","kind","other","path"]],paint:{"line-color":e.bridges_other_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_bridges_link_casing",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["has","is_link"]],paint:{"line-color":e.bridges_minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],12,0,12.5,1.5]}},{id:"roads_bridges_minor_casing",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","minor_road"]],paint:{"line-color":e.bridges_minor_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11],"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,.8]}},{id:"roads_bridges_major_casing",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":e.bridges_major_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,.5,18,10],"line-width":["interpolate",["exponential",1.6],["zoom"],9,0,9.5,1.5]}},{id:"roads_bridges_other",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["in","kind","other","path"]],paint:{"line-color":e.bridges_other,"line-dasharray":[2,1],"line-width":["interpolate",["exponential",1.6],["zoom"],14,0,20,7]}},{id:"roads_bridges_minor",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","minor_road"]],paint:{"line-color":e.bridges_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],11,0,12.5,.5,15,2,18,11]}},{id:"roads_bridges_link",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["has","is_link"]],paint:{"line-color":e.bridges_minor,"line-width":["interpolate",["exponential",1.6],["zoom"],13,0,13.5,1,18,11]}},{id:"roads_bridges_major",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","major_road"]],paint:{"line-color":e.bridges_major,"line-width":["interpolate",["exponential",1.6],["zoom"],6,0,12,1.6,15,3,18,13]}},{id:"roads_bridges_highway_casing",type:"line",source:i,"source-layer":"roads",minzoom:12,filter:["all",["has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":e.bridges_highway_casing,"line-gap-width":["interpolate",["exponential",1.6],["zoom"],3,0,3.5,.5,18,15],"line-width":["interpolate",["exponential",1.6],["zoom"],7,0,7.5,1,20,15]}},{id:"roads_bridges_highway",type:"line",source:i,"source-layer":"roads",filter:["all",["has","is_bridge"],["==","kind","highway"],["!has","is_link"]],paint:{"line-color":e.bridges_highway,"line-width":["interpolate",["exponential",1.6],["zoom"],3,0,6,1.1,12,1.6,15,5,18,15]}}]}ie(gt,"nolabels_layers");function yt(i,e,t,r){return[{id:"address_label",type:"symbol",source:i,"source-layer":"buildings",minzoom:18,filter:["==","kind","address"],layout:{"symbol-placement":"point","text-font":[e.italic||"Noto Sans Italic"],"text-field":["get","addr_housenumber"],"text-size":12},paint:{"text-color":e.address_label,"text-halo-color":e.address_label_halo,"text-halo-width":1}},{id:"water_waterway_label",type:"symbol",source:i,"source-layer":"water",minzoom:13,filter:["in","kind","river","stream"],layout:{"symbol-placement":"line","text-font":[e.italic||"Noto Sans Italic"],"text-field":Z(t,r,e.regular),"text-size":12,"text-letter-spacing":.2},paint:{"text-color":e.ocean_label,"text-halo-color":e.water,"text-halo-width":1}},{id:"roads_oneway",type:"symbol",source:i,"source-layer":"roads",minzoom:16,filter:["==",["get","oneway"],"yes"],layout:{"symbol-placement":"line","icon-image":"arrow","icon-rotate":90,"symbol-spacing":100}},{id:"roads_labels_minor",type:"symbol",source:i,"source-layer":"roads",minzoom:15,filter:["in","kind","minor_road","other","path"],layout:{"symbol-sort-key":["get","min_zoom"],"symbol-placement":"line","text-font":[e.regular||"Noto Sans Regular"],"text-field":Z(t,r,e.regular),"text-size":12},paint:{"text-color":e.roads_label_minor,"text-halo-color":e.roads_label_minor_halo,"text-halo-width":1}},{id:"water_label_ocean",type:"symbol",source:i,"source-layer":"water",filter:["in","kind","sea","ocean","bay","strait","fjord"],layout:{"text-font":[e.italic||"Noto Sans Italic"],"text-field":Z(t,r,e.regular),"text-size":["interpolate",["linear"],["zoom"],3,10,10,12],"text-letter-spacing":.1,"text-max-width":9,"text-transform":"uppercase"},paint:{"text-color":e.ocean_label,"text-halo-width":1,"text-halo-color":e.water}},{id:"earth_label_islands",type:"symbol",source:i,"source-layer":"earth",filter:["in","kind","island"],layout:{"text-font":[e.italic||"Noto Sans Italic"],"text-field":Z(t,r,e.regular),"text-size":10,"text-letter-spacing":.1,"text-max-width":8},paint:{"text-color":e.subplace_label,"text-halo-color":e.subplace_label_halo,"text-halo-width":1}},{id:"water_label_lakes",type:"symbol",source:i,"source-layer":"water",filter:["in","kind","lake","water"],layout:{"text-font":[e.italic||"Noto Sans Italic"],"text-field":Z(t,r,e.regular),"text-size":["interpolate",["linear"],["zoom"],3,10,6,12,10,12],"text-letter-spacing":.1,"text-max-width":9},paint:{"text-color":e.ocean_label,"text-halo-color":e.water,"text-halo-width":1}},{id:"roads_shields",type:"symbol",source:i,"source-layer":"roads",filter:["all",["in",["get","kind"],["literal",["highway","major_road"]]],["has","shield_text"],["<=",["length",["get","shield_text"]],5]],layout:{"icon-image":["match",["get","network"],"US:I",["concat","US:I-",["length",["get","shield_text"]],"char"],"NL:S-road",["concat","NL:S-road-",["length",["get","shield_text"]],"char"],["concat","generic_shield-",["length",["get","shield_text"]],"char"]],"text-field":["get","shield_text"],"text-font":[e.bold||"Noto Sans Medium"],"text-size":8,"icon-size":.8,"symbol-placement":"line","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport"},paint:{"text-color":e.roads_label_major}},{id:"roads_labels_major",type:"symbol",source:i,"source-layer":"roads",minzoom:11,filter:["in","kind","highway","major_road"],layout:{"symbol-sort-key":["get","min_zoom"],"symbol-placement":"line","text-font":[e.regular||"Noto Sans Regular"],"text-field":Z(t,r,e.regular),"text-size":12},paint:{"text-color":e.roads_label_major,"text-halo-color":e.roads_label_major_halo,"text-halo-width":1}},...e.pois?[{id:"pois",type:"symbol",source:i,"source-layer":"pois",filter:["all",["in",["get","kind"],["literal",["beach","forest","marina","park","peak","zoo","garden","bench","aerodrome","station","bus_stop","ferry_terminal","stadium","university","library","school","animal","toilets","drinking_water","post_office","building","townhall","restaurant","fast_food","cafe","bar","supermarket","convenience","books","beauty","electronics","clothes","attraction","museum","theatre","artwork"]]],[">=",["zoom"],["+",["get","min_zoom"],0]]],layout:{"icon-image":["match",["get","kind"],"station","train_station",["get","kind"]],"text-font":[e.regular||"Noto Sans Regular"],"text-justify":"auto","text-field":Z(t,r,e.regular),"text-size":["interpolate",["linear"],["zoom"],17,10,19,16],"text-max-width":8,"text-offset":[1.1,0],"text-variable-anchor":["left","right"]},paint:{"text-color":["case",["in",["get","kind"],["literal",["beach","forest","marina","park","peak","zoo","garden","bench"]]],e.pois.green,["in",["get","kind"],["literal",["aerodrome","station","bus_stop","ferry_terminal"]]],e.pois.lapis,["in",["get","kind"],["literal",["stadium","university","library","school","animal","toilets","drinking_water","post_office","building","townhall"]]],e.pois.slategray,["in",["get","kind"],["literal",["supermarket","convenience","books","beauty","electronics","clothes"]]],e.pois.blue,["in",["get","kind"],["literal",["restaurant","fast_food","cafe","bar"]]],e.pois.tangerine,["in",["get","kind"],["literal",["attraction","museum","theatre","artwork"]]],e.pois.pink,e.earth],"text-halo-color":e.earth,"text-halo-width":1}}]:[],{id:"places_subplace",type:"symbol",source:i,"source-layer":"places",filter:["in","kind","neighbourhood","macrohood"],layout:{"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-field":Z(t,r,e.regular),"text-font":[e.regular||"Noto Sans Regular"],"text-max-width":7,"text-letter-spacing":.1,"text-padding":["interpolate",["linear"],["zoom"],5,2,8,4,12,18,15,20],"text-size":["interpolate",["exponential",1.2],["zoom"],11,8,14,14,18,24],"text-transform":"uppercase"},paint:{"text-color":e.subplace_label,"text-halo-color":e.subplace_label_halo,"text-halo-width":1}},{id:"places_region",type:"symbol",source:i,"source-layer":"places",filter:["==","kind","region"],layout:{"symbol-sort-key":["get","sort_key"],"text-field":["step",["zoom"],["coalesce",["get","ref:en"],["get","ref"]],6,Z(t,r,e.regular)],"text-font":[e.regular||"Noto Sans Regular"],"text-size":["interpolate",["linear"],["zoom"],3,11,7,16],"text-radial-offset":.2,"text-anchor":"center","text-transform":"uppercase"},paint:{"text-color":e.state_label,"text-halo-color":e.state_label_halo,"text-halo-width":1}},{id:"places_locality",type:"symbol",source:i,"source-layer":"places",filter:["==","kind","locality"],layout:{"icon-image":["step",["zoom"],["case",["==",["get","capital"],"yes"],"capital","townspot"],8,""],"icon-size":.7,"text-field":Z(t,r,e.regular),"text-font":["case",["<=",["get","min_zoom"],5],["literal",[e.bold||"Noto Sans Medium"]],["literal",[e.regular||"Noto Sans Regular"]]],"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-padding":["interpolate",["linear"],["zoom"],5,3,8,7,12,11],"text-size":["interpolate",["linear"],["zoom"],2,["case",["<",["get","population_rank"],13],8,[">=",["get","population_rank"],13],13,0],4,["case",["<",["get","population_rank"],13],10,[">=",["get","population_rank"],13],15,0],6,["case",["<",["get","population_rank"],12],11,[">=",["get","population_rank"],12],17,0],8,["case",["<",["get","population_rank"],11],11,[">=",["get","population_rank"],11],18,0],10,["case",["<",["get","population_rank"],9],12,[">=",["get","population_rank"],9],20,0],15,["case",["<",["get","population_rank"],8],12,[">=",["get","population_rank"],8],22,0]],"icon-padding":["interpolate",["linear"],["zoom"],0,0,8,4,10,8,12,6,22,2],"text-justify":"auto","text-variable-anchor":["step",["zoom"],["literal",["bottom","left","right","top"]],8,["literal",["center"]]],"text-radial-offset":.3},paint:{"text-color":e.city_label,"text-halo-color":e.city_label_halo,"text-halo-width":1}},{id:"places_country",type:"symbol",source:i,"source-layer":"places",filter:["==","kind","country"],layout:{"symbol-sort-key":["case",["has","sort_key"],["get","sort_key"],["get","min_zoom"]],"text-field":pt(t,r),"text-font":[e.bold||"Noto Sans Medium"],"text-size":["interpolate",["linear"],["zoom"],2,["case",["<",["get","population_rank"],10],8,[">=",["get","population_rank"],10],12,0],6,["case",["<",["get","population_rank"],8],10,[">=",["get","population_rank"],8],18,0],8,["case",["<",["get","population_rank"],7],11,[">=",["get","population_rank"],7],20,0]],"icon-padding":["interpolate",["linear"],["zoom"],0,2,14,2,16,20,17,2,22,2],"text-transform":"uppercase"},paint:{"text-color":e.country_label,"text-halo-color":e.earth,"text-halo-width":1}}]}ie(yt,"labels_layers");var Zi={background:"#cccccc",earth:"#e2dfda",park_a:"#cfddd5",park_b:"#9cd3b4",hospital:"#e4dad9",industrial:"#d1dde1",school:"#e4ded7",wood_a:"#d0ded0",wood_b:"#a0d9a0",pedestrian:"#e3e0d4",scrub_a:"#cedcd7",scrub_b:"#99d2bb",glacier:"#e7e7e7",sand:"#e2e0d7",beach:"#e8e4d0",aerodrome:"#dadbdf",runway:"#e9e9ed",water:"#80deea",zoo:"#c6dcdc",military:"#dcdcdc",tunnel_other_casing:"#e0e0e0",tunnel_minor_casing:"#e0e0e0",tunnel_link_casing:"#e0e0e0",tunnel_major_casing:"#e0e0e0",tunnel_highway_casing:"#e0e0e0",tunnel_other:"#d5d5d5",tunnel_minor:"#d5d5d5",tunnel_link:"#d5d5d5",tunnel_major:"#d5d5d5",tunnel_highway:"#d5d5d5",pier:"#e0e0e0",buildings:"#cccccc",minor_service_casing:"#e0e0e0",minor_casing:"#e0e0e0",link_casing:"#e0e0e0",major_casing_late:"#e0e0e0",highway_casing_late:"#e0e0e0",other:"#ebebeb",minor_service:"#ebebeb",minor_a:"#ebebeb",minor_b:"#ffffff",link:"#ffffff",major_casing_early:"#e0e0e0",major:"#ffffff",highway_casing_early:"#e0e0e0",highway:"#ffffff",railway:"#a7b1b3",boundaries:"#adadad",bridges_other_casing:"#e0e0e0",bridges_minor_casing:"#e0e0e0",bridges_link_casing:"#e0e0e0",bridges_major_casing:"#e0e0e0",bridges_highway_casing:"#e0e0e0",bridges_other:"#ebebeb",bridges_minor:"#ffffff",bridges_link:"#ffffff",bridges_major:"#f5f5f5",bridges_highway:"#ffffff",roads_label_minor:"#91888b",roads_label_minor_halo:"#ffffff",roads_label_major:"#938a8d",roads_label_major_halo:"#ffffff",ocean_label:"#728dd4",subplace_label:"#8f8f8f",subplace_label_halo:"#e0e0e0",city_label:"#5c5c5c",city_label_halo:"#e0e0e0",state_label:"#b3b3b3",state_label_halo:"#e0e0e0",country_label:"#a3a3a3",address_label:"#91888b",address_label_halo:"#ffffff",pois:{blue:"#1A8CBD",green:"#20834D",lapis:"#315BCF",pink:"#EF56BA",red:"#F2567A",slategray:"#6A5B8F",tangerine:"#CB6704",turquoise:"#00C3D4"},landcover:{grassland:"rgba(210, 239, 207, 1)",barren:"rgba(255, 243, 215, 1)",urban_area:"rgba(230, 230, 230, 1)",farmland:"rgba(216, 239, 210, 1)",glacier:"rgba(255, 255, 255, 1)",scrub:"rgba(234, 239, 210, 1)",forest:"rgba(196, 231, 210, 1)"}},Ki={background:"#34373d",earth:"#1f1f1f",park_a:"#1c2421",park_b:"#192a24",hospital:"#252424",industrial:"#222222",school:"#262323",wood_a:"#202121",wood_b:"#202121",pedestrian:"#1e1e1e",scrub_a:"#222323",scrub_b:"#222323",glacier:"#1c1c1c",sand:"#212123",beach:"#28282a",aerodrome:"#1e1e1e",runway:"#333333",water:"#31353f",zoo:"#222323",military:"#242323",tunnel_other_casing:"#141414",tunnel_minor_casing:"#141414",tunnel_link_casing:"#141414",tunnel_major_casing:"#141414",tunnel_highway_casing:"#141414",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",pier:"#333333",buildings:"#111111",minor_service_casing:"#1f1f1f",minor_casing:"#1f1f1f",link_casing:"#1f1f1f",major_casing_late:"#1f1f1f",highway_casing_late:"#1f1f1f",other:"#333333",minor_service:"#333333",minor_a:"#3d3d3d",minor_b:"#333333",link:"#3d3d3d",major_casing_early:"#1f1f1f",major:"#3d3d3d",highway_casing_early:"#1f1f1f",highway:"#474747",railway:"#000000",boundaries:"#5b6374",bridges_other_casing:"#2b2b2b",bridges_minor_casing:"#1f1f1f",bridges_link_casing:"#1f1f1f",bridges_major_casing:"#1f1f1f",bridges_highway_casing:"#1f1f1f",bridges_other:"#333333",bridges_minor:"#333333",bridges_link:"#3d3d3d",bridges_major:"#3d3d3d",bridges_highway:"#474747",roads_label_minor:"#525252",roads_label_minor_halo:"#1f1f1f",roads_label_major:"#666666",roads_label_major_halo:"#1f1f1f",ocean_label:"#717784",subplace_label:"#525252",subplace_label_halo:"#1f1f1f",city_label:"#7a7a7a",city_label_halo:"#212121",state_label:"#3d3d3d",state_label_halo:"#1f1f1f",country_label:"#5c5c5c",address_label:"#525252",address_label_halo:"#1f1f1f",pois:{blue:"#4299BB",green:"#30C573",lapis:"#2B5CEA",pink:"#EF56BA",red:"#F2567A",slategray:"#93939F",tangerine:"#F19B6E",turquoise:"#00C3D4"},landcover:{grassland:"rgba(30, 41, 31, 1)",barren:"rgba(38, 38, 36, 1)",urban_area:"rgba(28, 28, 28, 1)",farmland:"rgba(31, 36, 32, 1)",glacier:"rgba(43, 43, 43, 1)",scrub:"rgba(34, 36, 30, 1)",forest:"rgba(28, 41, 37, 1)"}},Gi={background:"#ffffff",earth:"#ffffff",park_a:"#fcfcfc",park_b:"#fcfcfc",hospital:"#f8f8f8",industrial:"#fcfcfc",school:"#f8f8f8",wood_a:"#fafafa",wood_b:"#fafafa",pedestrian:"#fdfdfd",scrub_a:"#fafafa",scrub_b:"#fafafa",glacier:"#fcfcfc",sand:"#fafafa",beach:"#f6f6f6",aerodrome:"#fdfdfd",runway:"#efefef",water:"#dcdcdc",zoo:"#f7f7f7",military:"#fcfcfc",tunnel_other_casing:"#d6d6d6",tunnel_minor_casing:"#fcfcfc",tunnel_link_casing:"#fcfcfc",tunnel_major_casing:"#fcfcfc",tunnel_highway_casing:"#fcfcfc",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",pier:"#efefef",buildings:"#efefef",minor_service_casing:"#ffffff",minor_casing:"#ffffff",link_casing:"#ffffff",major_casing_late:"#ffffff",highway_casing_late:"#ffffff",other:"#f5f5f5",minor_service:"#f5f5f5",minor_a:"#ebebeb",minor_b:"#f5f5f5",link:"#ebebeb",major_casing_early:"#ffffff",major:"#ebebeb",highway_casing_early:"#ffffff",highway:"#ebebeb",railway:"#d6d6d6",boundaries:"#adadad",bridges_other_casing:"#ffffff",bridges_minor_casing:"#ffffff",bridges_link_casing:"#ffffff",bridges_major_casing:"#ffffff",bridges_highway_casing:"#ffffff",bridges_other:"#f5f5f5",bridges_minor:"#f5f5f5",bridges_link:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#adadad",roads_label_minor_halo:"#ffffff",roads_label_major:"#999999",roads_label_major_halo:"#ffffff",ocean_label:"#adadad",subplace_label:"#8f8f8f",subplace_label_halo:"#ffffff",city_label:"#5c5c5c",city_label_halo:"#ffffff",state_label:"#b3b3b3",state_label_halo:"#ffffff",country_label:"#b8b8b8",address_label:"#adadad",address_label_halo:"#ffffff"},Ji={background:"#a3a3a3",earth:"#cccccc",park_a:"#c2c2c2",park_b:"#c2c2c2",hospital:"#d0d0d0",industrial:"#c6c6c6",school:"#d0d0d0",wood_a:"#c2c2c2",wood_b:"#c2c2c2",pedestrian:"#c4c4c4",scrub_a:"#c2c2c2",scrub_b:"#c2c2c2",glacier:"#d2d2d2",sand:"#d2d2d2",beach:"#d2d2d2",aerodrome:"#c9c9c9",runway:"#f5f5f5",water:"#a3a3a3",zoo:"#c7c7c7",military:"#bfbfbf",tunnel_other_casing:"#b8b8b8",tunnel_minor_casing:"#b8b8b8",tunnel_link_casing:"#b8b8b8",tunnel_major_casing:"#b8b8b8",tunnel_highway_casing:"#b8b8b8",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",pier:"#b8b8b8",buildings:"#e0e0e0",minor_service_casing:"#cccccc",minor_casing:"#cccccc",link_casing:"#cccccc",major_casing_late:"#cccccc",highway_casing_late:"#cccccc",other:"#e0e0e0",minor_service:"#e0e0e0",minor_a:"#ebebeb",minor_b:"#e0e0e0",link:"#ebebeb",major_casing_early:"#cccccc",major:"#ebebeb",highway_casing_early:"#cccccc",highway:"#ebebeb",railway:"#f5f5f5",boundaries:"#5c5c5c",bridges_other_casing:"#cccccc",bridges_minor_casing:"#cccccc",bridges_link_casing:"#cccccc",bridges_major_casing:"#cccccc",bridges_highway_casing:"#cccccc",bridges_other:"#e0e0e0",bridges_minor:"#e0e0e0",bridges_link:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#999999",roads_label_minor_halo:"#e0e0e0",roads_label_major:"#8f8f8f",roads_label_major_halo:"#ebebeb",ocean_label:"#7a7a7a",subplace_label:"#7a7a7a",subplace_label_halo:"#cccccc",city_label:"#474747",city_label_halo:"#cccccc",state_label:"#999999",state_label_halo:"#cccccc",country_label:"#858585",address_label:"#999999",address_label_halo:"#e0e0e0"},Qi={background:"#2b2b2b",earth:"#141414",park_a:"#181818",park_b:"#181818",hospital:"#1d1d1d",industrial:"#101010",school:"#111111",wood_a:"#1a1a1a",wood_b:"#1a1a1a",pedestrian:"#191919",scrub_a:"#1c1c1c",scrub_b:"#1c1c1c",glacier:"#191919",sand:"#161616",beach:"#1f1f1f",aerodrome:"#191919",runway:"#323232",water:"#333333",zoo:"#191919",military:"#121212",tunnel_other_casing:"#101010",tunnel_minor_casing:"#101010",tunnel_link_casing:"#101010",tunnel_major_casing:"#101010",tunnel_highway_casing:"#101010",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",pier:"#0a0a0a",buildings:"#0a0a0a",minor_service_casing:"#141414",minor_casing:"#141414",link_casing:"#141414",major_casing_late:"#141414",highway_casing_late:"#141414",other:"#1f1f1f",minor_service:"#1f1f1f",minor_a:"#292929",minor_b:"#1f1f1f",link:"#1f1f1f",major_casing_early:"#141414",major:"#292929",highway_casing_early:"#141414",highway:"#292929",railway:"#292929",boundaries:"#707070",bridges_other_casing:"#141414",bridges_minor_casing:"#141414",bridges_link_casing:"#141414",bridges_major_casing:"#141414",bridges_highway_casing:"#141414",bridges_other:"#1f1f1f",bridges_minor:"#1f1f1f",bridges_link:"#292929",bridges_major:"#292929",bridges_highway:"#292929",roads_label_minor:"#525252",roads_label_minor_halo:"#141414",roads_label_major:"#5c5c5c",roads_label_major_halo:"#141414",ocean_label:"#707070",subplace_label:"#5c5c5c",subplace_label_halo:"#141414",city_label:"#999999",city_label_halo:"#141414",state_label:"#3d3d3d",state_label_halo:"#141414",country_label:"#707070",address_label:"#525252",address_label_halo:"#141414"};function me(i){switch(i){case"light":return Zi;case"dark":return Ki;case"white":return Gi;case"grayscale":return Ji;case"black":return Qi}throw new Error("Flavor not found")}ie(me,"namedFlavor");function er(i,e,t){let r=[];return t!=null&&t.labelsOnly||(r=gt(i,e)),t!=null&&t.lang&&(r=r.concat(yt(i,e,t.lang))),r}ie(er,"layers");function se(i,e,t){return Math.min(Math.max(i,t),e)}var Re=class extends Error{constructor(e){super(`Failed to parse color: "${e}"`)}},pe=Re;function xt(i){if(typeof i!="string")throw new pe(i);if(i.trim().toLowerCase()==="transparent")return[0,0,0,0];let e=i.trim();e=sr.test(i)?rr(i):i;let t=ar.exec(e);if(t){let o=Array.from(t).slice(1);return[...o.slice(0,3).map(l=>parseInt(ge(l,2),16)),parseInt(ge(o[3]||"f",2),16)/255]}let r=nr.exec(e);if(r){let o=Array.from(r).slice(1);return[...o.slice(0,3).map(l=>parseInt(l,16)),parseInt(o[3]||"ff",16)/255]}let a=or.exec(e);if(a){let o=Array.from(a).slice(1);return[...o.slice(0,3).map(l=>parseInt(l,10)),parseFloat(o[3]||"1")]}let n=lr.exec(e);if(n){let[o,l,s,c]=Array.from(n).slice(1).map(parseFloat);if(se(0,100,l)!==l)throw new pe(i);if(se(0,100,s)!==s)throw new pe(i);return[...cr(o,l,s),Number.isNaN(c)?1:c]}throw new pe(i)}function tr(i){let e=5381,t=i.length;for(;t;)e=e*33^i.charCodeAt(--t);return(e>>>0)%2341}var _t=i=>parseInt(i.replace(/_/g,""),36),ir="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((i,e)=>{let t=_t(e.substring(0,3)),r=_t(e.substring(3)).toString(16),a="";for(let n=0;n<6-r.length;n++)a+="0";return i[t]=`${a}${r}`,i},{});function rr(i){let e=i.toLowerCase().trim(),t=ir[tr(e)];if(!t)throw new pe(i);return`#${t}`}var ge=(i,e)=>Array.from(Array(e)).map(()=>i).join(""),ar=new RegExp(`^#${ge("([a-f0-9])",3)}([a-f0-9])?$`,"i"),nr=new RegExp(`^#${ge("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),or=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${ge(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),lr=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,sr=/^[a-z]+$/i,bt=i=>Math.round(i*255),cr=(i,e,t)=>{let r=t/100;if(e===0)return[r,r,r].map(bt);let a=(i%360+360)%360/60,n=(1-Math.abs(2*r-1))*(e/100),o=n*(1-Math.abs(a%2-1)),l=0,s=0,c=0;a>=0&&a<1?(l=n,s=o):a>=1&&a<2?(l=o,s=n):a>=2&&a<3?(s=n,c=o):a>=3&&a<4?(s=o,c=n):a>=4&&a<5?(l=o,c=n):a>=5&&a<6&&(l=n,c=o);let d=r-n/2,u=l+d,g=s+d,v=c+d;return[u,g,v].map(bt)};function hr(i,e,t,r){return`rgba(${se(0,255,i).toFixed()}, ${se(0,255,e).toFixed()}, ${se(0,255,t).toFixed()}, ${parseFloat(se(0,1,r).toFixed(3))})`}function Fe(i,e,t){let r=(_,k)=>k===3?_:_/255,[a,n,o,l]=xt(i).map(r),[s,c,d,u]=xt(e).map(r),g=u-l,v=t*2-1,M=((v*g===-1?v:v+g/(1+v*g))+1)/2,f=1-M,h=(a*f+s*M)*255,p=(n*f+c*M)*255,x=(o*f+d*M)*255,y=u*t+l*(1-t);return hr(h,p,x,y)}var Te=class{constructor(e,t,r,a,n){for(this.properties=Object.create(null),this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=a,this._values=n;e.pos>3,o===0)continue}if(o--,n===1)l+=e.readSVarint(),s+=e.readSVarint(),a&&r.push(a),a=[new S(l,s)];else if(n===2)l+=e.readSVarint(),s+=e.readSVarint(),a&&a.push(new S(l,s));else if(n===7)a&&a.push(a[0].clone());else throw new Error(`unknown command ${n}`)}return a&&r.push(a),r}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");let e=this._pbf;e.pos=this._geometry;let t=e.readVarint()+e.pos,r=1,a=0,n=0,o=0,l=1/0,s=-1/0,c=1/0,d=-1/0;for(;e.pos>3,a===0)continue}if(a--,r===1||r===2)n+=e.readSVarint(),o+=e.readSVarint(),ns&&(s=n),od&&(d=o);else if(r!==7)throw new Error(`unknown command ${r}`)}return[l,c,s,d]}toGeoJSON(e,t,r){let a=this.extent*Math.pow(2,r),n=this.extent*e,o=this.extent*t,l=this.loadGeometry();function s(g){return[(g.x+n)*360/a-180,360/Math.PI*Math.atan(Math.exp((1-(g.y+o)*2/a)*Math.PI))-90]}function c(g){return g.map(s)}let d;if(this.type===1){let g=[];for(let b of l)g.push(b[0]);let v=c(g);d=g.length===1?{type:"Point",coordinates:v[0]}:{type:"MultiPoint",coordinates:v}}else if(this.type===2){let g=l.map(c);d=g.length===1?{type:"LineString",coordinates:g[0]}:{type:"MultiLineString",coordinates:g}}else if(this.type===3){let g=dr(l),v=[];for(let b of g)v.push(b.map(c));d=v.length===1?{type:"Polygon",coordinates:v[0]}:{type:"MultiPolygon",coordinates:v}}else throw new Error("unknown feature type");let u={type:"Feature",geometry:d,properties:this.properties};return this.id!=null&&(u.id=this.id),u}};Te.types=["Unknown","Point","LineString","Polygon"];function dr(i){let e=i.length;if(e<=1)return[i];let t=[],r,a;for(let n=0;n=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let t=this._pbf.readVarint()+this._pbf.pos;return new Te(this._pbf,t,this.extent,this._keys,this._values)}};function ur(i){let e=null,t=i.readVarint()+i.pos;for(;i.pos"u"?null:new TextDecoder("utf-8"),Ue=0,Ce=1,ye=2,Pe=5,xe=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,r=this.length){for(;this.pos>3,o=this.pos;this.type=a&7,e(n,t,this),this.pos===o&&this.skip(a)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){let e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){let e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*4294967296;return this.pos+=8,e}readSFixed64(){let e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*4294967296;return this.pos+=8,e}readFloat(){let e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){let e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){let t=this.buf,r,a;return a=t[this.pos++],r=a&127,a<128||(a=t[this.pos++],r|=(a&127)<<7,a<128)||(a=t[this.pos++],r|=(a&127)<<14,a<128)||(a=t[this.pos++],r|=(a&127)<<21,a<128)?r:(a=t[this.pos],r|=(a&15)<<28,pr(r,e,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){let e=this.readVarint();return e%2===1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){let e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=mr&&vt?vt.decode(this.buf.subarray(t,e)):Fr(this.buf,t,e)}readBytes(){let e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){let r=this.readPackedEnd();for(;this.pos127;);else if(t===ye)this.pos=this.readVarint()+this.pos;else if(t===Pe)this.pos+=4;else if(t===Ce)this.pos+=8;else throw new Error(`Unimplemented type: ${t}`)}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0){gr(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))}writeSVarint(e){this.writeVarint(e<0?-e*2-1:e*2)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(e.length*4),this.pos++;let t=this.pos;this.pos=Tr(this.buf,e,this.pos);let r=this.pos-t;r>=128&&kt(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){let t=e.length;this.writeVarint(t),this.realloc(t);for(let r=0;r=128&&kt(r,a,this),this.pos=r-1,this.writeVarint(a),this.pos+=a}writeMessage(e,t,r){this.writeTag(e,ye),this.writeRawMessage(t,r)}writePackedVarint(e,t){t.length&&this.writeMessage(e,_r,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,br,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,kr,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,wr,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,vr,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,zr,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Mr,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Sr,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Lr,t)}writeBytesField(e,t){this.writeTag(e,ye),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,Pe),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,Pe),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,Ce),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,Ce),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,Ue),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,Ue),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,ye),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,Pe),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,Ce),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function pr(i,e,t){let r=t.buf,a,n;if(n=r[t.pos++],a=(n&112)>>4,n<128||(n=r[t.pos++],a|=(n&127)<<3,n<128)||(n=r[t.pos++],a|=(n&127)<<10,n<128)||(n=r[t.pos++],a|=(n&127)<<17,n<128)||(n=r[t.pos++],a|=(n&127)<<24,n<128)||(n=r[t.pos++],a|=(n&1)<<31,n<128))return ce(i,a,e);throw new Error("Expected varint not more than 10 bytes")}function ce(i,e,t){return t?e*4294967296+(i>>>0):(e>>>0)*4294967296+(i>>>0)}function gr(i,e){let t,r;if(i>=0?(t=i%4294967296|0,r=i/4294967296|0):(t=~(-i%4294967296),r=~(-i/4294967296),t^4294967295?t=t+1|0:(t=0,r=r+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),yr(t,r,e),xr(r,e)}function yr(i,e,t){t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos]=i&127}function xr(i,e){let t=(i&7)<<4;e.buf[e.pos++]|=t|((i>>>=3)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127)))))}function kt(i,e,t){let r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));t.realloc(r);for(let a=t.pos-1;a>=i;a--)t.buf[a+r]=t.buf[a]}function _r(i,e){for(let t=0;t239?4:n>223?3:n>191?2:1;if(a+l>t)break;let s,c,d;l===1?n<128&&(o=n):l===2?(s=i[a+1],(s&192)===128&&(o=(n&31)<<6|s&63,o<=127&&(o=null))):l===3?(s=i[a+1],c=i[a+2],(s&192)===128&&(c&192)===128&&(o=(n&15)<<12|(s&63)<<6|c&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):l===4&&(s=i[a+1],c=i[a+2],d=i[a+3],(s&192)===128&&(c&192)===128&&(d&192)===128&&(o=(n&15)<<18|(s&63)<<12|(c&63)<<6|d&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,l=1):o>65535&&(o-=65536,r+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),r+=String.fromCharCode(o),a+=l}return r}function Tr(i,e,t){for(let r=0,a,n;r55295&&a<57344)if(n)if(a<56320){i[t++]=239,i[t++]=191,i[t++]=189,n=a;continue}else a=n-55296<<10|a-56320|65536,n=null;else{a>56319||r+1===e.length?(i[t++]=239,i[t++]=191,i[t++]=189):n=a;continue}else n&&(i[t++]=239,i[t++]=191,i[t++]=189,n=null);a<128?i[t++]=a:(a<2048?i[t++]=a>>6|192:(a<65536?i[t++]=a>>12|224:(i[t++]=a>>18|240,i[t++]=a>>12&63|128),i[t++]=a>>6&63|128),i[t++]=a&63|128)}return t}var fe=Math.pow,$=(i,e,t)=>new Promise((r,a)=>{var n=s=>{try{l(t.next(s))}catch(c){a(c)}},o=s=>{try{l(t.throw(s))}catch(c){a(c)}},l=s=>s.done?r(s.value):Promise.resolve(s.value).then(n,o);l((t=t.apply(i,e)).next())}),H=Uint8Array,de=Uint16Array,Dr=Int32Array,St=new H([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Lt=new H([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Cr=new H([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ft=function(i,e){for(var t=new de(31),r=0;r<31;++r)t[r]=e+=1<>1|(D&21845)<<1,re=(re&52428)>>2|(re&13107)<<2,re=(re&61680)>>4|(re&3855)<<4,qe[D]=((re&65280)>>8|(re&255)<<8)>>1;var re,D,we=function(i,e,t){for(var r=i.length,a=0,n=new de(e);a>s]=c}else for(l=new de(r),a=0;a>15-i[a]);return l},ve=new H(288);for(D=0;D<144;++D)ve[D]=8;var D;for(D=144;D<256;++D)ve[D]=9;var D;for(D=256;D<280;++D)ve[D]=7;var D;for(D=280;D<288;++D)ve[D]=8;var D,Pt=new H(32);for(D=0;D<32;++D)Pt[D]=5;var D,Br=we(ve,9,1),Vr=we(Pt,5,1),He=function(i){for(var e=i[0],t=1;te&&(e=i[t]);return e},G=function(i,e,t){var r=e/8|0;return(i[r]|i[r+1]<<8)>>(e&7)&t},Ne=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},$r=function(i){return(i+7)/8|0},Er=function(i,e,t){(e==null||e<0)&&(e=0),(t==null||t>i.length)&&(t=i.length);var r=new H(t-e);return r.set(i.subarray(e,t)),r},Yr=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],U=function(i,e,t){var r=new Error(e||Yr[i]);if(r.code=i,Error.captureStackTrace&&Error.captureStackTrace(r,U),!t)throw r;return r},Ze=function(i,e,t,r){var a=i.length,n=r?r.length:0;if(!a||e.f&&!e.l)return t||new H(0);var o=!t||e.i!=2,l=e.i;t||(t=new H(a*3));var s=function(dt){var ft=t.length;if(dt>ft){var ut=new H(Math.max(ft*2,dt));ut.set(t),t=ut}},c=e.f||0,d=e.p||0,u=e.b||0,g=e.l,v=e.d,b=e.m,M=e.n,f=a*8;do{if(!g){c=G(i,d,1);var h=G(i,d+1,3);if(d+=3,h)if(h==1)g=Br,v=Vr,b=9,M=5;else if(h==2){var _=G(i,d,31)+257,k=G(i,d+10,15)+4,w=_+G(i,d+5,31)+1;d+=14;for(var z=new H(w),F=new H(19),T=0;T>4;if(p<16)z[T++]=p;else{var R=0,W=0;for(p==16?(W=3+G(i,d,3),d+=2,R=z[T-1]):p==17?(W=3+G(i,d,7),d+=3):p==18&&(W=11+G(i,d,127),d+=7);W--;)z[T++]=R}}var Se=z.subarray(0,_),V=z.subarray(_);b=He(Se),M=He(V),g=we(Se,b,1),v=we(V,M,1)}else U(1);else{var p=$r(d)+4,x=i[p-4]|i[p-3]<<8,y=p+x;if(y>a){l&&U(0);break}o&&s(u+x),t.set(i.subarray(p,y),u),e.b=u+=x,e.p=d=y*8,e.f=c;continue}if(d>f){l&&U(0);break}}o&&s(u+131072);for(var oe=(1<>4;if(d+=R&15,d>f){l&&U(0);break}if(R||U(2),le<256)t[u++]=le;else if(le==256){$e=d,g=null;break}else{var ct=le-254;if(le>264){var T=le-257,ue=St[T];ct=G(i,d,(1<>4;Ee||U(3),d+=Ee&15;var V=jr[Ye];if(Ye>3){var ue=Lt[Ye];V+=Ne(i,d)&(1<f){l&&U(0);break}o&&s(u+131072);var Xe=u+ct;if(u>3&1)+(e>>4&1);r>0;r-=!i[t++]);return t+(e&2)},Rr=function(i){var e=i.length;return(i[e-4]|i[e-3]<<8|i[e-2]<<16|i[e-1]<<24)>>>0},Ar=function(i,e){return((i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31)&&U(6,"invalid zlib data"),(i[1]>>5&1)==+!e&&U(6,"invalid zlib data: "+(i[1]&32?"need":"unexpected")+" dictionary"),(i[1]>>3&4)+2};function Ur(i,e){return Ze(i,{i:2},e&&e.out,e&&e.dictionary)}function Hr(i,e){var t=Ir(i);return t+8>i.length&&U(6,"invalid gzip data"),Ze(i.subarray(t,-8),{i:2},e&&e.out||new H(Rr(i)),e&&e.dictionary)}function Nr(i,e){return Ze(i.subarray(Ar(i,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary)}function Oe(i,e){return i[0]==31&&i[1]==139&&i[2]==8?Hr(i,e):(i[0]&15)!=8||i[0]>>4>7||(i[0]<<8|i[1])%31?Ur(i,e):Nr(i,e)}var qr=typeof TextDecoder<"u"&&new TextDecoder,Or=0;try{qr.decode(Xr,{stream:!0}),Or=1}catch{}var jt=(i,e)=>i*fe(2,e),_e=(i,e)=>Math.floor(i/fe(2,e)),je=(i,e)=>jt(i.getUint16(e+1,!0),8)+i.getUint8(e),Bt=(i,e)=>jt(i.getUint32(e+2,!0),16)+i.getUint16(e,!0),Wr=(i,e,t,r,a)=>{if(i!==r.getUint8(a))return i-r.getUint8(a);let n=je(r,a+1);if(e!==n)return e-n;let o=je(r,a+4);return t!==o?t-o:0},Zr=(i,e,t,r)=>{let a=Vt(i,e|128,t,r);return a?{z:e,x:t,y:r,offset:a[0],length:a[1],isDir:!0}:null},zt=(i,e,t,r)=>{let a=Vt(i,e,t,r);return a?{z:e,x:t,y:r,offset:a[0],length:a[1],isDir:!1}:null},Vt=(i,e,t,r)=>{let a=0,n=i.byteLength/17-1;for(;a<=n;){let o=n+a>>1,l=Wr(e,t,r,i,o*17);if(l>0)a=o+1;else if(l<0)n=o-1;else return[Bt(i,o*17+7),i.getUint32(o*17+13,!0)]}return null},Kr=(i,e)=>i.isDir&&!e.isDir?1:!i.isDir&&e.isDir?-1:i.z!==e.z?i.z-e.z:i.x!==e.x?i.x-e.x:i.y-e.y,$t=(i,e)=>{let t=i.getUint8(e*17);return{z:t&127,x:je(i,e*17+1),y:je(i,e*17+4),offset:Bt(i,e*17+7),length:i.getUint32(e*17+13,!0),isDir:t>>7===1}},Mt=i=>{let e=[],t=new DataView(i);for(let r=0;r{i.sort(Kr);let e=new ArrayBuffer(17*i.length),t=new Uint8Array(e);for(let r=0;r>8&255,t[r*17+3]=a.x>>16&255,t[r*17+4]=a.y&255,t[r*17+5]=a.y>>8&255,t[r*17+6]=a.y>>16&255,t[r*17+7]=a.offset&255,t[r*17+8]=_e(a.offset,8)&255,t[r*17+9]=_e(a.offset,16)&255,t[r*17+10]=_e(a.offset,24)&255,t[r*17+11]=_e(a.offset,32)&255,t[r*17+12]=_e(a.offset,48)&255,t[r*17+13]=a.length&255,t[r*17+14]=a.length>>8&255,t[r*17+15]=a.length>>16&255,t[r*17+16]=a.length>>24&255}return e},Jr=(i,e)=>{if(i.byteLength<17)return null;let t=i.byteLength/17,r=$t(i,t-1);if(r.isDir){let a=r.z,n=e.z-a,o=Math.trunc(e.x/(1<>>0)*4294967296+(i>>>0)}function ta(i,e){let t=e.buf,r=t[e.pos++],a=(r&112)>>4;if(r<128||(r=t[e.pos++],a|=(r&127)<<3,r<128)||(r=t[e.pos++],a|=(r&127)<<10,r<128)||(r=t[e.pos++],a|=(r&127)<<17,r<128)||(r=t[e.pos++],a|=(r&127)<<24,r<128)||(r=t[e.pos++],a|=(r&1)<<31,r<128))return he(i,a);throw new Error("Expected varint not more than 10 bytes")}function be(i){let e=i.buf,t=e[i.pos++],r=t&127;return t<128||(t=e[i.pos++],r|=(t&127)<<7,t<128)||(t=e[i.pos++],r|=(t&127)<<14,t<128)||(t=e[i.pos++],r|=(t&127)<<21,t<128)?r:(t=e[i.pos],r|=(t&15)<<28,ta(r,i))}function ia(i,e,t,r){if(r===0){t===1&&(e[0]=i-1-e[0],e[1]=i-1-e[1]);let a=e[0];e[0]=e[1],e[1]=a}}var ra=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function aa(i,e,t){if(i>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(e>fe(2,i)-1||t>fe(2,i)-1)throw Error("tile x/y outside zoom level bounds");let r=ra[i],a=fe(2,i),n=0,o=0,l=0,s=[e,t],c=a/2;for(;c>0;)n=(s[0]&c)>0?1:0,o=(s[1]&c)>0?1:0,l+=c*c*(3*n^o),ia(c,s,n,o),c=c/2;return r+l}function Yt(i,e){return $(this,null,function*(){if(e===1||e===0)return i;if(e===2){if(typeof globalThis.DecompressionStream>"u")return Oe(new Uint8Array(i));let t=new Response(i).body;if(!t)throw Error("Failed to read response stream");let r=t.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(r).arrayBuffer()}throw Error("Compression method not supported")})}function na(i){return i===1?".mvt":i===2?".png":i===3?".jpg":i===4?".webp":i===5?".avif":""}var oa=127;function la(i,e){let t=0,r=i.length-1;for(;t<=r;){let a=r+t>>1,n=e-i[a].tileId;if(n>0)t=a+1;else if(n<0)r=a-1;else return i[a]}return r>=0&&(i[r].runLength===0||e-i[r].tileId-1,a=/Chrome|Chromium|Edg|OPR|Brave/.test(t);this.chromeWindowsNoCache=!1,r&&a&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(i){this.customHeaders=i}getBytes(i,e,t,r){return $(this,null,function*(){let a,n;t?n=t:(a=new AbortController,n=a.signal);let o=new Headers(this.customHeaders);o.set("range",`bytes=${i}-${i+e-1}`);let l;this.mustReload?l="reload":this.chromeWindowsNoCache&&(l="no-store");let s=yield fetch(this.url,{signal:n,cache:l,headers:o});if(i===0&&s.status===416){let g=s.headers.get("Content-Range");if(!g||!g.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let v=+g.substr(8);s=yield fetch(this.url,{signal:n,cache:"reload",headers:{range:`bytes=0-${v-1}`}})}let c=s.headers.get("Etag");if(c?.startsWith("W/")&&(c=null),s.status===416||r&&c&&c!==r)throw this.mustReload=!0,new We(`Server returned non-matching ETag ${r} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(s.status>=300)throw Error(`Bad response code: ${s.status}`);let d=s.headers.get("Content-Length");if(s.status===200&&(!d||+d>e))throw a&&a.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield s.arrayBuffer(),etag:c||void 0,cacheControl:s.headers.get("Cache-Control")||void 0,expires:s.headers.get("Expires")||void 0}})}};function J(i,e){let t=i.getUint32(e+4,!0),r=i.getUint32(e+0,!0);return t*fe(2,32)+r}function ca(i,e){let t=new DataView(i),r=t.getUint8(7);if(r>3)throw Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:J(t,8),rootDirectoryLength:J(t,16),jsonMetadataOffset:J(t,24),jsonMetadataLength:J(t,32),leafDirectoryOffset:J(t,40),leafDirectoryLength:J(t,48),tileDataOffset:J(t,56),tileDataLength:J(t,64),numAddressedTiles:J(t,72),numTileEntries:J(t,80),numTileContents:J(t,88),clustered:t.getUint8(96)===1,internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:t.getUint8(99),minZoom:t.getUint8(100),maxZoom:t.getUint8(101),minLon:t.getInt32(102,!0)/1e7,minLat:t.getInt32(106,!0)/1e7,maxLon:t.getInt32(110,!0)/1e7,maxLat:t.getInt32(114,!0)/1e7,centerZoom:t.getUint8(118),centerLon:t.getInt32(119,!0)/1e7,centerLat:t.getInt32(123,!0)/1e7,etag:e}}function Xt(i){let e={buf:new Uint8Array(i),pos:0},t=be(e),r=[],a=0;for(let n=0;n0?r[n].offset=r[n-1].offset+r[n-1].length:r[n].offset=o-1}return r}function ha(i){let e=new DataView(i);return e.getUint16(2,!0)===2?(console.warn("PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),2):e.getUint16(2,!0)===1?(console.warn("PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),1):3}var We=class extends Error{};function da(i,e){return $(this,null,function*(){let t=yield i.getBytes(0,16384);if(new DataView(t.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(ha(t.data)<3)return[yield Et.getHeader(i)];let a=t.data.slice(0,oa),n=ca(a,t.etag),o=t.data.slice(n.rootDirectoryOffset,n.rootDirectoryOffset+n.rootDirectoryLength),l=`${i.getKey()}|${n.etag||""}|${n.rootDirectoryOffset}|${n.rootDirectoryLength}`,s=Xt(yield e(o,n.internalCompression));return[n,[l,s.length,s]]})}function fa(i,e,t,r,a){return $(this,null,function*(){let n=yield i.getBytes(t,r,void 0,a.etag),o=yield e(n.data,a.internalCompression),l=Xt(o);if(l.length===0)throw new Error("Empty directory is invalid");return l})}var ua=class{constructor(i=100,e=!0,t=Yt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=i,this.counter=1,this.decompress=t}getHeader(i){return $(this,null,function*(){let e=i.getKey(),t=this.cache.get(e);if(t)return t.lastUsed=this.counter++,yield t.data;let r=new Promise((a,n)=>{da(i,this.decompress).then(o=>{o[1]&&this.cache.set(o[1][0],{lastUsed:this.counter++,data:Promise.resolve(o[1][2])}),a(o[0]),this.prune()}).catch(o=>{n(o)})});return this.cache.set(e,{lastUsed:this.counter++,data:r}),r})}getDirectory(i,e,t,r){return $(this,null,function*(){let a=`${i.getKey()}|${r.etag||""}|${e}|${t}`,n=this.cache.get(a);if(n)return n.lastUsed=this.counter++,yield n.data;let o=new Promise((l,s)=>{fa(i,this.decompress,e,t,r).then(c=>{l(c),this.prune()}).catch(c=>{s(c)})});return this.cache.set(a,{lastUsed:this.counter++,data:o}),o})}getArrayBuffer(i,e,t,r){return $(this,null,function*(){let a=`${i.getKey()}|${r.etag||""}|${e}|${t}`,n=this.cache.get(a);if(n)return n.lastUsed=this.counter++,yield n.data;let o=new Promise((l,s)=>{i.getBytes(e,t,void 0,r.etag).then(c=>{l(c.data),this.cache.has(a),this.prune()}).catch(c=>{s(c)})});return this.cache.set(a,{lastUsed:this.counter++,data:o}),o})}prune(){if(this.cache.size>=this.maxCacheEntries){let i=1/0,e;this.cache.forEach((t,r)=>{t.lastUsed{this.getHeader(i).then(n=>{r(),this.invalidations.delete(e)}).catch(n=>{a(n)})});this.invalidations.set(e,t)})}},It=class{constructor(i,e,t){typeof i=="string"?this.source=new sa(i):this.source=i,t?this.decompress=t:this.decompress=Yt,e?this.cache=e:this.cache=new ua}getHeader(){return $(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(i,e,t,r){return $(this,null,function*(){let a=aa(i,e,t),n=yield this.cache.getHeader(this.source);if(n.specVersion<3)return Et.getZxy(n,this.source,this.cache,i,e,t,r);if(in.maxZoom)return;let o=n.rootDirectoryOffset,l=n.rootDirectoryLength;for(let s=0;s<=3;s++){let c=yield this.cache.getDirectory(this.source,o,l,n),d=la(c,a);if(d){if(d.runLength>0){let u=yield this.source.getBytes(n.tileDataOffset+d.offset,d.length,r,n.etag);return{data:yield this.decompress(u.data,n.tileCompression),cacheControl:u.cacheControl,expires:u.expires}}o=n.leafDirectoryOffset+d.offset,l=d.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(i,e,t,r){return $(this,null,function*(){try{return yield this.getZxyAttempt(i,e,t,r)}catch(a){if(a instanceof We)return this.cache.invalidate(this.source),yield this.getZxyAttempt(i,e,t,r);throw a}})}getMetadataAttempt(){return $(this,null,function*(){let i=yield this.cache.getHeader(this.source),e=yield this.source.getBytes(i.jsonMetadataOffset,i.jsonMetadataLength,void 0,i.etag),t=yield this.decompress(e.data,i.internalCompression),r=new TextDecoder("utf-8");return JSON.parse(r.decode(t))})}getMetadata(){return $(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(i){if(i instanceof We)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw i}})}getTileJson(i){return $(this,null,function*(){let e=yield this.getHeader(),t=yield this.getMetadata(),r=na(e.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${i}/{z}/{x}/{y}${r}`],vector_layers:t.vector_layers,attribution:t.attribution,description:t.description,name:t.name,version:t.version,bounds:[e.minLon,e.minLat,e.maxLon,e.maxLat],center:[e.centerLon,e.centerLat,e.centerZoom],minzoom:e.minZoom,maxzoom:e.maxZoom}})}};var Li=Ni(Rt(),1);function Je(i){let e=0,t=0;for(let l of i)e+=l.w*l.h,t=Math.max(t,l.w);i.sort((l,s)=>s.h-l.h);let a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),t),h:1/0}],n=0,o=0;for(let l of i)for(let s=a.length-1;s>=0;s--){let c=a[s];if(!(l.w>c.w||l.h>c.h)){if(l.x=c.x,l.y=c.y,o=Math.max(o,l.y+l.h),n=Math.max(n,l.x+l.w),l.w===c.w&&l.h===c.h){let d=a.pop();sma(i,"name",{value:e,configurable:!0}),q=(i,e,t)=>new Promise((r,a)=>{var n=s=>{try{l(t.next(s))}catch(c){a(c)}},o=s=>{try{l(t.throw(s))}catch(c){a(c)}},l=s=>s.done?r(s.value):Promise.resolve(s.value).then(n,o);l((t=t.apply(i,e)).next())}),Zt=class{constructor(e,t){this.str=e??t,this.perFeature=typeof this.str=="function"&&this.str.length===2}get(e,t){return typeof this.str=="function"?this.str(e,t):this.str}};m(Zt,"StringAttr");var I=Zt,Kt=class{constructor(e,t=1){this.value=e??t,this.perFeature=typeof this.value=="function"&&this.value.length===2}get(e,t){return typeof this.value=="function"?this.value(e,t):this.value}};m(Kt,"NumberAttr");var P=Kt,Gt=class{constructor(e){var t;this.labelProps=(t=e?.labelProps)!=null?t:["name"],this.textTransform=e?.textTransform}get(e,t){let r,a;typeof this.labelProps=="function"?a=this.labelProps(e,t):a=this.labelProps;for(let o of a)if(Object.prototype.hasOwnProperty.call(t.props,o)&&typeof t.props[o]=="string"){r=t.props[o];break}let n;return typeof this.textTransform=="function"?n=this.textTransform(e,t):n=this.textTransform,r&&n==="uppercase"?r=r.toUpperCase():r&&n==="lowercase"?r=r.toLowerCase():r&&n==="capitalize"&&(r=r.toLowerCase().split(" ").map(o=>o[0].toUpperCase()+o.slice(1)).join(" ")),r}};m(Gt,"TextAttr");var at=Gt,Jt=class{constructor(e){var t,r;e!=null&&e.font?this.font=e.font:(this.family=(t=e?.fontFamily)!=null?t:"sans-serif",this.size=(r=e?.fontSize)!=null?r:12,this.weight=e?.fontWeight,this.style=e?.fontStyle)}get(e,t){if(this.font)return typeof this.font=="function"?this.font(e,t):this.font;let r="";this.style&&(typeof this.style=="function"?r=`${this.style(e,t)} `:r=`${this.style} `);let a="";this.weight&&(typeof this.weight=="function"?a=`${this.weight(e,t)} `:a=`${this.weight} `);let n;typeof this.size=="function"?n=this.size(e,t):n=this.size;let o;return typeof this.family=="function"?o=this.family(e,t):o=this.family,`${r}${a}${n}px ${o}`}};m(Jt,"FontAttr");var nt=Jt,Qt=class{constructor(e,t=[]){this.value=e??t,this.perFeature=typeof this.value=="function"&&this.value.length===2}get(e,t){return typeof this.value=="function"?this.value(e,t):this.value}};m(Qt,"ArrayAttr");var pa=Qt,ga=m((i,e,t)=>{let r=[],a,n,o,l=0,s=0,c=0,d=0,u=0,g=0,v=0,b=0,M=0,f=0,h=0,p=0;if(i.length<2)return[];if(i.length===2)return c=Math.sqrt(E(i[1].x-i[0].x,2)+E(i[1].y-i[0].y,2)),[{length:c,beginIndex:0,beginDistance:0,endIndex:2,endDistance:c}];for(d=Math.sqrt(E(i[1].x-i[0].x,2)+E(i[1].y-i[0].y,2)),l=1,s=i.length-1;le||c-p>t)&&(r.push({length:c-p,beginDistance:p,beginIndex:h,endIndex:l+1,endDistance:c}),h=l,p=c),d=u;return l-h>0&&r.push({length:c-p+u,beginIndex:h,beginDistance:p,endIndex:l+1,endDistance:c+u}),r},"linelabel");function ei(i,e,t,r){let a=[];for(let n of i){let o=ga(n,Math.PI/45,e);for(let l of o)if(l.length>=e+r){let s=new S(n[l.beginIndex].x,n[l.beginIndex].y),c=n[l.endIndex-1],d=new S((c.x-s.x)/l.length,(c.y-s.y)/l.length);for(let u=r;u=0&&t-r(i[i.Point=1]="Point",i[i.Line=2]="Line",i[i.Polygon=3]="Polygon",i))(xa||{});function ae(i){return`${i.x}:${i.y}:${i.z}`}m(ae,"toIndex");var _a=m((i,e,t)=>{i.pos=e;let r=i.readVarint()+i.pos,a=1,n=0,o=0,l=0,s=1/0,c=-1/0,d=1/0,u=-1/0,g=[],v=[];for(;i.pos>3}if(n--,a===1||a===2)o+=i.readSVarint()*t,l+=i.readSVarint()*t,oc&&(c=o),lu&&(u=l),a===1&&(v.length>0&&g.push(v),v=[]),v.push(new S(o,l));else if(a===7)v&&v.push(v[0].clone());else throw new Error(`unknown command ${a}`)}return v&&g.push(v),{geom:g,bbox:{minX:s,minY:d,maxX:c,maxY:u}}},"loadGeomAndBbox");function lt(i,e){let t=new De(new xe(i)),r=new Map;for(let[a,n]of Object.entries(t.layers)){let o=[],l=n;for(let s=0;so.z!==e.z?(o.controller.abort(),!1):!0));let r=new AbortController;this.zoomaborts.push({z:e.z,controller:r});let a=r.signal,n=yield this.p.getZxy(e.z,e.x,e.y,a);return n?lt(n.data,t):new Map})}};m(ii,"PmtilesSource");var At=ii,ri=class{constructor(e,t){this.url=e,this.zoomaborts=[],this.shouldCancelZooms=t}get(e,t){return q(this,null,function*(){this.shouldCancelZooms&&(this.zoomaborts=this.zoomaborts.filter(o=>o.z!==e.z?(o.controller.abort(),!1):!0));let r=this.url.replace("{z}",e.z.toString()).replace("{x}",e.x.toString()).replace("{y}",e.y.toString()),a=new AbortController;this.zoomaborts.push({z:e.z,controller:a});let n=a.signal;return new Promise((o,l)=>{fetch(r,{signal:n}).then(s=>s.arrayBuffer()).then(s=>{let c=lt(s,t);o(c)}).catch(s=>{l(s)})})})}};m(ri,"ZxySource");var ba=ri,et=6378137,Ut=85.0511287798,Be=et*Math.PI,wa=m(i=>{let e=Math.PI/180,t=Math.max(Math.min(Ut,i[0]),-Ut),r=Math.sin(t*e);return new S(et*i[1]*e,et*Math.log((1+r)/(1-r))/2)},"project");function tt(i){return i*i}m(tt,"sqr");function ze(i,e){return tt(i.x-e.x)+tt(i.y-e.y)}m(ze,"dist2");function ai(i,e,t){let r=ze(e,t);if(r===0)return ze(i,e);let a=((i.x-e.x)*(t.x-e.x)+(i.y-e.y)*(t.y-e.y))/r;return a=Math.max(0,Math.min(1,a)),ze(i,new S(e.x+a*(t.x-e.x),e.y+a*(t.y-e.y)))}m(ai,"distToSegmentSquared");function it(i,e){let t=!1;for(let r=0,a=e.length-1;ri.y!=s>i.y&&i.x<(l-n)*(i.y-o)/(s-o)+n&&(t=!t)}return t}m(it,"isInRing");function ni(i){let e=0;for(let t=0;t{let n=this.cache.get(t);if(n)n.used=performance.now(),r(n.data);else{let o=this.inflight.get(t);o?o.push({resolve:r,reject:a}):(this.inflight.set(t,[]),this.source.get(e,this.tileSize).then(l=>{this.cache.set(t,{used:performance.now(),data:l});let s=this.inflight.get(t);if(s)for(let c of s)c.resolve(l);if(this.inflight.delete(t),r(l),this.cache.size>=64){let c=1/0,d;this.cache.forEach((u,g)=>{u.used{let s=this.inflight.get(t);if(s)for(let c of s)c.reject(l);this.inflight.delete(t),a(l)}))}})})}queryFeatures(e,t,r,a){let n=wa([t,e]),o=new S((n.x+Be)/(Be*2),1-(n.y+Be)/(Be*2));o.x>1&&(o.x=o.x-Math.floor(o.x));let l=o.mult(1<(i[i.Left=1]="Left",i[i.Center=2]="Center",i[i.Right=3]="Right",i))(ka||{}),za=(i=>(i[i.N=1]="N",i[i.Ne=2]="Ne",i[i.E=3]="E",i[i.Se=4]="Se",i[i.S=5]="S",i[i.Sw=6]="Sw",i[i.W=7]="W",i[i.Nw=8]="Nw",i))(za||{}),Fn=m((i,e,t)=>{let r=document.createElement("canvas"),a=r.getContext("2d");return r.width=i,r.height=e,a!==null&&t(r,a),r},"createPattern"),hi=class{constructor(e){var t;this.pattern=e.pattern,this.fill=new I(e.fill,"black"),this.opacity=new P(e.opacity,1),this.stroke=new I(e.stroke,"black"),this.width=new P(e.width,0),this.perFeature=(t=this.fill.perFeature||this.opacity.perFeature||this.stroke.perFeature||this.width.perFeature||e.perFeature)!=null?t:!1,this.doStroke=!1}before(e,t){if(!this.perFeature){e.globalAlpha=this.opacity.get(t),e.fillStyle=this.fill.get(t),e.strokeStyle=this.stroke.get(t);let r=this.width.get(t);r>0&&(this.doStroke=!0),e.lineWidth=r}if(this.pattern){let r=e.createPattern(this.pattern,"repeat");r&&(e.fillStyle=r)}}draw(e,t,r,a){let n=!1;if(this.perFeature){e.globalAlpha=this.opacity.get(r,a),e.fillStyle=this.fill.get(r,a);let l=this.width.get(r,a);l&&(n=!0,e.strokeStyle=this.stroke.get(r,a),e.lineWidth=l)}let o=m(()=>{e.fill(),(n||this.doStroke)&&e.stroke()},"drawPath");e.beginPath();for(let l of t)for(let s=0;s{let r=t-i;return r>=0&&r{if(e.length<1)return 0;if(t<=e[0][0])return e[0][1];if(t>=e[e.length-1][0])return e[e.length-1][1];let r=di(t,e),a=ui(t,r,i,e);return fi(a,e[r][1],e[r+1][1])}}m(Q,"exp");function Sa(i,e){return t=>{if(e.length<1)return 0;let r=i;for(let a=0;a=e[a][0]&&(r=e[a][1]);return r}}m(Sa,"step");function rt(i){return Q(1,i)}m(rt,"linear");var mi=class{constructor(e){var t;this.color=new I(e.color,"black"),this.width=new P(e.width),this.opacity=new P(e.opacity),this.dash=e.dash?new pa(e.dash):null,this.dashColor=new I(e.dashColor,"black"),this.dashWidth=new P(e.dashWidth,1),this.lineCap=new I(e.lineCap,"butt"),this.lineJoin=new I(e.lineJoin,"miter"),this.skip=!1,this.perFeature=!!((t=this.dash)!=null&&t.perFeature||this.color.perFeature||this.opacity.perFeature||this.width.perFeature||this.lineCap.perFeature||this.lineJoin.perFeature||e.perFeature)}before(e,t){this.perFeature||(e.strokeStyle=this.color.get(t),e.lineWidth=this.width.get(t),e.globalAlpha=this.opacity.get(t),e.lineCap=this.lineCap.get(t),e.lineJoin=this.lineJoin.get(t))}draw(e,t,r,a){if(this.skip)return;let n=m(()=>{this.perFeature&&(e.globalAlpha=this.opacity.get(r,a),e.lineCap=this.lineCap.get(r,a),e.lineJoin=this.lineJoin.get(r,a)),this.dash?(e.save(),this.perFeature?(e.lineWidth=this.dashWidth.get(r,a),e.strokeStyle=this.dashColor.get(r,a),e.setLineDash(this.dash.get(r,a))):e.setLineDash(this.dash.get(r)),e.stroke(),e.restore()):(e.save(),this.perFeature&&(e.lineWidth=this.width.get(r,a),e.strokeStyle=this.color.get(r,a)),e.stroke(),e.restore())},"strokePath");e.beginPath();for(let o of t)for(let l=0;l{d.globalAlpha=1,d.drawImage(this.sheet.canvas,o.x,o.y,o.w,o.h,-o.w/2/this.dpr,-o.h/2/this.dpr,o.w/2,o.h/2)},"draw")}]}};m(La,"IconSymbolizer");var pi=class{constructor(e){this.radius=new P(e.radius,3),this.fill=new I(e.fill,"black"),this.stroke=new I(e.stroke,"white"),this.width=new P(e.width,0),this.opacity=new P(e.opacity)}draw(e,t,r,a){e.globalAlpha=this.opacity.get(r,a);let n=this.radius.get(r,a),o=this.width.get(r,a);o>0&&(e.strokeStyle=this.stroke.get(r,a),e.lineWidth=o,e.beginPath(),e.arc(t[0][0].x,t[0][0].y,n+o/2,0,2*Math.PI),e.stroke()),e.fillStyle=this.fill.get(r,a),e.beginPath(),e.arc(t[0][0].x,t[0][0].y,n,0,2*Math.PI),e.fill()}place(e,t,r){let a=t[0],n=new S(t[0][0].x,t[0][0].y),o=this.radius.get(e.zoom,r),l={minX:n.x-o,minY:n.y-o,maxX:n.x+o,maxY:n.y+o};return[{anchor:n,bboxes:[l],draw:m(s=>{this.draw(s,[[new S(0,0)]],e.zoom,r)},"draw")}]}};m(pi,"CircleSymbolizer");var Fa=pi,Ta=class{constructor(e){this.font=new nt(e),this.text=new at(e),this.fill=new I(e.fill,"black"),this.background=new I(e.background,"white"),this.padding=new P(e.padding,0)}place(e,t,r){let a=this.text.get(e.zoom,r);if(!a)return;let n=this.font.get(e.zoom,r);e.scratch.font=n;let o=e.scratch.measureText(a),l=o.width,s=o.actualBoundingBoxAscent,c=o.actualBoundingBoxDescent,d=t[0],u=new S(t[0][0].x,t[0][0].y),g=this.padding.get(e.zoom,r),v={minX:u.x-l/2-g,minY:u.y-s-g,maxX:u.x+l/2+g,maxY:u.y+c+g};return[{anchor:u,bboxes:[v],draw:m(b=>{b.globalAlpha=1,b.fillStyle=this.background.get(e.zoom,r),b.fillRect(-l/2-g,-s-g,l+2*g,s+c+2*g),b.fillStyle=this.fill.get(e.zoom,r),b.font=n,b.fillText(a,-l/2,0)},"draw")}]}};m(Ta,"ShieldSymbolizer");var Da=class{constructor(e){this.list=e}place(e,t,r){let a=this.list[0].place(e,t,r);if(!a)return;let n=a[0],o=n.anchor,l=n.bboxes[0],s=l.maxY-l.minY,c=[{draw:n.draw,translate:{x:0,y:0}}],d=[[new S(t[0][0].x,t[0][0].y+s)]];for(let u=1;u{for(let g of c)u.save(),u.translate(g.translate.x,g.translate.y),g.draw(u),u.restore()},"draw")}]}};m(Da,"FlexSymbolizer");var gi=m((i,e)=>({minX:Math.min(i.minX,e.minX),minY:Math.min(i.minY,e.minY),maxX:Math.max(i.maxX,e.maxX),maxY:Math.max(i.maxY,e.maxY)}),"mergeBbox"),yi=class{constructor(e){this.list=e}place(e,t,r){let a=this.list[0];if(!a)return;let n=a.place(e,t,r);if(!n)return;let o=n[0],l=o.anchor,s=o.bboxes[0],c=[o.draw];for(let d=1;d{for(let u of c)u(d)},"draw")}]}};m(yi,"GroupSymbolizer");var Ca=yi,xi=class{constructor(e){this.symbolizer=e}place(e,t,r){let a=t[0][0],n=this.symbolizer.place(e,[[new S(0,0)]],r);if(!n||n.length===0)return;let o=n[0],l=o.bboxes[0],s=l.maxX-l.minX,c=l.maxY-l.minY,d={minX:a.x-s/2,maxX:a.x+s/2,minY:a.y-c/2,maxY:a.y+c/2};return[{anchor:a,bboxes:[d],draw:m(u=>{u.translate(-s/2,c/2-l.maxY),o.draw(u,{justify:2})},"draw")}]}};m(xi,"CenteredSymbolizer");var Pa=xi,ja=class{constructor(e,t){this.padding=new P(e,0),this.symbolizer=t}place(e,t,r){let a=this.symbolizer.place(e,t,r);if(!a||a.length===0)return;let n=this.padding.get(e.zoom,r);for(let o of a)for(let l of o.bboxes)l.minX-=n,l.minY-=n,l.maxX+=n,l.maxY+=n;return a}};m(ja,"Padding");var _i=class{constructor(e){this.font=new nt(e),this.text=new at(e),this.fill=new I(e.fill,"black"),this.stroke=new I(e.stroke,"black"),this.width=new P(e.width,0),this.lineHeight=new P(e.lineHeight,1),this.letterSpacing=new P(e.letterSpacing,0),this.maxLineCodeUnits=new P(e.maxLineChars,15),this.justify=e.justify}place(e,t,r){let a=this.text.get(e.zoom,r);if(!a)return;let n=this.font.get(e.zoom,r);e.scratch.font=n;let o=this.letterSpacing.get(e.zoom,r),l=ot(a,this.maxLineCodeUnits.get(e.zoom,r)),s="",c=0;for(let h of l)h.length>c&&(c=h.length,s=h);let d=e.scratch.measureText(s),u=d.width+o*(c-1),g=d.actualBoundingBoxAscent,v=d.actualBoundingBoxDescent,b=(g+v)*this.lineHeight.get(e.zoom,r),M=new S(t[0][0].x,t[0][0].y),f={minX:M.x,minY:M.y-g,maxX:M.x+u,maxY:M.y+v+(l.length-1)*b};return[{anchor:M,bboxes:[f],draw:m((h,p)=>{h.globalAlpha=1,h.font=n,h.fillStyle=this.fill.get(e.zoom,r);let x=this.width.get(e.zoom,r),y=0;for(let _ of l){let k=0;if(this.justify===2||p&&p.justify===2?k=(u-h.measureText(_).width)/2:(this.justify===3||p&&p.justify===3)&&(k=u-h.measureText(_).width),x)if(h.lineWidth=x*2,h.strokeStyle=this.stroke.get(e.zoom,r),o>0){let w=k;for(let z of _)h.strokeText(z,w,y),w+=h.measureText(z).width+o}else h.strokeText(_,k,y);if(o>0){let w=k;for(let z of _)h.fillText(z,w,y),w+=h.measureText(z).width+o}else h.fillText(_,k,y);y+=b}},"draw")}]}};m(_i,"TextSymbolizer");var bi=_i,wi=class{constructor(e){this.centered=new Pa(new bi(e))}place(e,t,r){return this.centered.place(e,t,r)}};m(wi,"CenteredTextSymbolizer");var ke=wi,vi=class{constructor(e,t){var r,a,n;this.symbolizer=e,this.offsetX=new P(t.offsetX,0),this.offsetY=new P(t.offsetY,0),this.justify=(r=t.justify)!=null?r:void 0,this.placements=(a=t.placements)!=null?a:[2,6,8,4,1,3,5,7],this.ddValues=(n=t.ddValues)!=null?n:()=>({})}place(e,t,r){if(r.geomType!==1)return;let a=t[0][0],n=this.symbolizer.place(e,[[new S(0,0)]],r);if(!n||n.length===0)return;let o=n[0],l=o.bboxes[0],s=this.offsetX,c=this.offsetY,d=this.justify,u=this.placements,{offsetX:g,offsetY:v,justify:b,placements:M}=this.ddValues(e.zoom,r)||{};g&&(s=new P(g,0)),v&&(c=new P(v,0)),b&&(d=b),M&&(u=M);let f=s.get(e.zoom,r),h=c.get(e.zoom,r),p=m((w,z)=>({minX:w.x+z.x+l.minX,minY:w.y+z.y+l.minY,maxX:w.x+z.x+l.maxX,maxY:w.y+z.y+l.maxY}),"getBbox"),x=new S(f,h),y,_=m(w=>{w.translate(x.x,x.y),o.draw(w,{justify:y})},"draw"),k=m((w,z)=>{let F=p(w,z);if(!e.index.bboxCollides(F,e.order))return[{anchor:a,bboxes:[F],draw:_}]},"placeLabelInPoint");for(let w of u){let z=this.computeXaxisOffset(f,l,w),F=this.computeYaxisOffset(h,l,w);return y=this.computeJustify(d,w),x=new S(z,F),k(a,x)}}computeXaxisOffset(e,t,r){let a=t.maxX,n=a/2;return[1,5].includes(r)?e-n:[8,7,6].includes(r)?e-a:e}computeYaxisOffset(e,t,r){let a=Math.abs(t.minY),n=t.maxY,o=(t.minY+t.maxY)/2;return[3,7].includes(r)?e-o:[8,2,1].includes(r)?e-n:[6,4,5].includes(r)?e+a:e}computeJustify(e,t){return e||([1,5].includes(t)?2:[2,3,4].includes(t)?1:3)}};m(vi,"OffsetSymbolizer");var Ba=vi,ki=class{constructor(e){this.symbolizer=new Ba(new bi(e),e)}place(e,t,r){return this.symbolizer.place(e,t,r)}};m(ki,"OffsetTextSymbolizer");var Va=ki,$a=(i=>(i[i.Above=1]="Above",i[i.Center=2]="Center",i[i.Below=3]="Below",i))($a||{}),zi=class{constructor(e){var t;this.font=new nt(e),this.text=new at(e),this.fill=new I(e.fill,"black"),this.stroke=new I(e.stroke,"black"),this.width=new P(e.width,0),this.offset=new P(e.offset,0),this.position=(t=e.position)!=null?t:1,this.maxLabelCodeUnits=new P(e.maxLabelChars,40),this.repeatDistance=new P(e.repeatDistance,250)}place(e,t,r){let a=this.text.get(e.zoom,r);if(!a||a.length>this.maxLabelCodeUnits.get(e.zoom,r))return;let n=20,o=r.bbox;if(o.maxY-o.minY4&&(u*=1<({minX:y.x-g/2,minY:y.y-g/2,maxX:y.x+g/2,maxY:y.y+g/2})),x=m(y=>{y.globalAlpha=1,y.rotate(Math.atan2(h,f)),f<0&&(y.scale(-1,-1),y.translate(-c,0));let _=0;this.position===3?_+=d:this.position===2&&(_+=d/2),y.translate(0,_-this.offset.get(e.zoom,r)),y.font=l;let k=this.width.get(e.zoom,r);k&&(y.lineWidth=k,y.strokeStyle=this.stroke.get(e.zoom,r),y.strokeText(a,0,0)),y.fillStyle=this.fill.get(e.zoom,r),y.fillText(a,0,0)},"draw");b.push({anchor:M.start,bboxes:p,draw:x,deduplicationKey:a,deduplicationDistance:u})}return b}};m(zi,"LineLabelSymbolizer");var Qe=zi,X=m((i,e)=>{let t=i[e];return typeof t=="string"?t:""},"getString"),Ht=m((i,e)=>{let t=i[e];return typeof t=="number"?t:0},"getNumber"),Mi=m(i=>[{dataLayer:"earth",symbolizer:new B({fill:i.earth})},...i.landcover?[{dataLayer:"landcover",symbolizer:new B({fill:m((e,t)=>{let r=i.landcover;if(!r||!t)return"";let a=X(t.props,"kind");return a==="grassland"?r.grassland:a==="barren"?r.barren:a==="urban_area"?r.urban_area:a==="farmland"?r.farmland:a==="glacier"?r.glacier:a==="scrub"?r.scrub:r.forest},"fill"),opacity:m((e,t)=>e===8?.5:1,"opacity")})}]:[],{dataLayer:"landuse",symbolizer:new B({fill:m((e,t)=>Fe(i.park_a,i.park_b,Math.min(Math.max(e/12,12),0)),"fill")}),filter:m((e,t)=>{let r=X(t.props,"kind");return["allotments","village_green","playground"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.park_b,opacity:m((e,t)=>e<8?0:e===8?.5:1,"opacity")}),filter:m((e,t)=>{let r=X(t.props,"kind");return["national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.hospital}),filter:m((e,t)=>t.props.kind==="hospital","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.industrial}),filter:m((e,t)=>t.props.kind==="industrial","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.school}),filter:m((e,t)=>{let r=X(t.props,"kind");return["school","university","college"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.beach}),filter:m((e,t)=>t.props.kind==="beach","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.zoo}),filter:m((e,t)=>t.props.kind==="zoo","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.zoo}),filter:m((e,t)=>{let r=X(t.props,"kind");return["military","naval_base","airfield"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:m((e,t)=>Fe(i.wood_a,i.wood_b,Math.min(Math.max(e/12,12),0)),"fill"),opacity:m((e,t)=>e<8?0:e===8?.5:1,"opacity")}),filter:m((e,t)=>{let r=X(t.props,"kind");return["wood","nature_reserve","forest"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:m((e,t)=>Fe(i.scrub_a,i.scrub_b,Math.min(Math.max(e/12,12),0)),"fill")}),filter:m((e,t)=>{let r=X(t.props,"kind");return["scrub","grassland","grass"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.scrub_b}),filter:m((e,t)=>{let r=X(t.props,"kind");return["scrub","grassland","grass"].includes(r)},"filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.glacier}),filter:m((e,t)=>t.props.kind==="glacier","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.sand,opacity:m((e,t)=>e<8?0:e===8?.5:1,"opacity")}),filter:m((e,t)=>t.props.kind==="sand","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.aerodrome}),filter:m((e,t)=>t.props.kind==="aerodrome","filter")},{dataLayer:"water",symbolizer:new B({fill:i.water}),filter:m((e,t)=>t.geomType===3,"filter")},{dataLayer:"roads",symbolizer:new N({color:i.runway,width:m((e,t)=>Q(1.6,[[11,0],[13,4],[19,30]])(e),"width")}),filter:m((e,t)=>t.props.kind_detail==="runway","filter")},{dataLayer:"roads",symbolizer:new N({color:i.runway,width:m((e,t)=>Q(1.6,[[14,0],[14.5,1],[16,6]])(e),"width")}),filter:m((e,t)=>t.props.kind_detail==="taxiway","filter")},{dataLayer:"roads",symbolizer:new N({color:i.pier,width:m((e,t)=>Q(1.6,[[13,0],[13.5,0,5],[21,16]])(e),"width")}),filter:m((e,t)=>t.props.kind==="path"&&t.props.kind_detail==="pier","filter")},{dataLayer:"water",minzoom:14,symbolizer:new N({color:i.water,width:m((e,t)=>Q(1.6,[[9,0],[9.5,1],[18,12]])(e),"width")}),filter:m((e,t)=>t.geomType===2&&t.props.kind==="river","filter")},{dataLayer:"water",minzoom:14,symbolizer:new N({color:i.water,width:.5}),filter:m((e,t)=>t.geomType===2&&t.props.kind==="stream","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.pedestrian}),filter:m((e,t)=>t.props.kind==="pedestrian","filter")},{dataLayer:"landuse",symbolizer:new B({fill:i.pier}),filter:m((e,t)=>t.props.kind==="pier","filter")},{dataLayer:"buildings",symbolizer:new B({fill:i.buildings,opacity:.5})},{dataLayer:"roads",symbolizer:new N({color:i.major,width:m((e,t)=>Q(1.6,[[14,0],[20,7]])(e),"width")}),filter:m((e,t)=>{let r=X(t.props,"kind");return["other","path"].includes(r)},"filter")},{dataLayer:"roads",symbolizer:new N({color:i.major,width:m((e,t)=>Q(1.6,[[13,0],[18,8]])(e),"width")}),filter:m((e,t)=>t.props.kind==="minor_road","filter")},{dataLayer:"roads",symbolizer:new N({color:i.major,width:m((e,t)=>Q(1.6,[[6,0],[12,1.6],[15,3],[18,13]])(e),"width")}),filter:m((e,t)=>t.props.kind==="major_road","filter")},{dataLayer:"roads",symbolizer:new N({color:i.major,width:m((e,t)=>Q(1.6,[[3,0],[6,1.1],[12,1.6],[15,5],[18,15]])(e),"width")}),filter:m((e,t)=>t.props.kind==="highway","filter")},{dataLayer:"boundaries",symbolizer:new N({color:i.boundaries,width:1}),filter:m((e,t)=>{let r=t.props.kind_detail;return typeof r=="number"&&r<=2},"filter")},{dataLayer:"roads",symbolizer:new N({dash:[.3,.75],color:i.railway,dashWidth:m((e,t)=>Q(1.6,[[4,0],[7,.15],[19,9]])(e),"dashWidth"),opacity:.5}),filter:m((e,t)=>t.props.kind==="rail","filter")},{dataLayer:"boundaries",symbolizer:new N({color:i.boundaries,width:.5}),filter:m((e,t)=>{let r=t.props.kind_detail;return typeof r=="number"&&r>2},"filter")}],"paintRules"),Si=m((i,e)=>{let t=[`name:${e}`,"name"];return[{dataLayer:"roads",symbolizer:new Qe({labelProps:t,fill:i.roads_label_minor,font:"400 12px sans-serif",width:2,stroke:i.roads_label_minor_halo}),minzoom:16,filter:m((r,a)=>{let n=X(a.props,"kind");return["minor_road","other","path"].includes(n)},"filter")},{dataLayer:"roads",symbolizer:new Qe({labelProps:t,fill:i.roads_label_major,font:"400 12px sans-serif",width:2,stroke:i.roads_label_major_halo}),minzoom:12,filter:m((r,a)=>{let n=X(a.props,"kind");return["highway","major_road"].includes(n)},"filter")},{dataLayer:"roads",symbolizer:new Qe({labelProps:t,fill:i.roads_label_major,font:"400 12px sans-serif",width:2,stroke:i.roads_label_major_halo}),minzoom:12,filter:m((r,a)=>{let n=X(a.props,"kind");return["highway","major_road"].includes(n)},"filter")},{dataLayer:"water",symbolizer:new ke({labelProps:t,fill:i.ocean_label,lineHeight:1.5,letterSpacing:1,font:m((r,a)=>`400 ${rt([[3,10],[10,12]])(r)}px sans-serif`,"font"),textTransform:"uppercase"}),filter:m((r,a)=>{let n=X(a.props,"kind");return a.geomType===1&&["ocean","bay","strait","fjord"].includes(n)},"filter")},{dataLayer:"water",symbolizer:new ke({labelProps:t,fill:i.ocean_label,lineHeight:1.5,letterSpacing:1,font:m((r,a)=>`400 ${rt([[3,10],[6,12],[10,12]])(r)}px sans-serif`,"font")}),filter:m((r,a)=>{let n=X(a.props,"kind");return a.geomType===1&&["sea","lake","water"].includes(n)},"filter")},{dataLayer:"places",symbolizer:new ke({labelProps:m((r,a)=>r<6?[`ref:${e}`,"ref"]:t,"labelProps"),fill:i.state_label,stroke:i.state_label_halo,width:1,lineHeight:1.5,font:m((r,a)=>"400 12px sans-serif","font"),textTransform:"uppercase"}),filter:m((r,a)=>a.props.kind==="region","filter")},{dataLayer:"places",symbolizer:new ke({labelProps:t,fill:i.country_label,lineHeight:1.5,font:m((r,a)=>(r<6,"600 12px sans-serif"),"font"),textTransform:"uppercase"}),filter:m((r,a)=>a.props.kind==="country","filter")},{dataLayer:"places",minzoom:9,symbolizer:new ke({labelProps:t,fill:i.city_label,lineHeight:1.5,font:m((r,a)=>{if(!a)return"400 12px sans-serif";let n=a.props.min_zoom,o=400;n&&n<=5&&(o=600);let l=12,s=a.props.population_rank;return s&&s>9&&(l=16),`${o} ${l}px sans-serif`},"font")}),sort:m((r,a)=>{let n=Ht(r,"min_zoom"),o=Ht(a,"min_zoom");return n-o},"sort"),filter:m((r,a)=>a.props.kind==="locality","filter")},{dataLayer:"places",maxzoom:8,symbolizer:new Ca([new Fa({radius:2,fill:i.city_label,stroke:i.city_label_halo,width:1.5}),new Va({labelProps:t,fill:i.city_label,stroke:i.city_label_halo,width:1,offsetX:6,offsetY:4.5,font:m((r,a)=>"400 12px sans-serif","font")})]),filter:m((r,a)=>a.props.kind==="locality","filter")}]},"labelRules"),Fi=m((i,e,t)=>{let r=[];for(let a of i){let n=[];for(let o of a)n.push(o.clone().mult(e).add(t));r.push(n)}return r},"transformGeom"),Ve=m((i,e)=>{let t=1<=t?i%t:i},"wrap"),Ti=class{constructor(e,t,r){this.tileCache=e,this.maxDataLevel=t,this.levelDiff=r}dataTilesForBounds(e,t){let r=E(2,e)/E(2,Math.ceil(e)),a=[],n=1,o=this.tileCache.tileSize;if(ethis.tileCache.get(a.dataTile)))).map((a,n)=>{let o=r[n];return{data:a,z:e,dataTile:o.dataTile,scale:o.scale,dim:o.dim,origin:o.origin}})})}getDisplayTile(e){return q(this,null,function*(){let t=this.dataTileForDisplayTile(e);return{data:yield this.tileCache.get(t.dataTile),z:e.z,dataTile:t.dataTile,scale:t.scale,origin:t.origin,dim:t.dim}})}queryFeatures(e,t,r,a){let n=Math.round(r),o=Math.min(n-this.levelDiff,this.maxDataLevel),l=a/(1<{let e=m(r=>{let a=r.levelDiff===void 0?1:r.levelDiff,n=r.maxDataZoom||15,o;if(typeof r.url=="string")new URL(r.url,"http://example.com").pathname.endsWith(".pmtiles")?o=new At(r.url,!0):o=new ba(r.url,!0);else if(r.url)o=new At(r.url,!0);else throw new Error(`Invalid source ${r.url}`);let l=new va(o,256*1<{let r=e/256,a=Math.floor(t.minX/256),n=Math.floor(t.minY/256),o=Math.floor(t.maxX/256),l=Math.floor(t.maxY/256),s=Math.log2(r),c=[];for(let d=a;d<=o;d++){let u=d%(1<this.dim&&(l=!0);if(o||l){let s=o?this.dim:-this.dim,c=[];for(let g of e.bboxes)c.push({minX:g.minX+s,minY:g.minY,maxX:g.maxX+s,maxY:g.maxY});let d={anchor:new S(e.anchor.x+s,e.anchor.y),bboxes:c,draw:e.draw,order:t,tileKey:r},u=this.current.get(r);u&&u.add(d);for(let g of c)this.tree.insert({minX:g.minX,minY:g.minY,maxX:g.maxX,maxY:g.maxY,indexedLabel:d})}}pruneOrNoop(e){let t=e.split(":"),r,a=0,n=0;for(let o of this.current.keys()){let l=o.split(":");if(l[3]===t[3]){n++;let s=Math.sqrt(E(+l[0]-+t[0],2)+E(+l[1]-+t[1],2));s>a&&(a=s,r=o)}r&&n>this.maxLabeledTiles&&this.pruneKey(r)}}pruneKey(e){let t=this.current.get(e);if(!t)return;let r=[];for(let a of this.tree.all())t.has(a.indexedLabel)&&r.push(a);for(let a of r)this.tree.remove(a);this.current.delete(e)}removeLabel(e){let t=[];for(let a of this.tree.all())e===a.indexedLabel&&t.push(a);for(let a of t)this.tree.remove(a);let r=this.current.get(e.tileKey);r&&r.delete(e)}};m(Ci,"Index");var Xa=Ci,Pi=class{constructor(e,t,r,a,n){this.index=new Xa(256*1<o.maxzoom)continue;let l=o.dataSource||"",s=e.get(l);if(s)for(let c of s){let d=`${ae(c.dataTile)}:${l}`;if(!r.has(d))continue;let u=c.data.get(o.dataLayer);if(u===void 0)continue;let g=u;o.sort&&g.sort((b,M)=>o.sort?o.sort(b.props,M.props):0);let v={index:this.index,zoom:this.z,scratch:this.scratch,order:n,overzoom:this.z-c.dataTile.z};for(let b of g){if(o.filter&&!o.filter(this.z,b))continue;let M=Fi(b.geom,c.scale,c.origin),f=o.symbolizer.place(v,M,b);if(f)for(let h of f){let p=!1;if(!(h.deduplicationKey&&this.index.deduplicationCollides(h))){if(this.index.labelCollides(h,1/0)){if(!this.index.labelCollides(h,n)){let x=this.index.searchLabel(h,1/0);for(let y of x){this.index.removeLabel(y);for(let _ of y.bboxes)this.findInvalidatedTiles(a,c.dim,_,d)}this.index.insert(h,n,d),p=!0}}else this.index.insert(h,n,d),p=!0;if(p)for(let x of h.bboxes)(x.maxX>c.origin.x+c.dim||x.minXc.origin.y+c.dim)&&this.findInvalidatedTiles(a,c.dim,x,d)}}}}}for(let n of r)this.index.pruneOrNoop(n);return a.size>0&&this.callback&&this.callback(a),performance.now()-t}findInvalidatedTiles(e,t,r,a){let n=Ya(this.z,t,r);for(let o of n)o.key!==a&&this.index.hasPrefix(o.key)&&e.add(o.display)}add(e){let t=!0;for(let[r,a]of e)for(let n of a)this.index.has(`${ae(n.dataTile)}:${r}`)||(t=!1);return t?0:this.layout(e)}};m(Pi,"Labeler");var ji=Pi,Bi=class{constructor(e,t,r,a){this.labelers=new Map,this.scratch=e,this.labelRules=t,this.maxLabeledTiles=r,this.callback=a}add(e,t){let r=this.labelers.get(e);return r||(r=new ji(e,this.scratch,this.labelRules,this.maxLabeledTiles,this.callback),this.labelers.set(e,r)),r.add(t)}getIndex(e){let t=this.labelers.get(e);if(t)return t.index}};m(Bi,"Labelers");var Nt=Bi;function st(i,e,t,r,a,n,o,l,s){let c=performance.now();i.save(),i.miterLimit=2;for(let d of a){if(d.minzoom&&ed.maxzoom)continue;let u=t.get(d.dataSource||"");if(u)for(let g of u){let v=g.data.get(d.dataLayer);if(v===void 0)continue;d.symbolizer.before&&d.symbolizer.before(i,g.z);let b=g.origin,M=g.dim,f=g.scale;if(i.save(),l){i.beginPath();let h=Math.max(b.x-o.x,n.minX-o.x),p=Math.max(b.y-o.y,n.minY-o.y),x=Math.min(b.x-o.x+M,n.maxX-o.x),y=Math.min(b.y-o.y+M,n.maxY-o.y);i.rect(h,p,x-h,y-p),i.clip()}i.translate(b.x-o.x,b.y-o.y);for(let h of v){let p=h.geom,x=h.bbox;x.maxX*f+b.xn.maxX||x.minY*f+b.y>n.maxY||x.maxY*f+b.y{let e=Math.PI/180,t=Math.max(Math.min(qt,i.y),-qt),r=Math.sin(t*e);return new S(Me*i.x*e,Me*Math.log((1+r)/(1-r))/2)},"project"),Ia=m(i=>{let e=180/Math.PI;return{lat:(2*Math.atan(Math.exp(i.y/Me))-Math.PI/2)*e,lng:i.x*e/Me}},"unproject"),Ra=m((i,e)=>t=>{let r=Vi(t);return new S((r.x+O)/(O*2),1-(r.y+O)/(O*2)).mult(E(2,e)*256).sub(i)},"instancedProject"),Aa=m((i,e)=>t=>{let r=new S(t.x,t.y).add(i).div(E(2,e)*256),a=new S(r.x*(O*2)-O,(1-r.y)*(O*2)-O);return Ia(a)},"instancedUnproject"),Ot=m((i,e)=>{let t=e*(360/i);return Math.log2(t/256)},"getZoom"),Ua=class{constructor(e){if(e.flavor){let t=me(e.flavor);this.paintRules=Mi(t),this.labelRules=Si(t,e.lang||"en"),this.backgroundColor=t.background}else this.paintRules=e.paintRules||[],this.labelRules=e.labelRules||[],this.backgroundColor=e.backgroundColor;this.views=Di(e),this.debug=e.debug||""}drawContext(e,t,r,a,n){return q(this,null,function*(){let o=Vi(a),l=new S((o.x+O)/(O*2),1-(o.y+O)/(O*2)).clone().mult(E(2,n)*256).sub(new S(t/2,r/2)),s={minX:l.x,minY:l.y,maxX:l.x+t,maxY:l.y+r},c=[];for(let[h,p]of this.views){let x=p.getBbox(n,s);c.push({key:h,promise:x})}let d=yield Promise.all(c.map(h=>h.promise.then(p=>({status:"fulfilled",value:p,key:h.key}),p=>({status:"rejected",value:[],reason:p,key:h.key})))),u=new Map;for(let h of d)h.status==="fulfilled"&&u.set(h.key,h.value);let g=performance.now(),v=new ji(n,e,this.labelRules,16,void 0),b=v.add(u);this.backgroundColor&&(e.save(),e.fillStyle=this.backgroundColor,e.fillRect(0,0,t,r),e.restore());let M=this.paintRules,f=st(e,n,u,v.index,M,s,l,!0,this.debug);if(this.debug){e.save(),e.translate(-l.x,-l.y),e.strokeStyle=this.debug,e.fillStyle=this.debug,e.font="12px sans-serif";let h=0;for(let[p,x]of u){for(let y of x){e.strokeRect(y.origin.x,y.origin.y,y.dim,y.dim);let _=y.dataTile;e.fillText(`${p+(p?" ":"")+_.z} ${_.x} ${_.y}`,y.origin.x+4,y.origin.y+14*(1+h))}h++}e.restore()}return{elapsed:performance.now()-g,project:Ra(l,n),unproject:Aa(l,n)}})}drawCanvas(e,t,r){return q(this,arguments,function*(a,n,o,l={}){let s=window.devicePixelRatio,c=a.clientWidth,d=a.clientHeight;a.width===c*s&&a.height===d*s||(a.width=c*s,a.height=d*s),l.lang&&(a.lang=l.lang);let u=a.getContext("2d");if(!u){console.error("Failed to initialize canvas2d context.");return}return u.setTransform(s,0,0,s,0,0),this.drawContext(u,c,d,n,o)})}drawContextBounds(e,t,r,a,n){return q(this,null,function*(){let o=r.x-t.x,l=new S((t.x+r.x)/2,(t.y+r.y)/2);return this.drawContext(e,a,n,l,Ot(o,a))})}drawCanvasBounds(e,t,r,a){return q(this,arguments,function*(n,o,l,s,c={}){let d=l.x-o.x,u=new S((o.x+l.x)/2,(o.y+l.y)/2);return this.drawCanvas(n,u,Ot(d,s),c)})}};m(Ua,"Static");var Ha=m(i=>new Promise(e=>{setTimeout(()=>{e()},i)}),"timer"),Na=m(i=>i.then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e})),"reflect"),$i=m((i={})=>{let e=class extends L.GridLayer{constructor(a={}){var n;if(a.noWrap&&!a.bounds&&(a.bounds=[[-90,-180],[90,180]]),a.attribution==null&&(a.attribution='Protomaps \xA9 OpenStreetMap'),super(a),a.flavor){let l=me(a.flavor);this.paintRules=Mi(l),this.labelRules=Si(l,a.lang||"en"),this.backgroundColor=l.background}else this.paintRules=a.paintRules||[],this.labelRules=a.labelRules||[],this.backgroundColor=a.backgroundColor;this.devicePixelRatio=(n=a.devicePixelRatio)!=null?n:window.devicePixelRatio,this.lastRequestedZ=void 0,this.tasks=a.tasks||[],this.views=Di(a),this.debug=a.debug;let o=document.createElement("canvas").getContext("2d");this.scratch=o,this.onTilesInvalidated=l=>{for(let s of l)this.rerenderTile(s)},this.labelers=new Nt(this.scratch,this.labelRules,16,this.onTilesInvalidated),this.tileSize=256*this.devicePixelRatio,this.tileDelay=a.tileDelay||3,this.lang=a.lang}renderTile(a,n,o,l=()=>{}){return q(this,null,function*(){this.lastRequestedZ=a.z;let s=[];for(let[w,z]of this.views){let F=z.getDisplayTile(a);s.push({key:w,promise:F})}let c=yield Promise.all(s.map(w=>w.promise.then(z=>({status:"fulfilled",value:z,key:w.key}),z=>({status:"rejected",reason:z,key:w.key})))),d=new Map;for(let w of c)w.status==="fulfilled"?d.set(w.key,[w.value]):w.reason.name==="AbortError"||console.error(w.reason);if(n.key!==o||this.lastRequestedZ!==a.z||(yield Promise.all(this.tasks.map(Na)),n.key!==o)||this.lastRequestedZ!==a.z)return;let u=this.labelers.add(a.z,d);if(n.key!==o||this.lastRequestedZ!==a.z)return;let g=this.labelers.getIndex(a.z);if(!this._map)return;let v=this._map.getCenter().wrap(),b=this._getTiledPixelBounds(v),M=this._pxBoundsToTileRange(b).getCenter(),f=a.distanceTo(M)*this.tileDelay;if(yield Ha(f),n.key!==o||this.lastRequestedZ!==a.z)return;let h=16,p={minX:256*a.x-h,minY:256*a.y-h,maxX:256*(a.x+1)+h,maxY:256*(a.y+1)+h},x=new S(256*a.x,256*a.y);n.width=this.tileSize,n.height=this.tileSize;let y=n.getContext("2d");if(!y){console.error("Failed to get Canvas context");return}y.setTransform(this.tileSize/256,0,0,this.tileSize/256,0,0),y.clearRect(0,0,256,256),this.backgroundColor&&(y.save(),y.fillStyle=this.backgroundColor,y.fillRect(0,0,256,256),y.restore());let _=0,k=this.paintRules;if(_=st(y,a.z,d,this.xray?null:g,k,p,x,!1,this.debug),this.debug){y.save(),y.fillStyle=this.debug,y.font="600 12px sans-serif",y.fillText(`${a.z} ${a.x} ${a.y}`,4,14),y.font="12px sans-serif";let w=28;for(let[z,F]of d){let T=F[0].dataTile;y.fillText(`${z+(z?" ":"")+T.z} ${T.x} ${T.y}`,4,w),w+=14}y.font="600 10px sans-serif",_>8&&(y.fillText(`${_.toFixed()} ms paint`,4,w),w+=14),u>8&&y.fillText(`${u.toFixed()} ms layout`,4,w),y.strokeStyle=this.debug,y.lineWidth=.5,y.beginPath(),y.moveTo(0,0),y.lineTo(0,256),y.stroke(),y.lineWidth=.5,y.beginPath(),y.moveTo(0,0),y.lineTo(256,0),y.stroke(),y.restore()}l()})}rerenderTile(a){for(let n in this._tiles){let o=this._wrapCoords(this._keyToTileCoords(n));a===this._tileCoordsToKey(o)&&this.renderTile(o,this._tiles[n].el,a)}}queryTileFeaturesDebug(a,n,o=16){let l=new Map;for(let[s,c]of this.views)l.set(s,c.queryFeatures(a,n,this._map.getZoom(),o));return l}clearLayout(){this.labelers=new Nt(this.scratch,this.labelRules,16,this.onTilesInvalidated)}rerenderTiles(){for(let a in this._tiles){let n=this._wrapCoords(this._keyToTileCoords(a)),o=this._tileCoordsToKey(n);this.renderTile(n,this._tiles[a].el,o)}}createTile(a,n){let o=L.DomUtil.create("canvas","leaflet-tile");o.lang=this.lang;let l=this._tileCoordsToKey(a);return o.key=l,this.renderTile(a,o,l,()=>{n(void 0,o)}),o}_removeTile(a){let n=this._tiles[a];n&&(n.el.removed=!0,n.el.key=void 0,L.DomUtil.removeClass(n.el,"leaflet-tile-loaded"),n.el.width=n.el.height=0,L.DomUtil.remove(n.el),delete this._tiles[a],this.fire("tileunload",{tile:n.el,coords:this._keyToTileCoords(a)}))}};m(e,"LeafletLayer");let t=e;return new t(i)},"leafletLayer"),to=m((i,e,t)=>{let r=new FontFace(i,`url(${e})`,{weight:t});return document.fonts.add(r),r.load()},"Font"),Wt=m(i=>q(void 0,null,function*(){return new Promise((e,t)=>{let r=new Image;r.onload=()=>e(r),r.onerror=()=>t("Invalid SVG"),r.src=i})}),"mkimg"),qa=` + + + + + + +`,Oa=class{constructor(e){this.src=e,this.canvas=document.createElement("canvas"),this.mapping=new Map,this.missingBox={x:0,y:0,w:0,h:0}}load(){return q(this,null,function*(){let e=this.src,t=window.devicePixelRatio;e.endsWith(".html")&&(e=yield(yield fetch(e)).text());let r=new window.DOMParser().parseFromString(e,"text/html"),a=Array.from(r.body.children),n=yield Wt(`data:image/svg+xml;base64,${btoa(qa)}`),o=[{w:n.width*t,h:n.height*t,img:n,id:""}],l=new XMLSerializer;for(let d of a){let u=`data:image/svg+xml;base64,${btoa(l.serializeToString(d))}`,g=yield Wt(u);o.push({w:g.width*t,h:g.height*t,img:g,id:d.id})}let s=Je(o);this.canvas.width=s.w,this.canvas.height=s.h;let c=this.canvas.getContext("2d");if(c)for(let d of o)d.x!==void 0&&d.y!==void 0&&(c.drawImage(d.img,d.x,d.y,d.w,d.h),d.id?this.mapping.set(d.id,{x:d.x,y:d.y,w:d.w,h:d.h}):this.missingBox={x:d.x,y:d.y,w:d.w,h:d.h});return this})}get(e){let t=this.mapping.get(e);return t||(t=this.missingBox),t}};m(Oa,"Sheet");return qi(Wa);})(); diff --git a/bin/check-params.py b/bin/check-params.py index 81009103..0b8c7c7b 100755 --- a/bin/check-params.py +++ b/bin/check-params.py @@ -160,6 +160,9 @@ "video_embeds: [bilibili, youtube]\nmap:\n enable: true\n tiles: https://{s}.tile.example.org/{z}/{x}/{y}{r}.png\n attribution: Example tiles\n attribution_url: https://example.org/copyright\n dark_tiles: https://{s}.tile.example.org/dark/{z}/{x}/{-y}.png\n subdomains: abcd\n max_zoom: 18\n loading: click", # Surrounding whitespace in map values is trimmed, not rejected. "map:\n enable: true\n tiles: ' https://tile.example.org/{z}/{x}/{y}.png '\n attribution: Example\n attribution_url: ' https://example.org/copyright '\n subdomains: ' abc '", + # A Protomaps basemap, archive or template, completes the map without tiles. + "map:\n enable: true\n attribution: Protomaps © OpenStreetMap\n protomaps:\n url: https://tiles.example.org/world.pmtiles\n flavor: grayscale\n dark_flavor: black\n lang: zh-Hans\n max_data_zoom: 14", + "map:\n enable: true\n attribution: Protomaps\n loading: click\n protomaps:\n url: ' https://api.example.org/tiles/v4/{z}/{x}/{y}.mvt?key=abc '", "ui:\n dark_mode: true\n feedback: true\n page_context_menu: false", "ui:\n dark_mode: {enable: true, show_menu: true}\n expo: {mode: cards, size: 200}", "ui:\n share: [x, bluesky, mastodon, whatsapp, line, pinterest, chatgpt, claude, email, copy]", @@ -225,6 +228,18 @@ # Leaflet throws on a placeholder it cannot fill, wherever it appears. ("map:\n enable: true\n tiles: https://tile.example.org/{z}/{x}/{y}.png?key={apikey}\n attribution: Example", "params.map.tiles may use only the {s}, {z}, {x}, {y}, {-y} and {r} placeholders; got {apikey}"), ("map:\n enable: true\n tiles: https://tile.example.org/{z}/{x}/{y}.png\n dark_tiles: https://api.example.org/styles/{id}/{z}/{x}/{y}\n attribution: Example", "params.map.dark_tiles may use only the {s}, {z}, {x}, {y}, {-y} and {r} placeholders; got {id}"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: http://tiles.example.org/world.pmtiles", "params.map.protomaps.url must be an https:// URL"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/world.mvt", "params.map.protomaps.url must be a .pmtiles archive or a template with {z}, {x} and {y}"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/{z}/{x}/{y}.mvt?key={key}", "params.map.protomaps.url may use only {z}, {x} and {y}"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://{z}.example.org/{x}/{y}.mvt", "params.map.protomaps.url may use only {z}, {x} and {y}, and only in the path"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/{z}/world.pmtiles", "params.map.protomaps.url names a .pmtiles archive"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/world.pmtiles\n flavor: sepia", "params.map.protomaps.flavor must be one of light, dark, white, grayscale, black"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/world.pmtiles\n lang: 'zh Hans'", "params.map.protomaps.lang must be a language tag"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/world.pmtiles\n max_data_zoom: 30", "params.map.protomaps.max_data_zoom must be a whole number from 1 to 22"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: https://tiles.example.org/world.pmtiles\n style: dark", 'params.map.protomaps has unknown key "style"'), + ("map:\n enable: true\n attribution: Example\n protomaps: https://tiles.example.org/world.pmtiles", "params.map.protomaps must be a map"), + ("map:\n enable: true\n tiles: https://tile.example.org/{z}/{x}/{y}.png\n attribution: Example\n protomaps:\n url: https://tiles.example.org/world.pmtiles", "params.map.protomaps.url replaces params.map.tiles"), + ("map:\n enable: true\n attribution: Example\n protomaps:\n url: ''", "params.map.enable requires params.map.tiles"), # Discord publishes no share-intent URL, so it stays outside the set no # matter how often it is asked for; WeChat below is the same case. ("ui:\n share: [x, discord]", 'invalid params.ui.share entry "discord"'), @@ -517,8 +532,8 @@ def site_config(params: str) -> str: ) -def build_case(hugo: str, name: str, params: str, front_matter: str) -> tuple[int, str, bool]: - """Build a one-page site; return its exit code, log, and page presence. +def build_case(hugo: str, name: str, params: str, front_matter: str) -> tuple[int, str, str | None]: + """Build a one-page site; return its exit code, log, and page HTML (None if absent). An invalid parameter no longer stops a build: it warns and falls back, so a case is judged on what the output says rather than on whether Hugo exited. @@ -537,7 +552,8 @@ def build_case(hugo: str, name: str, params: str, front_matter: str) -> tuple[in "--destination", str(source / "public"), "--logLevel", "warn"] result = run_hugo_process(command, capture_output=True, text=True, check=False) page = source / "public/docs/page/index.html" - return result.returncode, (result.stdout + result.stderr), page.is_file() + html = page.read_text(encoding="utf-8") if page.is_file() else None + return result.returncode, (result.stdout + result.stderr), html def check_builds(hugo: str) -> list[str]: @@ -556,12 +572,13 @@ def check_builds(hugo: str) -> list[str]: def run(job: tuple[str, str, str, str | None]): name = job[0] origin = "page" if name.startswith("invalid-page-") else "site" - code, output, page_exists = build_case(hugo, name, job[1], job[2]) + code, output, html = build_case(hugo, name, job[1], job[2]) # Every invalid value must warn and keep building. - return job, origin, code, output, page_exists + return job, origin, code, output, html with ThreadPoolExecutor(max_workers=4) as pool: - for (name, params, front, expected), origin, code, output, page_exists in pool.map(run, jobs): + for (name, params, front, expected), origin, code, output, html in pool.map(run, jobs): + page_exists = html is not None label = (params or front).replace("\n", " ") if expected is None: require(code == 0, f"accepted shape failed to build ({label}): {output[-400:]}", errors) @@ -572,6 +589,15 @@ def run(job: tuple[str, str, str, str | None]): # A complete map configuration, placeholders included, is silent. require("params.map" not in output, f"a complete params.map warned ({label}): {output[-400:]}", errors) + # A Protomaps basemap publishes its renderer beside Leaflet + # and names it in the page config; raster maps do neither. + vector = "protomaps:" in params + page = html or "" + require(("third_party/protomaps-leaflet/" in page) == vector + and ('"protomaps":{"' in page) == vector + and "third_party/leaflet/" in page, + f"params.map {'with' if vector else 'without'} protomaps published the wrong map engines ({label})", + errors) continue if name.startswith("invalid-"): require(code == 0, diff --git a/bin/generate-config-schema.py b/bin/generate-config-schema.py index 7ec3150d..1fdc54a9 100755 --- a/bin/generate-config-schema.py +++ b/bin/generate-config-schema.py @@ -282,6 +282,17 @@ def build(check_params) -> dict[str, str]: map_props["loading"]["enum"] = re.findall(r'"([a-z]+)"', map_loading[1]) map_props["max_zoom"]["minimum"] = int(map_zoom[1]) map_props["max_zoom"]["maximum"] = int(map_zoom[2]) + map_flavors = re.search(r'\$flavors\s*:=\s*slice((?:\s+"[a-z]+")+)', map_resolver) + map_data_zoom = re.search( + r'max_data_zoom".*?\(ge\s+\(int\s+\$raw\)\s+(\d+)\)\s+\(le\s+\(int\s+\$raw\)\s+(\d+)\)', + map_resolver, re.S) + if not (map_flavors and map_data_zoom): + raise SystemExit("map-config resolver has no Protomaps flavor slice or max_data_zoom bounds") + protomaps_props = map_props["protomaps"]["properties"] + for key in ("flavor", "dark_flavor"): + protomaps_props[key]["enum"] = re.findall(r'"([a-z]+)"', map_flavors[1]) + protomaps_props["max_data_zoom"]["minimum"] = int(map_data_zoom[1]) + protomaps_props["max_data_zoom"]["maximum"] = int(map_data_zoom[2]) for key, reason in FRONT_SCHEMA_EXCLUDES.items(): if key not in page_keys: diff --git a/bin/vendor/build.mjs b/bin/vendor/build.mjs index e94dddb3..4c97e8db 100644 --- a/bin/vendor/build.mjs +++ b/bin/vendor/build.mjs @@ -19,6 +19,12 @@ export { mathContent, remarkMath } from '@markmap/plugin-math';`, resolveDir: pr stdin: { contents: `export { deflateRaw } from 'pako';`, resolveDir: process.cwd() }, format: 'iife', globalName: 'pako', outfile: 'out/pako/pako_deflate.min.js', }], + // Leaflet stays the page's own global `L`; protomaps-leaflet reads it only + // when a layer is created, so the bundle imports nothing from it. + ['protomaps-leaflet', { + stdin: { contents: `export { leafletLayer } from 'protomaps-leaflet';`, resolveDir: process.cwd() }, + format: 'iife', globalName: 'protomapsL', outfile: 'out/protomaps-leaflet/protomaps-leaflet.min.js', + }], ['external-svg-loader', { entryPoints: ['node_modules/external-svg-loader/svg-loader.js'], format: 'iife', outfile: 'out/external-svg-loader/svg-loader.min.js', diff --git a/bin/vendor/package-lock.json b/bin/vendor/package-lock.json index 4ce4ec02..9748a61c 100644 --- a/bin/vendor/package-lock.json +++ b/bin/vendor/package-lock.json @@ -16,7 +16,8 @@ "esbuild": "0.28.2", "external-svg-loader": "1.7.1", "idb-keyval": "6.3.0", - "pako": "3.0.3" + "pako": "3.0.3", + "protomaps-leaflet": "5.1.0" } }, "node_modules/@esbuild/aix-ppc64": { @@ -441,6 +442,23 @@ "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", "license": "BlueOak-1.0.0" }, + "node_modules/@mapbox/point-geometry": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-1.1.0.tgz", + "integrity": "sha512-YGcBz1cg4ATXDCM/71L9xveh4dynfGmcLDqufR+nQQy3fKwsAZsWd/x4621/6uJaeB9mwOHE6hPeDgXz9uViUQ==", + "license": "ISC" + }, + "node_modules/@mapbox/vector-tile": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-2.0.5.tgz", + "integrity": "sha512-pXj8m7KTsqZt+1jsE0xIpGvqTSbblfkuEJL/NJmNePMtEwxO8V3XMDo9WMSfDeqHvCtBI9Lmt4mGcGR10zecmw==", + "license": "BSD-3-Clause", + "dependencies": { + "@mapbox/point-geometry": "~1.1.0", + "@types/geojson": "^7946.0.16", + "pbf": "^4.0.2" + } + }, "node_modules/@markmap/core": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@markmap/core/-/core-1.1.1.tgz", @@ -533,6 +551,21 @@ "speech-rule-engine": "5.0.0-rc.4" } }, + "node_modules/@protomaps/basemaps": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@protomaps/basemaps/-/basemaps-5.7.2.tgz", + "integrity": "sha512-K1Yk6bWdULulYg+R2QRVXx4NzJZan5YQhpejEG0c1/sXruJrfPIPZuakpf3jwAgVmjIRVQwAv+yRafDeN0aaUQ==", + "license": "BSD-3-Clause", + "bin": { + "generate_style": "src/cli.ts" + } + }, + "node_modules/@types/css-font-loading-module": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@types/css-font-loading-module/-/css-font-loading-module-0.0.7.tgz", + "integrity": "sha512-nl09VhutdjINdWyXxHWN/w9zlNCfr60JUqJbd24YXUuCwgeL0TpFSdElCwb6cxfB6ybE19Gjj4g0jsgkXxKv1Q==", + "license": "MIT" + }, "node_modules/@types/debug": { "version": "4.1.13", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", @@ -542,6 +575,12 @@ "@types/ms": "*" } }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "license": "MIT" + }, "node_modules/@types/hast": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz", @@ -557,6 +596,15 @@ "integrity": "sha512-trgaNyfU+Xh2Tc+ABIb44a5AYUpicB3uwirOioeOkNPPbmgRNtcWyDeeFRzjPZENO9Vq8gvVqfhaaXWLlevVwg==", "license": "MIT" }, + "node_modules/@types/leaflet": { + "version": "1.9.23", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.23.tgz", + "integrity": "sha512-rpvCoR7fQ2I4tFGIDjuyRAXl25e9YiJ9eE7AdJY5aJF8tkgg4ph3fRb9zafM6ZB1YO5LYziZQwh/vW3IOat/+Q==", + "license": "MIT", + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/mdast": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", @@ -572,6 +620,12 @@ "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", "license": "MIT" }, + "node_modules/@types/rbush": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/rbush/-/rbush-3.0.4.tgz", + "integrity": "sha512-knSt9cCW8jj1ZSFcFeBZaX++OucmfPxxHiRwTahZfJlnQsek7O0bazTJHWD2RVj9LEoejUYF2de3/stf+QXcXw==", + "license": "MIT" + }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -936,6 +990,12 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "license": "MIT" + }, "node_modules/flatbush": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/flatbush/-/flatbush-4.7.0.tgz", @@ -2091,6 +2151,34 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/pbf": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-4.0.2.tgz", + "integrity": "sha512-J0ajxARhZfpUEebxYs1vhMGMuLSXtBe1e+fFPDrf2uA2hgo+UshKfNUWOz92HJNz6/NFEXseQPddnHkTreWRqg==", + "license": "BSD-3-Clause", + "dependencies": { + "resolve-protobuf-schema": "^2.1.0" + }, + "bin": { + "pbf": "bin/pbf" + } + }, + "node_modules/pmtiles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-3.2.1.tgz", + "integrity": "sha512-3R4fBwwoli5mw7a6t1IGwOtfmcSAODq6Okz0zkXhS1zi9sz1ssjjIfslwPvcWw5TNhdjNBUg9fgfPLeqZlH6ng==", + "license": "BSD-3-Clause", + "dependencies": { + "@types/leaflet": "^1.9.8", + "fflate": "^0.8.0" + } + }, + "node_modules/potpack": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/potpack/-/potpack-1.0.2.tgz", + "integrity": "sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==", + "license": "ISC" + }, "node_modules/property-information": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.2.0.tgz", @@ -2101,6 +2189,51 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/protocol-buffers-schema": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.1.tgz", + "integrity": "sha512-VG2K63Igkiv9p76tk1lilczEK1cT+kCjKtkdhw1dQZV3k3IXJbd3o6Ho8b9zJZaHSnT2hKe4I+ObmX9w6m5SmQ==", + "license": "MIT" + }, + "node_modules/protomaps-leaflet": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/protomaps-leaflet/-/protomaps-leaflet-5.1.0.tgz", + "integrity": "sha512-N0YY1Gbw5nZ9n8VUOvwHKm/w3zhTTuaZEeMZl8doHemeM4ujGPp2otI6t4Sgqrz8iM4svx2rpG1Q17rHkOWSaA==", + "license": "BSD-3-Clause", + "dependencies": { + "@mapbox/point-geometry": "^1.1.0", + "@mapbox/vector-tile": "^2.0.2", + "@protomaps/basemaps": "^5.0.0", + "@types/css-font-loading-module": "^0.0.7", + "@types/rbush": "^3.0.0", + "color2k": "^2.0.3", + "pbf": "^4.0.1", + "pmtiles": "^3.1.0", + "potpack": "^1.0.2", + "rbush": "^3.0.1" + } + }, + "node_modules/protomaps-leaflet/node_modules/color2k": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/color2k/-/color2k-2.0.3.tgz", + "integrity": "sha512-zW190nQTIoXcGCaU08DvVNFTmQhUpnJfVuAKfWqUQkflXKpaDdpaYoM0iluLS9lgJNHyBF58KKA2FBEwkD7wog==", + "license": "MIT" + }, + "node_modules/quickselect": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz", + "integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==", + "license": "ISC" + }, + "node_modules/rbush": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/rbush/-/rbush-3.0.1.tgz", + "integrity": "sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==", + "license": "MIT", + "dependencies": { + "quickselect": "^2.0.0" + } + }, "node_modules/remark-frontmatter": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/remark-frontmatter/-/remark-frontmatter-5.0.0.tgz", @@ -2182,6 +2315,15 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/resolve-protobuf-schema": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz", + "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==", + "license": "MIT", + "dependencies": { + "protocol-buffers-schema": "^3.3.1" + } + }, "node_modules/rimraf": { "version": "6.1.4", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.4.tgz", diff --git a/bin/vendor/package.json b/bin/vendor/package.json index 77c9299d..230e662e 100644 --- a/bin/vendor/package.json +++ b/bin/vendor/package.json @@ -10,12 +10,14 @@ "@markmap/view": "1.1.1", "pako": "3.0.3", "external-svg-loader": "1.7.1", - "idb-keyval": "6.3.0" + "idb-keyval": "6.3.0", + "protomaps-leaflet": "5.1.0" }, "overrides": { "idb-keyval": "6.3.0", "katex": "0.19.1", - "highlight.js": "11.12.0" + "highlight.js": "11.12.0", + "color2k": "2.0.3" }, "name": "oink-vendor-build", "version": "1.0.0" diff --git a/hugo.yaml b/hugo.yaml index 1eb46ae5..05bfd7c7 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -44,6 +44,11 @@ params: # `attribution_url` links the attribution text, `subdomains` overrides Leaflet's # default "abc" when `tiles` uses `{s}`, and `loading` is `lazy` (viewport) or # `click` (button before any tile request). The theme names no tile service. + # `protomaps.url` draws a vector basemap instead of `tiles`: an https:// + # PMTiles archive (path ending in .pmtiles) or a {z}/{x}/{y} vector-tile + # template, such as the Protomaps API. `flavor` and `dark_flavor` are light, + # dark, white, grayscale or black; `lang` picks label names (blank: the site + # language); `max_data_zoom` is the deepest zoom the tiles hold. map: enable: false tiles: "" @@ -53,6 +58,12 @@ params: subdomains: "" max_zoom: 19 loading: lazy # lazy | click + protomaps: + url: "" + flavor: light # light | dark | white | grayscale | black + dark_flavor: dark + lang: "" + max_data_zoom: 15 print: toc: true # section print views start with a table of contents section_break_wordcount: 50 # pages longer than this start a new print page diff --git a/layouts/_partials/content/map-config.html b/layouts/_partials/content/map-config.html index a8617d36..a6911357 100644 --- a/layouts/_partials/content/map-config.html +++ b/layouts/_partials/content/map-config.html @@ -6,8 +6,17 @@ the attribution text, `subdomains` selects {s} values (default "abc"), and `loading` is "lazy" (viewport) or "click" (explicit button). Anything incomplete warns and leaves maps off; a map fence then renders - only its place list. Returns dict: enable, tiles, darkTiles, - attribution, attributionUrl, subdomains, maxZoom, loading. */ -}} + only its place list. + `protomaps` draws a vector basemap instead of raster tiles: its `url` + is an https:// PMTiles archive (a path ending in .pmtiles, read with + HTTP range requests) or a {z}/{x}/{y} vector-tile template, such as a + self-hosted extract or the Protomaps API. `flavor` and `dark_flavor` + name the basemap's light and dark looks, `lang` picks label names + (default: the site language), and `max_data_zoom` is the deepest zoom + the tiles hold. It replaces `tiles`; `attribution` is still required. + Returns dict: enable, tiles, darkTiles, attribution, attributionUrl, + subdomains, maxZoom, loading, protomaps (empty, or url, flavor, + darkFlavor, lang, maxDataZoom). */ -}} {{- $value := site.Params.map -}} {{- $enabled := partial "config-enabled.html" (dict "value" $value "key" "params.map") -}} {{- $tiles := "" -}} @@ -17,10 +26,11 @@ {{- $subdomains := "" -}} {{- $maxZoom := 19 -}} {{- $loading := "lazy" -}} +{{- $protomaps := dict -}} {{- if $enabled -}} {{- $map := dict -}} {{- if reflect.IsMap $value }}{{ $map = $value }}{{ end -}} - {{- $knownKeys := slice "enable" "tiles" "dark_tiles" "attribution" "attribution_url" "subdomains" "max_zoom" "loading" -}} + {{- $knownKeys := slice "enable" "tiles" "dark_tiles" "attribution" "attribution_url" "subdomains" "max_zoom" "loading" "protomaps" -}} {{- range $key, $_ := $map -}} {{- if not (in $knownKeys $key) }}{{ warnf "params.map has unknown key %q (allowed: %s); ignoring it" $key (delimit $knownKeys ", ") }}{{ end -}} {{- end -}} @@ -109,9 +119,105 @@ {{- warnf "params.map.loading must be lazy or click; got %v; using lazy" . -}} {{- end -}} {{- end -}} - {{- if not (and $tiles $attribution) -}} - {{- warnf "params.map.enable requires params.map.tiles (an https:// template with {z}, {x} and {y}) and params.map.attribution; the theme names no tile service, so maps stay off and map fences show their place lists" -}} + {{- with index $map "protomaps" -}} + {{- if not (reflect.IsMap .) -}} + {{- warnf "params.map.protomaps must be a map with url, flavor, dark_flavor, lang and max_data_zoom; got %v; ignoring it" . -}} + {{- else -}} + {{- $pm := . -}} + {{- $pmKeys := slice "url" "flavor" "dark_flavor" "lang" "max_data_zoom" -}} + {{- range $key, $_ := $pm -}} + {{- if not (in $pmKeys $key) }}{{ warnf "params.map.protomaps has unknown key %q (allowed: %s); ignoring it" $key (delimit $pmKeys ", ") }}{{ end -}} + {{- end -}} + {{- $pmUrl := "" -}} + {{- $rawUrl := index $pm "url" | default "" -}} + {{- if ne (printf "%T" $rawUrl) "string" -}} + {{- warnf "params.map.protomaps.url must be a string; got %v; ignoring it" $rawUrl -}} + {{- else if strings.TrimSpace $rawUrl -}} + {{- $raw := strings.TrimSpace $rawUrl -}} + {{- /* protomaps-leaflet reads a URL whose path ends in .pmtiles as an + archive and anything else as a template; it fills only {z}, + {x} and {y}, so no other placeholder may appear, and none in + the host. */ -}} + {{- $path := index (split (index (split $raw "#") 0) "?") 0 -}} + {{- $archive := strings.HasSuffix (lower $path) ".pmtiles" -}} + {{- $probe := $raw -}} + {{- range slice "{z}" "{x}" "{y}" }}{{ $probe = replace $probe . "0" }}{{ end -}} + {{- $hostBrace := false -}} + {{- with findRE `(?i)^https://[^/?#]*` $raw 1 }}{{ $hostBrace = or (strings.Contains (index . 0) "{") (strings.Contains (index . 0) "}") }}{{ end -}} + {{- if or (strings.Contains $probe "{") (strings.Contains $probe "}") $hostBrace -}} + {{- warnf "params.map.protomaps.url may use only {z}, {x} and {y}, and only in the path; got %q; ignoring it" $raw -}} + {{- else -}} + {{- $url := partial "content/url.html" (dict "label" "params.map" "parameter" "protomaps.url" "position" "site configuration" "value" $probe "kind" "web") -}} + {{- if not $url.valid -}} + {{- else if ne $url.scheme "https" -}} + {{- warnf "params.map.protomaps.url must be an https:// URL; got %q; ignoring it" $raw -}} + {{- else if and (not $archive) (not (and (strings.Contains $raw "{z}") (strings.Contains $raw "{x}") (strings.Contains $raw "{y}"))) -}} + {{- warnf "params.map.protomaps.url must be a .pmtiles archive or a template with {z}, {x} and {y}; got %q; ignoring it" $raw -}} + {{- else if and $archive (strings.Contains $raw "{") -}} + {{- warnf "params.map.protomaps.url names a .pmtiles archive, which takes no {z}, {x} or {y}; got %q; ignoring it" $raw -}} + {{- else -}} + {{- $pmUrl = $raw -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- $flavors := slice "light" "dark" "white" "grayscale" "black" -}} + {{- $flavor := "light" -}} + {{- $darkFlavor := "dark" -}} + {{- range $key := slice "flavor" "dark_flavor" -}} + {{- with index $pm $key -}} + {{- $raw := "" -}} + {{- if eq (printf "%T" .) "string" }}{{ $raw = lower (strings.TrimSpace .) }}{{ end -}} + {{- if in $flavors $raw -}} + {{- if eq $key "flavor" }}{{ $flavor = $raw }}{{ else }}{{ $darkFlavor = $raw }}{{ end -}} + {{- else -}} + {{- warnf "params.map.protomaps.%s must be one of %s; got %v; using %s" $key (delimit $flavors ", ") . (cond (eq $key "flavor") "light" "dark") -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- /* Label names come from name: with the local name as the + fallback. The basemap writes Chinese as zh-Hans and zh-Hant and + every other language by its primary subtag. */ -}} + {{- $siteLang := lower site.Language.Lang -}} + {{- $lang := index (split $siteLang "-") 0 -}} + {{- if eq $lang "zh" -}} + {{- $lang = cond (findRE `^zh-(tw|hk|mo|hant)` $siteLang) "zh-Hant" "zh-Hans" -}} + {{- end -}} + {{- with index $pm "lang" -}} + {{- if and (eq (printf "%T" .) "string") (findRE `^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})?$` (strings.TrimSpace .)) -}} + {{- $lang = strings.TrimSpace . -}} + {{- else -}} + {{- warnf "params.map.protomaps.lang must be a language tag such as en, ja or zh-Hans; got %v; using %s" . $lang -}} + {{- end -}} + {{- end -}} + {{- $maxDataZoom := 15 -}} + {{- if isset $pm "max_data_zoom" -}} + {{- $rawVal := index $pm "max_data_zoom" -}} + {{- if ne $rawVal nil -}} + {{- $raw := printf "%v" $rawVal -}} + {{- if and (findRE `^[1-9][0-9]?$` $raw) (ge (int $raw) 1) (le (int $raw) 22) -}} + {{- $maxDataZoom = int $raw -}} + {{- else -}} + {{- warnf "params.map.protomaps.max_data_zoom must be a whole number from 1 to 22; got %v; using 15" $rawVal -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- if $pmUrl -}} + {{- $protomaps = dict "url" $pmUrl "flavor" $flavor "darkFlavor" (cond (eq $darkFlavor $flavor) "" $darkFlavor) "lang" $lang "maxDataZoom" $maxDataZoom -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- if $protomaps -}} + {{- if or $tiles $darkTiles -}} + {{- warnf "params.map.protomaps.url replaces params.map.tiles and dark_tiles; ignoring the raster tiles" -}} + {{- end -}} + {{- $tiles = "" -}} + {{- $darkTiles = "" -}} + {{- $subdomains = "" -}} + {{- end -}} + {{- if not (and (or $tiles $protomaps) $attribution) -}} + {{- warnf "params.map.enable requires params.map.tiles (an https:// template with {z}, {x} and {y}) or params.map.protomaps.url (an https:// .pmtiles archive or vector-tile template), and params.map.attribution; the theme names no tile service, so maps stay off and map fences show their place lists" -}} {{- $enabled = false -}} + {{- $protomaps = dict -}} {{- end -}} {{- end -}} -{{- return (dict "enable" $enabled "tiles" $tiles "darkTiles" $darkTiles "attribution" $attribution "attributionUrl" $attributionUrl "subdomains" $subdomains "maxZoom" $maxZoom "loading" $loading) -}} +{{- return (dict "enable" $enabled "tiles" $tiles "darkTiles" $darkTiles "attribution" $attribution "attributionUrl" $attributionUrl "subdomains" $subdomains "maxZoom" $maxZoom "loading" $loading "protomaps" $protomaps) -}} diff --git a/layouts/_partials/scripts.html b/layouts/_partials/scripts.html index 05698ade..7cb8b107 100644 --- a/layouts/_partials/scripts.html +++ b/layouts/_partials/scripts.html @@ -195,12 +195,21 @@ {{ $leafletJS := resources.Get "third_party/leaflet/leaflet.js" -}} {{ if hugo.IsProduction }}{{ $leafletJS = $leafletJS | fingerprint }}{{ end -}} {{ $engines = merge $engines (dict "leaflet" (dict "src" $leafletJS.RelPermalink "integrity" ($leafletJS.Data.Integrity | default ""))) -}} - + "closePopup" (T "ui_search_close") "loadMap" (T "ui_map_load") -}} +{{ with $mapConfig.protomaps }}{{ $mapClient = merge $mapClient (dict "protomaps" .) }}{{ end -}} + {{ end -}} {{ with $engines -}} diff --git a/schema/site-params.schema.json b/schema/site-params.schema.json index 80af6ac5..dc0880ad 100644 --- a/schema/site-params.schema.json +++ b/schema/site-params.schema.json @@ -117,7 +117,7 @@ "boolean", "object" ], - "description": "Interactive maps above ```map place lists. Off until a site names its tile service: `tiles` is an https:// template with {z}, {x} and {y} ({s}, {r} and {-y} allowed), and `attribution` is the text that service requires. Optional `attribution_url` links the attribution text, `subdomains` overrides Leaflet's default \"abc\" when `tiles` uses `{s}`, and `loading` is `lazy` (viewport) or `click` (button before any tile request). The theme names no tile service.", + "description": "Interactive maps above ```map place lists. Off until a site names its tile service: `tiles` is an https:// template with {z}, {x} and {y} ({s}, {r} and {-y} allowed), and `attribution` is the text that service requires. Optional `attribution_url` links the attribution text, `subdomains` overrides Leaflet's default \"abc\" when `tiles` uses `{s}`, and `loading` is `lazy` (viewport) or `click` (button before any tile request). The theme names no tile service. `protomaps.url` draws a vector basemap instead of `tiles`: an https:// PMTiles archive (path ending in .pmtiles) or a {z}/{x}/{y} vector-tile template, such as the Protomaps API. `flavor` and `dark_flavor` are light, dark, white, grayscale or black; `lang` picks label names (blank: the site language); `max_data_zoom` is the deepest zoom the tiles hold.", "additionalProperties": true, "properties": { "enable": { @@ -157,6 +157,48 @@ "lazy", "click" ] + }, + "protomaps": { + "type": "object", + "additionalProperties": true, + "properties": { + "url": { + "type": "string", + "default": "" + }, + "flavor": { + "type": "string", + "default": "light", + "enum": [ + "light", + "dark", + "white", + "grayscale", + "black" + ] + }, + "dark_flavor": { + "type": "string", + "default": "dark", + "enum": [ + "light", + "dark", + "white", + "grayscale", + "black" + ] + }, + "lang": { + "type": "string", + "default": "" + }, + "max_data_zoom": { + "type": "integer", + "default": 15, + "minimum": 1, + "maximum": 22 + } + } } } }, diff --git a/tests/js/content-components-map.test.js b/tests/js/content-components-map.test.js index 8c2e93c0..480ca517 100644 --- a/tests/js/content-components-map.test.js +++ b/tests/js/content-components-map.test.js @@ -8,7 +8,9 @@ // dragging until a mouse or pen enters, reduced motion disables animations, // keyboard-opened popups take and return focus, click-to-load defers engine // loading until clicked and focuses the map it loads, and hidden containers -// frame once visible. +// frame once visible. A Protomaps basemap draws through protomaps-leaflet in +// its light and dark flavors, loads after Leaflet, and counts failed vector +// tiles itself because the renderer never reports them to Leaflet. // Rendered tiles belong to the documentation site's browser suite. const assert = require('node:assert/strict'); const fs = require('node:fs'); @@ -314,6 +316,34 @@ function mount(source, opts = {}) { const docListeners = new Map(); const requests = []; const L = opts.preload === false ? null : stubLeaflet(calls, { touch: !!opts.touch }); + const vectorLayers = []; + const protomapsL = + opts.preload === false || !opts.vector + ? null + : { + leafletLayer(options) { + calls.push(['vector', options]); + const listeners = new Map(); + const view = { getDisplayTile: opts.vectorTile || (() => Promise.resolve([])) }; + const layer = { + options, + views: new Map([['', view]]), + view, + on(name, fn) { + const list = listeners.get(name) || []; + list.push(fn); + listeners.set(name, list); + return layer; + }, + fire(name) { + (listeners.get(name) || []).forEach((fn) => fn({})); + }, + addTo: () => layer, + }; + vectorLayers.push(layer); + return layer; + }, + }; const document = { readyState: opts.readyState, @@ -326,7 +356,9 @@ function mount(source, opts = {}) { }, createElement: element, querySelector(selector) { - if (selector === '[data-td-component-engines]') return { textContent: '{"leaflet":{"src":"/l.js"}}' }; + if (selector === '[data-td-component-engines]') { + return { textContent: '{"leaflet":{"src":"/l.js"},"protomaps":{"src":"/p.js"}}' }; + } if (selector === '[data-td-map-config]') return { textContent: JSON.stringify(site) }; return null; }, @@ -339,6 +371,7 @@ function mount(source, opts = {}) { }; const window = { L, + protomapsL, addEventListener() {}, matchMedia: (query) => ({ matches: query === '(prefers-reduced-motion: reduce)' ? !!opts.reducedMotion : false, @@ -384,7 +417,9 @@ function mount(source, opts = {}) { listItems, root, L, + vectorLayers, requests, + window, observed: () => observed, setTheme(next) { theme = next; @@ -766,3 +801,87 @@ test('multiple places with explicit zoom call setView once and validate popup li assert.equal(popups[0][2], 'External'); assert.equal(popups[1][2], 'Unsafe', 'unsafe href and thumb are both dropped'); }); + +const VECTOR = { + url: 'https://tiles.example.org/world.pmtiles', + flavor: 'light', + darkFlavor: 'dark', + lang: 'ja', + maxDataZoom: 15, +}; +const ONE_PLACE = { places: [{ name: 'A', lat: 35, lng: 135, text: '', thumb: '', href: '' }], route: false, zoom: 0 }; + +test('a Protomaps basemap draws vector flavors instead of raster tiles and follows the theme', async () => { + const page = mount(ONE_PLACE, { vector: true, site: { tiles: '', protomaps: VECTOR } }); + await page.due(); + assert.equal(page.canvas.hidden, false); + assert.equal(page.calls.some((call) => call[0] === 'tiles'), false, 'no raster layer'); + assert.equal(page.canvas.hasAttribute('data-td-map-light-tiles'), false, 'the dark flavor is its own look'); + const first = page.calls.find((call) => call[0] === 'vector')[1]; + assert.equal( + JSON.stringify(first), + JSON.stringify({ + url: 'https://tiles.example.org/world.pmtiles', + flavor: 'light', + lang: 'ja', + maxDataZoom: 15, + maxZoom: 19, + attribution: '', + }), + ); + assert.deepEqual(page.calls.find((call) => call[0] === 'attribution'), ['attribution', '<b>© Example</b>']); + page.setTheme('dark'); + const vectors = page.calls.filter((call) => call[0] === 'vector'); + assert.equal(vectors.length, 2); + assert.equal(vectors[1][1].flavor, 'dark'); + page.setTheme('dark'); + assert.equal(page.calls.filter((call) => call[0] === 'vector').length, 2, 'the same flavor is not redrawn'); +}); + +test('a Protomaps basemap without a dark flavor keeps its light look and marks it', async () => { + const page = mount(ONE_PLACE, { vector: true, theme: 'dark', site: { tiles: '', protomaps: { ...VECTOR, darkFlavor: '' } } }); + await page.due(); + assert.equal(page.canvas.hasAttribute('data-td-map-light-tiles'), true); + assert.equal(page.calls.find((call) => call[0] === 'vector')[1].flavor, 'light'); +}); + +test('failing vector tiles hide the canvas; aborted requests do not count', async () => { + const aborted = mount(ONE_PLACE, { + vector: true, + site: { tiles: '', protomaps: { ...VECTOR, darkFlavor: '' } }, + vectorTile: () => Promise.reject(Object.assign(new Error('zoom moved'), { name: 'AbortError' })), + }); + await aborted.due(); + await aborted.vectorLayers[0].view.getDisplayTile().catch(() => {}); + aborted.vectorLayers[0].fire('load'); + assert.equal(aborted.canvas.hidden, false, 'an aborted tile is not a failure'); + + const page = mount(ONE_PLACE, { + vector: true, + site: { tiles: '', protomaps: { ...VECTOR, darkFlavor: '' } }, + vectorTile: () => Promise.reject(new Error('404')), + }); + await page.due(); + const layer = page.vectorLayers[0]; + await layer.view.getDisplayTile().catch(() => {}); + await layer.view.getDisplayTile().catch(() => {}); + layer.fire('load'); + assert.equal(page.canvas.hidden, true); + await page.tick(); + assert.deepEqual(page.calls.filter((call) => call[0] === 'mapRemove'), [['mapRemove', false]]); +}); + +test('click-to-load names the Protomaps host and loads its renderer after Leaflet', async () => { + const page = mount(ONE_PLACE, { + preload: false, + site: { loading: 'click', tiles: '', protomaps: { ...VECTOR, url: 'https://api.example.org/tiles/v4/{z}/{x}/{y}.mvt' } }, + }); + const button = page.root.children.find((child) => child.tag === 'button'); + assert.equal(button.textContent, 'Karte laden (\u2066api.example.org\u2069)'); + button.dispatch('click'); + assert.deepEqual(page.requests.map((script) => script.src), ['/l.js'], 'Leaflet first'); + page.window.L = stubLeaflet(page.calls); + page.requests[0].onload(); + await page.settle(); + assert.deepEqual(page.requests.map((script) => script.src), ['/l.js', '/p.js']); +});