diff --git a/README.md b/README.md index 4717a56..e071570 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,12 @@ return [ ``` ```php -use Elbgoods\NovaMapboxField\NovaMapboxField; +use Elbgoods\NovaMapboxField\NovaMapboxMarkerField; public function fields(Request $request) { return [ - NovaMapboxField::make('Marker') + NovaMapboxMarkerField::make('Marker') ->longitude($this->longitude) ->latitude($this->latitude) ->zoom(8), @@ -44,6 +44,9 @@ public function fields(Request $request) } ``` +## Screenshot + + ## License This project is open-sourced software licensed under the [MIT license](LICENSE.md). diff --git a/dist/js/field.js b/dist/js/field.js index b91521b..3de9e65 100644 --- a/dist/js/field.js +++ b/dist/js/field.js @@ -1 +1 @@ -(()=>{var t={562:(t,e,i)=>{"use strict";i.d(e,{Z:()=>n});var r=i(645),o=i.n(r)()((function(t){return t[1]}));o.push([t.id,".mapboxgl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.mapboxgl-canvas{position:absolute;left:0;top:0}.mapboxgl-map:-webkit-full-screen{width:100%;height:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{position:absolute;pointer-events:none;z-index:2}.mapboxgl-ctrl-top-left{top:0;left:0}.mapboxgl-ctrl-top-right{top:0;right:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{right:0;bottom:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:10px 0 0 10px;float:left}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{margin:10px 10px 0 0;float:right}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{margin:0 0 10px 10px;float:left}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{margin:0 10px 10px 0;float:right}.mapboxgl-ctrl-group{border-radius:4px;background:#fff}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgb(0 0 0/10%)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{width:29px;height:29px;display:block;padding:0;outline:none;border:0;box-sizing:border-box;background-color:transparent;cursor:pointer;overflow:hidden}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{display:block;width:100%;height:100%;background-repeat:no-repeat;background-position:50%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px rgb(0 150 255/100%)}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px rgb(0 150 255/100%)}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E %3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg'%3E %3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E %3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E %3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E %3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E %3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E %3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='red'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='red'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='red'/%3E %3C/svg%3E\")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{width:88px;height:23px;margin:0 0 -4px -4px;display:block;background-repeat:no-repeat;cursor:pointer;overflow:hidden;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='88' height='23' viewBox='0 0 88 23' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd'%3E %3Cdefs%3E %3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E %3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E %3C/defs%3E %3Cmask id='clip'%3E %3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/mask%3E %3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E %3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E %3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E %3C/g%3E %3Cg id='fill' opacity='0.9' fill='%23fff'%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/g%3E %3C/svg%3E\")}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='88' height='23' viewBox='0 0 88 23' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd'%3E %3Cdefs%3E %3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E %3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E %3C/defs%3E %3Cmask id='clip'%3E %3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/mask%3E %3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E %3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E %3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E %3C/g%3E %3Cg id='fill' opacity='1' fill='%23fff'%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/g%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='88' height='23' viewBox='0 0 88 23' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd'%3E %3Cdefs%3E %3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E %3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E %3C/defs%3E %3Cmask id='clip'%3E %3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/mask%3E %3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E %3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E %3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E %3C/g%3E %3Cg id='fill' opacity='1' fill='%23000'%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/g%3E %3C/svg%3E\")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{padding:0 5px;background-color:rgb(255 255 255/50%);margin:0}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{min-height:20px;padding:2px 24px 2px 0;margin:10px;position:relative;background-color:#fff;border-radius:12px}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 8px 2px 28px;border-radius:12px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{display:none;cursor:pointer;position:absolute;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E %3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E %3C/svg%3E\");background-color:rgb(255 255 255/50%);width:24px;height:24px;box-sizing:border-box;border-radius:12px;outline:none;top:0;right:0;border:0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner,.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{top:0;right:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{top:0;left:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%3E %3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E %3C/svg%3E\")}}@media screen and (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E %3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl-attrib a{color:rgb(0 0 0/75%);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:rgb(255 255 255/75%);font-size:10px;border:2px solid #333;border-top:#333;padding:0 5px;color:#333;box-sizing:border-box;white-space:nowrap}.mapboxgl-popup{position:absolute;top:0;left:0;display:flex;will-change:transform;pointer-events:none}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{width:0;height:0;border:10px solid transparent;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-top:none;border-bottom-color:#fff}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-top:none;border-left:none;border-bottom-color:#fff}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-top:none;border-right:none;border-bottom-color:#fff}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-right:none;border-left-color:#fff}.mapboxgl-popup-close-button{position:absolute;right:0;top:0;border:0;border-radius:0 3px 0 0;cursor:pointer;background-color:transparent}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{position:relative;background:#fff;border-radius:3px;box-shadow:0 1px 2px rgb(0 0 0/10%);padding:10px 10px 15px;pointer-events:auto}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{position:absolute;top:0;left:0;will-change:transform;opacity:1;transition:opacity .2s}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;width:15px;height:15px;border-radius:50%}.mapboxgl-user-location-dot:before{content:\"\";position:absolute;animation:mapboxgl-user-location-dot-pulse 2s infinite}.mapboxgl-user-location-dot:after{border-radius:50%;border:2px solid #fff;content:\"\";height:19px;left:-2px;position:absolute;top:-2px;width:19px;box-sizing:border-box;box-shadow:0 0 3px rgb(0 0 0/35%)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{width:0;height:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{content:\"\";border-bottom:7.5px solid #4aa1eb;position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{transform:scale(1);opacity:1}70%{transform:scale(3);opacity:0}to{transform:scale(1);opacity:0}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:rgba(29,161,242,.2);width:1px;height:1px;border-radius:100%}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{position:absolute;top:0;left:0;width:0;height:0;background:#fff;border:2px dotted #202020;opacity:.5}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{color:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;justify-content:center;text-align:center;position:absolute;display:flex;align-items:center;top:0;left:0;width:100%;height:100%;background:rgb(0 0 0/70%);opacity:0;pointer-events:none;transition:opacity .75s ease-in-out;transition-delay:1s}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y}",""]);const n=o},309:(t,e,i)=>{"use strict";i.d(e,{Z:()=>a});var r=i(645),o=i.n(r),n=i(562),s=o()((function(t){return t[1]}));s.i(n.Z),s.push([t.id,"#mapContainer[data-v-16283323]{height:600px}",""]);const a=s},645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i=t(e);return e[2]?"@media ".concat(e[2]," {").concat(i,"}"):i})).join("")},e.i=function(t,i,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var n=0;n(r=1))return r;for(;in?i=o:r=o,o=.5*(r-i)+i}return o},o.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var n=s;function s(t,e){this.x=t,this.y=e}s.prototype={clone:function(){return new s(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),o=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},s.convert=function(t){return t instanceof s?t:Array.isArray(t)?new s(t[0],t[1]):t};const a=Math.PI/180,l=180/Math.PI;function c(t){return t*a}function u(t){return t*l}const h=[[0,0],[1,0],[1,1],[0,1]];function p(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function d(t,e,r,o){const n=new i(t,e,r,o);return function(t){return n.solve(t)}}const f=d(.25,.1,.25,1);function m(t,e,i){return Math.min(i,Math.max(e,t))}function _(t,e,i){return(i=m((i-t)/(e-t),0,1))*i*(3-2*i)}function g(t,e,i){const r=i-e,o=((t-e)%r+r)%r+e;return o===e?i:o}function y(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const o=new Array(t.length);let n=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(n=t),o[s]=e,0==--r&&i(n,o)}))}))}function x(t){const e=[];for(const i in t)e.push(t[i]);return e}function v(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let b=1;function w(){return b++}function T(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function E(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function S(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function C(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function M(t,e){return-1!==t.indexOf(e,t.length-e.length)}function A(t,e,i){const r={};for(const o in t)r[o]=e.call(i||this,t[o],o,t);return r}function I(t,e,i){const r={};for(const o in t)e.call(i||this,t[o],o,t)&&(r[o]=t[o]);return r}function z(t){return Array.isArray(t)?t.map(z):"object"==typeof t&&t?A(t,z):t}const k={};function P(t){k[t]||("undefined"!=typeof console&&console.warn(t),k[t]=!0)}function D(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function L(t){let e=0;for(let i,r,o=0,n=t.length,s=n-1;o@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,o)=>{const n=r||o;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let F=null;function O(t){if(null==F){const e=t.navigator?t.navigator.userAgent:null;F=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return F}function U(t){try{const i=e[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function V(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const j=e.performance;function N(t){const e=t?t.url.toString():void 0;return j.getEntriesByName(e)}var G="2.9.2";let Z,$,q,X;const W={now:()=>void 0!==q?q:e.performance.now(),setNow(t){q=t},restoreNow(){q=void 0},frame(t){const i=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(i)}},getImageData(t,i=0){const{width:r,height:o}=t;X||(X=e.document.createElement("canvas"));const n=X.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return(r>X.width||o>X.height)&&(X.width=r,X.height=o),n.clearRect(-i,-i,r+2*i,o+2*i),n.drawImage(t,0,0,r,o),n.getImageData(-i,-i,r+2*i,o+2*i)},resolveURL:t=>(Z||(Z=e.document.createElement("a")),Z.href=t,Z.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==$&&($=e.matchMedia("(prefers-reduced-motion: reduce)")),$.matches)}};let H;const Y={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==H){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{H=null!=r.env.API_URL_REGEX?new RegExp(r.env.API_URL_REGEX):t}catch(e){H=t}}return H},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},K={supported:!1,testSupport:function(t){!tt&&Q&&(et?it(t):J=t)}};let J,Q,tt=!1,et=!1;function it(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Q),t.isContextLost())return;K.supported=!0}catch(t){}t.deleteTexture(e),tt=!0}e.document&&(Q=e.document.createElement("img"),Q.onload=function(){J&&it(J),J=null,et=!0},Q.onerror=function(){tt=!0,J=null},Q.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const rt="01",ot="NO_ACCESS_TOKEN";function nt(t){return 0===t.indexOf("mapbox:")}function st(t){return Y.API_URL_REGEX.test(t)}const at=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function lt(t){const e=t.match(at);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function ct(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}function ut(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(i[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class ht{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=ut(Y.ACCESS_TOKEN);let r="";return r=i&&i.u?e.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):Y.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${r}`:`mapbox.eventData:${r}`}fetchEventData(){const t=U("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));const o=e.localStorage.getItem(r);o&&(this.anonId=o)}catch(t){P("Unable to read from LocalStorage")}}saveEventData(){const t=U("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(t){P("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,r){if(!Y.EVENTS_URL)return;const o=lt(Y.EVENTS_URL);o.params.push(`access_token=${r||Y.ACCESS_TOKEN||""}`);const n={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:G,skuId:rt,userId:this.anonId},s=e?v(n,e):n,a={url:ct(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=Dt(a,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const pt=new class extends ht{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){Y.EVENTS_URL&&Y.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>nt(t)||st(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=ut(Y.ACCESS_TOKEN),i=e?e.u:Y.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;S(this.anonId)||(this.anonId=T(),r=!0);const o=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(o),i=(o-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||t.getDate()!==e.getDate()}else r=!0;r?this.postEvent(o,{"enabled.telemetry":!1},(t=>{t||(this.eventData.lastSuccess=o,this.eventData.tokenU=i)}),t):this.processRequests()}},dt=pt.postTurnstileEvent.bind(pt),ft=new class extends ht{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,Y.EVENTS_URL&&(i||Y.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(ot)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),S(this.anonId)||(this.anonId=T()),this.postEvent(i,{skuToken:this.skuToken},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},mt=ft.postMapLoadEvent.bind(ft),_t=new class extends ht{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!Y.API_URL||!Y.SESSION_PATH)return;const o=lt(Y.API_URL+Y.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${r||Y.ACCESS_TOKEN||""}`);const n={url:ct(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Lt(n,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,Y.SESSION_PATH&&Y.API_URL&&(i||Y.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(ot)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},gt=_t.getSessionAPI.bind(_t),yt=new Set;let xt,vt=500,bt=50,wt={};function Tt(t){const e=St(t);let i,r;e&&e.forEach((t=>{const e=t.split("=");"language"===e[0]?i=e[1]:"worldview"===e[0]&&(r=e[1])}));let o="mapbox-tiles";return i&&(o+=`-${i}`),r&&(o+=`-${r}`),o}function Et(t){e.caches&&!wt[t]&&(wt[t]=e.caches.open(t))}function St(t){const e=t.indexOf("?");return e>0?t.slice(e+1).split("&"):[]}function Ct(t){const e=t.indexOf("?");if(e<0)return t;const i=St(t).filter((t=>{const e=t.split("=");return"language"===e[0]||"worldview"===e[0]}));return i.length?`${t.slice(0,e)}?${i.join("&")}`:t.slice(0,e)}let Mt=1/0;const At={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(At);class It extends Error{constructor(t,e,i){401===e&&st(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const zt=B()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href,kt=function(t,i){if(!(/^file:/.test(r=t.url)||/^file:/.test(zt())&&!/^\w+:/.test(r))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,i){const r=new e.AbortController,o=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:zt(),signal:r.signal});let n=!1,s=!1;const a=(l=o.url).indexOf("sku=")>0&&st(l);var l;"json"===t.type&&o.headers.set("Accept","application/json");const c=(r,n,l)=>{if(s)return;if(r&&"SecurityError"!==r.message&&P(r),n&&l)return u(n);const c=Date.now();e.fetch(o).then((e=>{if(e.ok){const t=a?e.clone():null;return u(e,t,c)}return i(new It(e.statusText,e.status,t.url))})).catch((t=>{20!==t.code&&i(new Error(t.message))}))},u=(r,a,l)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{s||(a&&l&&function(t,i,r){const o=Tt(t.url);if(Et(o),!wt[o])return;const n={status:i.status,statusText:i.statusText,headers:new e.Headers};i.headers.forEach(((t,e)=>n.headers.set(e,t)));const s=R(i.headers.get("Cache-Control")||"");if(s["no-store"])return;s["max-age"]&&n.headers.set("Expires",new Date(r+1e3*s["max-age"]).toUTCString());const a=n.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(t,e){if(void 0===xt)try{new Response(new ReadableStream),xt=!0}catch(t){xt=!1}xt?e(t.body):t.blob().then(e)}(i,(i=>{const r=new e.Response(i,n);Et(o),wt[o]&&wt[o].then((e=>e.put(Ct(t.url),r))).catch((t=>P(t.message)))})))}(o,a,l),n=!0,i(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((t=>{s||i(new Error(t.message))}))};return a?function(t,e){const i=Tt(t.url);if(Et(i),!wt[i])return e(null);const r=Ct(t.url);wt[i].then((t=>{t.match(r).then((i=>{const o=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=R(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(i);t.delete(r),o&&t.put(r,i.clone()),e(null,i,o)})).catch(e)})).catch(e)}(o,c):c(null,null),{cancel:()=>{s=!0,n||r.abort()}}}(t,i);if(B()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,i,void 0,!0)}var r;return function(t,i){const r=new e.XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{i(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(t){return i(t)}i(null,e,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else i(new It(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(t,i)},Pt=function(t,e){return kt(v(t,{type:"arrayBuffer"}),e)},Dt=function(t,e){return kt(v(t,{method:"POST"}),e)},Lt=function(t,e){return kt(v(t,{method:"GET"}),e)};function Bt(t){const i=e.document.createElement("a");return i.href=t,i.protocol===e.document.location.protocol&&i.host===e.document.location.host}const Rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ft,Ot;Ft=[],Ot=0;const Ut=function(t,i){if(K.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),Ot>=Y.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return Ft.push(e),e}Ot++;let r=!1;const o=()=>{if(!r)for(r=!0,Ot--;Ft.length&&Ot{o(),t?i(t):r&&(e.createImageBitmap?function(t,i){const r=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(r).then((t=>{i(null,t)})).catch((t=>{i(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(r,((t,e)=>i(t,e,n,s))):function(t,i){const r=new e.Image,o=e.URL;r.onload=()=>{i(null,r),o.revokeObjectURL(r.src),r.onload=null,e.requestAnimationFrame((()=>{r.src=Rt}))},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new e.Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?o.createObjectURL(n):Rt}(r,((t,e)=>i(t,e,n,s))))}));return{cancel:()=>{n.cancel(),o()}}};function Vt(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function jt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class Nt{constructor(t,e={}){v(this,e),this.type=t}}class Gt extends Nt{constructor(t,e={}){super("error",v({error:t},e))}}class Zt{on(t,e){return this._listeners=this._listeners||{},Vt(t,e,this._listeners),this}off(t,e){return jt(t,e,this._listeners),jt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Vt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Nt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)jt(i,e,this._oneTimeListeners),e.call(this,t);const o=this._eventedParent;o&&(v(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),o.fire(t))}else t instanceof Gt&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var $t=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function qt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function Xt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Wt(t){if(Array.isArray(t))return t.map(Wt);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Wt(t[i]);return e}return Xt(t)}class Ht extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var Yt=Ht;class Kt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Kt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var Jt=Kt;const Qt={kind:"null"},te={kind:"number"},ee={kind:"string"},ie={kind:"boolean"},re={kind:"color"},oe={kind:"object"},ne={kind:"value"},se={kind:"collator"},ae={kind:"formatted"},le={kind:"resolvedImage"};function ce(t,e){return{kind:"array",itemType:t,N:e}}function ue(t){if("array"===t.kind){const e=ue(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const he=[Qt,te,ee,ie,re,ae,oe,ce(ne),le];function pe(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!pe(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of he)if(!pe(t,e))return null}return`Expected ${ue(t)} but found ${ue(e)} instead.`}function de(t,e){return e.some((e=>e.kind===t.kind))}function fe(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function me(t){var e={exports:{}};return t(e,e.exports),e.exports}var _e=me((function(t,e){var i={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function r(t){return(t=Math.round(t))<0?0:t>255?255:t}function o(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function s(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{e.parseCSSColor=function(t){var e,a=t.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(e=parseInt(a.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===a.length&&(e=parseInt(a.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=n(h.pop());case"rgb":return 3!==h.length?null:[o(h[0]),o(h[1]),o(h[2]),p];case"hsla":if(4!==h.length)return null;p=n(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*s(g,_,d+1/3)),r(255*s(g,_,d)),r(255*s(g,_,d-1/3)),p];default:return null}}return null}}catch(t){}}));class ge{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof ge)return t;if("string"!=typeof t)return;const e=_e.parseCSSColor(t);return e?new ge(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}toArray01(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[t/r,e/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:r}=this;return[t,e,i,r]}}ge.black=new ge(0,0,0,1),ge.white=new ge(1,1,1,1),ge.transparent=new ge(0,0,0,0),ge.red=new ge(1,0,0,1),ge.blue=new ge(0,0,1,1);var ye=ge;class xe{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ve{constructor(t,e,i,r,o){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=o}}class be{constructor(t){this.sections=t}static fromString(t){return new be([new ve(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof be?t:be.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class we{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new we({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Te(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ee(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof ye)return!0;if(t instanceof xe)return!0;if(t instanceof be)return!0;if(t instanceof we)return!0;if(Array.isArray(t)){for(const e of t)if(!Ee(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Ee(t[e]))return!1;return!0}return!1}function Se(t){if(null===t)return Qt;if("string"==typeof t)return ee;if("boolean"==typeof t)return ie;if("number"==typeof t)return te;if(t instanceof ye)return re;if(t instanceof xe)return se;if(t instanceof be)return ae;if(t instanceof we)return le;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Se(e);if(i){if(i===t)continue;i=ne;break}i=t}return ce(i||ne,e)}return oe}function Ce(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ye||t instanceof be||t instanceof we?t.toString():JSON.stringify(t)}class Me{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ee(t[1]))return e.error("invalid value");const i=t[1];let r=Se(i);const o=e.expectedType;return"array"!==r.kind||0!==r.N||!o||"array"!==o.kind||"number"==typeof o.N&&0!==o.N||(r=o),new Me(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ye?["rgba"].concat(this.value.toArray()):this.value instanceof be?this.value.serialize():this.value}}var Ae=Me,Ie=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const ze={string:ee,number:te,boolean:ie,object:oe};class ke{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const o=t[0];if("array"===o){let o,n;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in ze)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);o=ze[i],r++}else o=ne;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);n=t[2],r++}i=ce(o,n)}else i=ze[o];const n=[];for(;rt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}var Pe=ke;class De{constructor(t){this.type=ae,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let o=!1;for(let i=1;i<=t.length-1;++i){const n=t[i];if(o&&"object"==typeof n&&!Array.isArray(n)){o=!1;let t=null;if(n["font-scale"]&&(t=e.parse(n["font-scale"],1,te),!t))return null;let i=null;if(n["text-font"]&&(i=e.parse(n["text-font"],1,ce(ee)),!i))return null;let s=null;if(n["text-color"]&&(s=e.parse(n["text-color"],1,re),!s))return null;const a=r[r.length-1];a.scale=t,a.font=i,a.textColor=s}else{const n=e.parse(t[i],1,ne);if(!n)return null;const s=n.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");o=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new De(r)}evaluate(t){return new be(this.sections.map((e=>{const i=e.content.evaluate(t);return Se(i)===le?new ve("",i,null,null,null):new ve(Ce(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class Le{constructor(t){this.type=le,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ee);return i?new Le(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=we.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Be={"to-boolean":ie,"to-color":re,"to-number":te,"to-string":ee};class Re{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Be[i],o=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Te(e[0],e[1],e[2],e[3]),!i))return new ye(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ie(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Ie(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?be.fromString(Ce(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?we.fromString(Ce(this.args[0].evaluate(t))):Ce(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new De([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Le(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Fe=Re;const Oe=["Unknown","Point","LineString","Polygon"];var Ue=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Oe[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ye.parse(t)),e}};class Ve{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=Ve.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const o=Array.isArray(r)?r[0]:r.type,n=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=n.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,n]of s){a=new di(e.registry,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(ue).join(", ")})`:`(${ue(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i=e[2]||t[1]<=e[1]||t[3]>=e[3])}function qe(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,o=Math.pow(2,e.z);return[Math.round(i*o*Ge),Math.round(r*o*Ge)]}function Xe(t,e,i){const r=t[0]-e[0],o=t[1]-e[1],n=t[0]-i[0],s=t[1]-i[1];return r*s-n*o==0&&r*n<=0&&o*s<=0}function We(t,e){let i=!1;for(let s=0,a=e.length;s(r=t)[1]!=(n=a[e+1])[1]>r[1]&&r[0]<(n[0]-o[0])*(r[1]-o[1])/(n[1]-o[1])+o[0]&&(i=!i)}}var r,o,n;return i}function He(t,e){for(let i=0;i0&&a<0||s<0&&a>0}function Ke(t,e,i){for(const c of i)for(let i=0;ii[2]){const e=.5*r;let o=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===o&&(o=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=o}Ze(e,t)}function ri(t,e,i,r){const o=Math.pow(2,r.z)*Ge,n=[r.x*Ge,r.y*Ge],s=[];if(!t)return s;for(const r of t)for(const t of r){const r=[t.x+n[0],t.y+n[1]];ii(r,e,i,o),s.push(r)}return s}function oi(t,e,i,r){const o=Math.pow(2,r.z)*Ge,n=[r.x*Ge,r.y*Ge],s=[];if(!t)return s;for(const i of t){const t=[];for(const r of i){const i=[r.x+n[0],r.y+n[1]];Ze(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]<=o/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const r of t)ii(r,e,i,o)}var a;return s}class ni{constructor(t,e){this.type=ie,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ee(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t{e&&!ai(t)&&(e=!1)})),e}function li(t){if(t instanceof je&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!li(t)&&(e=!1)})),e}function ci(t,e){if(t instanceof je&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!ci(t,e)&&(i=!1)})),i}class ui{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ui(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var hi=ui;class pi{constructor(t,e=[],i,r=new Jt,o=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=o,this.expectedType=i}parse(t,e,i,r,o={}){return e?this.concat(e,i,r)._parse(t,o):this._parse(t,o)}_parse(t,e){function i(t,e,i){return"assert"===i?new Pe(e,[t]):"coerce"===i?new Fe(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const o=this.registry[r];if(o){let r=o.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,o=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==o.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(t,o))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Ae)&&"resolvedImage"!==r.type.kind&&fi(r)){const e=new Ue;try{r=new Ae(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,o=i?this.scope.concat(i):this.scope;return new pi(this.registry,r,e||null,o,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Yt(i,t))}checkSubtype(t,e){const i=pe(t,e);return i&&this.error(i),i}}var di=pi;function fi(t){if(t instanceof hi)return fi(t.boundExpression);if(t instanceof je&&"error"===t.name)return!1;if(t instanceof Ne)return!1;if(t instanceof si)return!1;const e=t instanceof Fe||t instanceof Pe;let i=!0;return t.eachChild((t=>{i=e?i&&fi(t):i&&t instanceof Ae})),!!i&&ai(t)&&ci(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function mi(t,e){const i=t.length-1;let r,o,n=0,s=i,a=0;for(;n<=s;)if(a=Math.floor((n+s)/2),r=t[a],o=t[a+1],r<=e){if(a===i||ee))throw new Ie("Input is not a number.");s=a-1}return 0}class _i{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,te);if(!i)return null;const r=[];let o=null;e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let i=1;i=n)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,o);if(!c)return null;o=o||c.type,r.push([n,c])}return new _i(o,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const o=e.length;return r>=e[o-1]?i[o-1].evaluate(t):i[mi(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var gi=_i;function yi(t,e,i){return t*(1-i)+e*i}var xi=Object.freeze({__proto__:null,number:yi,color:function(t,e,i){return new ye(yi(t.r,e.r,i),yi(t.g,e.g,i),yi(t.b,e.b,i),yi(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>yi(t,e[r],i)))}});const vi=.95047,bi=1.08883,wi=4/29,Ti=6/29,Ei=3*Ti*Ti,Si=Math.PI/180,Ci=180/Math.PI;function Mi(t){return t>.008856451679035631?Math.pow(t,1/3):t/Ei+wi}function Ai(t){return t>Ti?t*t*t:Ei*(t-wi)}function Ii(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function zi(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ki(t){const e=zi(t.r),i=zi(t.g),r=zi(t.b),o=Mi((.4124564*e+.3575761*i+.1804375*r)/vi),n=Mi((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*n-16,a:500*(o-n),b:200*(n-Mi((.0193339*e+.119192*i+.9503041*r)/bi)),alpha:t.a}}function Pi(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ai(e),i=vi*Ai(i),r=bi*Ai(r),new ye(Ii(3.2404542*i-1.5371385*e-.4985314*r),Ii(-.969266*i+1.8760108*e+.041556*r),Ii(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Di(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Li={forward:ki,reverse:Pi,interpolate:function(t,e,i){return{l:yi(t.l,e.l,i),a:yi(t.a,e.a,i),b:yi(t.b,e.b,i),alpha:yi(t.alpha,e.alpha,i)}}},Bi={forward:function(t){const{l:e,a:i,b:r}=ki(t),o=Math.atan2(r,i)*Ci;return{h:o<0?o+360:o,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Si,i=t.c;return Pi({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Di(t.h,e.h,i),c:yi(t.c,e.c,i),l:yi(t.l,e.l,i),alpha:yi(t.alpha,e.alpha,i)}}};var Ri=Object.freeze({__proto__:null,lab:Li,hcl:Bi});class Fi{constructor(t,e,i,r,o){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of o)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,r,o){let n=0;if("exponential"===t.name)n=Oi(e,t.base,r,o);else if("linear"===t.name)n=Oi(e,1,r,o);else if("cubic-bezier"===t.name){const s=t.controlPoints;n=new i(s[0],s[1],s[2],s[3]).solve(Oi(e,1,r,o))}return n}static parse(t,e){let[i,r,o,...n]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(o=e.parse(o,2,te),!o)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=re:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Fi(a,i,r,o,s):e.error(`Type ${ue(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const o=e.length;if(r>=e[o-1])return i[o-1].evaluate(t);const n=mi(e,r),s=Fi.interpolationFactor(this.interpolation,r,e[n],e[n+1]),a=i[n].evaluate(t),l=i[n+1].evaluate(t);return"interpolate"===this.operator?xi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Bi.reverse(Bi.interpolate(Bi.forward(a),Bi.forward(l),s)):Li.reverse(Li.interpolate(Li.forward(a),Li.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tpe(r,t.type)));return new Vi(n?ne:i,o)}evaluate(t){let e,i=null,r=0;for(const o of this.args){if(r++,i=o.evaluate(t),i&&i instanceof we&&!i.available&&(e||(e=i),i=null,r===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var ji=Vi;class Ni{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new Ie(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Ie(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var $i=Zi;class qi{constructor(t,e){this.type=ie,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,ne);return i&&r?de(i.type,[ie,ee,te,Qt,ne])?new qi(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ue(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!fe(e,["boolean","string","number","null"]))throw new Ie(`Expected first argument to be of type boolean, string, number or null, but found ${ue(Se(e))} instead.`);if(!fe(i,["string","array"]))throw new Ie(`Expected second argument to be of type array or string, but found ${ue(Se(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Xi=qi;class Wi{constructor(t,e,i){this.type=te,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,ne);if(!i||!r)return null;if(!de(i.type,[ie,ee,te,Qt,ne]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ue(i.type)} instead`);if(4===t.length){const o=e.parse(t[3],3,te);return o?new Wi(i,r,o):null}return new Wi(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!fe(e,["boolean","string","number","null"]))throw new Ie(`Expected first argument to be of type boolean, string, number or null, but found ${ue(Se(e))} instead.`);if(!fe(i,["string","array"]))throw new Ie(`Expected second argument to be of type array or string, but found ${ue(Se(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Hi=Wi;class Yi{constructor(t,e,i,r,o,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=o,this.otherwise=n}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const o={},n=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Se(t)))return null}else i=Se(t);if(void 0!==o[String(t)])return c.error("Branch labels must be unique.");o[String(t)]=n.length}const u=e.parse(l,s,r);if(!u)return null;r=r||u.type,n.push(u)}const s=e.parse(t[1],1,ne);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Yi(i,r,s,o,n,a):null}evaluate(t){const e=this.input.evaluate(t);return(Se(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const o=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?o(r[0]):r.map(o)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var Ki=Yi;class Ji{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let o=1;oe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Qi=Ji;class tr{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,te);if(!i||!r)return null;if(!de(i.type,[ce(ne),ee,ne]))return e.error(`Expected first argument to be of type array or string, but found ${ue(i.type)} instead`);if(4===t.length){const o=e.parse(t[3],3,te);return o?new tr(i.type,i,r,o):null}return new tr(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!fe(e,["string","array"]))throw new Ie(`Expected first argument to be of type array or string, but found ${ue(Se(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var er=tr;function ir(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function rr(t,e,i,r){return 0===r.compare(e,i)}function or(t,e,i){const r="=="!==t&&"!="!==t;return class o{constructor(t,e,i){this.type=ie,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let n=e.parse(t[1],1,ne);if(!n)return null;if(!ir(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${ue(n.type)}'.`);let s=e.parse(t[2],2,ne);if(!s)return null;if(!ir(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${ue(s.type)}'.`);if(n.type.kind!==s.type.kind&&"value"!==n.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${ue(n.type)}' and '${ue(s.type)}'.`);r&&("value"===n.type.kind&&"value"!==s.type.kind?n=new Pe(s.type,[n]):"value"!==n.type.kind&&"value"===s.type.kind&&(s=new Pe(n.type,[s])));let a=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==s.type.kind&&"value"!==n.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,se),!a)return null}return new o(n,s,a)}evaluate(o){const n=this.lhs.evaluate(o),s=this.rhs.evaluate(o);if(r&&this.hasUntypedArgument){const e=Se(n),i=Se(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ie(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Se(n),i=Se(s);if("string"!==t.kind||"string"!==i.kind)return e(o,n,s)}return this.collator?i(o,n,s,this.collator.evaluate(o)):e(o,n,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const nr=or("==",(function(t,e,i){return e===i}),rr),sr=or("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!rr(0,e,i,r)})),ar=or("<",(function(t,e,i){return e",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),cr=or("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),ur=or(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class hr{constructor(t,e,i,r,o){this.type=ee,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,te);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let o=null;if(r.locale&&(o=e.parse(r.locale,1,ee),!o))return null;let n=null;if(r.currency&&(n=e.parse(r.currency,1,ee),!n))return null;let s=null;if(r["min-fraction-digits"]&&(s=e.parse(r["min-fraction-digits"],1,te),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,te),!a)?null:new hr(i,o,n,s,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class pr{constructor(t){this.type=te,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${ue(i.type)} instead.`):new pr(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Ie(`Expected value to be of type string or array, but found ${ue(Se(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const dr={"==":nr,"!=":sr,">":lr,"<":ar,">=":ur,"<=":cr,array:Pe,at:$i,boolean:Pe,case:Qi,coalesce:ji,collator:Ne,format:De,image:Le,in:Xi,"index-of":Hi,interpolate:Ui,"interpolate-hcl":Ui,"interpolate-lab":Ui,length:pr,let:Gi,literal:Ae,match:Ki,number:Pe,"number-format":hr,object:Pe,slice:er,step:gi,string:Pe,"to-boolean":Fe,"to-color":Fe,"to-number":Fe,"to-string":Fe,var:hi,within:si};function fr(t,[e,i,r,o]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const n=o?o.evaluate(t):1,s=Te(e,i,r,n);if(s)throw new Ie(s);return new ye(e/255*n,i/255*n,r/255*n,n)}function mr(t,e){return t in e}function _r(t,e){const i=e[t];return void 0===i?null:i}function gr(t){return{type:t}}je.register(dr,{error:[{kind:"error"},[ee],(t,[e])=>{throw new Ie(e.evaluate(t))}],typeof:[ee,[ne],(t,[e])=>ue(Se(e.evaluate(t)))],"to-rgba":[ce(te,4),[re],(t,[e])=>e.evaluate(t).toArray()],rgb:[re,[te,te,te],fr],rgba:[re,[te,te,te,te],fr],has:{type:ie,overloads:[[[ee],(t,[e])=>mr(e.evaluate(t),t.properties())],[[ee,oe],(t,[e,i])=>mr(e.evaluate(t),i.evaluate(t))]]},get:{type:ne,overloads:[[[ee],(t,[e])=>_r(e.evaluate(t),t.properties())],[[ee,oe],(t,[e,i])=>_r(e.evaluate(t),i.evaluate(t))]]},"feature-state":[ne,[ee],(t,[e])=>_r(e.evaluate(t),t.featureState||{})],properties:[oe,[],t=>t.properties()],"geometry-type":[ee,[],t=>t.geometryType()],id:[ne,[],t=>t.id()],zoom:[te,[],t=>t.globals.zoom],pitch:[te,[],t=>t.globals.pitch||0],"distance-from-center":[te,[],t=>t.distanceFromCenter()],"heatmap-density":[te,[],t=>t.globals.heatmapDensity||0],"line-progress":[te,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[te,[],t=>t.globals.skyRadialProgress||0],accumulated:[ne,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[te,gr(te),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[te,gr(te),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:te,overloads:[[[te,te],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[te],(t,[e])=>-e.evaluate(t)]]},"/":[te,[te,te],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[te,[te,te],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[te,[],()=>Math.LN2],pi:[te,[],()=>Math.PI],e:[te,[],()=>Math.E],"^":[te,[te,te],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[te,[te],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[te,[te],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[te,[te],(t,[e])=>Math.log(e.evaluate(t))],log2:[te,[te],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[te,[te],(t,[e])=>Math.sin(e.evaluate(t))],cos:[te,[te],(t,[e])=>Math.cos(e.evaluate(t))],tan:[te,[te],(t,[e])=>Math.tan(e.evaluate(t))],asin:[te,[te],(t,[e])=>Math.asin(e.evaluate(t))],acos:[te,[te],(t,[e])=>Math.acos(e.evaluate(t))],atan:[te,[te],(t,[e])=>Math.atan(e.evaluate(t))],min:[te,gr(te),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[te,gr(te),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[te,[te],(t,[e])=>Math.abs(e.evaluate(t))],round:[te,[te],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[te,[te],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[te,[te],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ie,[ee,ne],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ie,[ne],(t,[e])=>t.id()===e.value],"filter-type-==":[ie,[ee],(t,[e])=>t.geometryType()===e.value],"filter-<":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r{const i=t.id(),r=e.value;return typeof i==typeof r&&i":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r>o}],"filter-id->":[ie,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r<=o}],"filter-id-<=":[ie,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r>=o}],"filter-id->=":[ie,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ie,[ne],(t,[e])=>e.value in t.properties()],"filter-has-id":[ie,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ie,[ce(ee)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ie,[ce(ne)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ie,[ee,ce(ne)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ie,[ee,ce(ne)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const o=i+r>>1;if(e[o]===t)return!0;e[o]>t?r=o-1:i=o+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ie,overloads:[[[ie,ie],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[gr(ie),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ie,overloads:[[[ie,ie],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[gr(ie),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ie,[ie],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ie,[ee],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ee,[ee],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ee,[ee],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ee,gr(ne),(t,e)=>e.map((e=>Ce(e.evaluate(t)))).join("")],"resolved-locale":[ee,[se],(t,[e])=>e.evaluate(t).resolvedLocale()]});var yr=dr;function xr(t){return{result:"success",value:t}}function vr(t){return{result:"error",value:t}}function br(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function wr(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Tr(t){return!!t.expression&&t.expression.interpolated}function Er(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Sr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Cr(t){return t}function Mr(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],o=r||!(r||void 0!==t.property),n=t.type||(Tr(e)?"exponential":"interval");if(i&&((t=qt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],ye.parse(t[1])]))),t.default=ye.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Ri[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===n)s=kr;else if("interval"===n)s=zr;else if("categorical"===n){s=Ir,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==n)throw new Error(`Unknown function type "${n}"`);s=Pr}if(r){const i={},r=[];for(let e=0;et[0])),evaluate:({zoom:i},r)=>kr({stops:o,base:t.base},e,i).evaluate(i,r)}}if(o){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Ui.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,r){const o=r&&r.properties?r.properties[t.property]:void 0;return void 0===o?Ar(t.default,e.default):s(t,e,o,a,l)}}}function Ar(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Ir(t,e,i,r,o){return Ar(typeof i===o?r[i]:void 0,t.default,e.default)}function zr(t,e,i){if("number"!==Er(i))return Ar(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const o=mi(t.stops.map((t=>t[0])),i);return t.stops[o][1]}function kr(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Er(i))return Ar(t.default,e.default);const o=t.stops.length;if(1===o)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[o-1][0])return t.stops[o-1][1];const n=mi(t.stops.map((t=>t[0])),i),s=function(t,e,i,r){const o=r-i,n=t-i;return 0===o?0:1===e?n/o:(Math.pow(e,n)-1)/(Math.pow(e,o)-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),a=t.stops[n][1],l=t.stops[n+1][1];let c=xi[e.type]||Cr;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Ri[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function Pr(t,e,i){return"color"===e.type?i=ye.parse(i):"formatted"===e.type?i=be.fromString(i.toString()):"resolvedImage"===e.type?i=we.fromString(i.toString()):Er(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Ar(i,t.default,e.default)}class Dr{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Ue,this._defaultValue=e?function(t){return"color"===t.type&&(Sr(t.default)||Array.isArray(t.default))?new ye(0,0,0,0):"color"===t.type?ye.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,o,n,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=n,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,o,n,s,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=n||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ie(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Lr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in yr}function Br(t,e){const i=new di(yr,[],e?function(t){const e={color:re,string:ee,number:te,enum:ee,boolean:ie,formatted:ae,resolvedImage:le};return"array"===t.type?ce(e[t.value]||ne,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?xr(new Dr(r,e)):vr(i.errors)}class Rr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!li(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,o,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,o,n)}evaluate(t,e,i,r,o,n){return this._styleExpression.evaluate(t,e,i,r,o,n)}}class Fr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!li(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,o,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,o,n)}evaluate(t,e,i,r,o,n){return this._styleExpression.evaluate(t,e,i,r,o,n)}interpolationFactor(t,e,i){return this.interpolationType?Ui.interpolationFactor(this.interpolationType,t,e,i):0}}function Or(t,e){if("error"===(t=Br(t,e)).result)return t;const i=t.value.expression,r=ai(i);if(!r&&!br(e))return vr([new Yt("","data expressions not supported")]);const o=ci(i,["zoom","pitch","distance-from-center"]);if(!o&&!wr(e))return vr([new Yt("","zoom expressions not supported")]);const n=Vr(i);return n||o?n instanceof Yt?vr([n]):n instanceof Ui&&!Tr(e)?vr([new Yt("",'"interpolate" expressions cannot be used with this property')]):xr(n?new Fr(r?"camera":"composite",t.value,n.labels,n instanceof Ui?n.interpolation:void 0):new Rr(r?"constant":"source",t.value)):vr([new Yt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Ur{constructor(t,e){this._parameters=t,this._specification=e,qt(this,Mr(this._parameters,this._specification))}static deserialize(t){return new Ur(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Vr(t){let e=null;if(t instanceof Gi)e=Vr(t.result);else if(t instanceof ji){for(const i of t.args)if(e=Vr(i),e)break}else(t instanceof gi||t instanceof Ui)&&t.input instanceof je&&"zoom"===t.input.name&&(e=t);return e instanceof Yt||t.eachChild((t=>{const i=Vr(t);i instanceof Yt?e=i:!e&&i?e=new Yt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Yt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class jr{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function Nr(t){const e=t.key,i=t.value,r=t.valueSpec||{},o=t.objectElementValidators||{},n=t.style,s=t.styleSpec;let a=[];const l=Er(i);if("object"!==l)return[new jr(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let u;o[l]?u=o[l]:r[l]?u=wo:o["*"]?u=o["*"]:r["*"]&&(u=wo),u?a=a.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:n,styleSpec:s,object:i,objectKey:t},i)):a.push(new jr(e,i[t],`unknown property "${t}"`))}for(const t in r)o[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&a.push(new jr(e,i,`missing required property "${t}"`));return a}function Gr(t){const e=t.value,i=t.valueSpec,r=t.style,o=t.styleSpec,n=t.key,s=t.arrayElementValidator||wo;if("array"!==Er(e))return[new jr(n,e,`array expected, ${Er(e)} found`)];if(i.length&&e.length!==i.length)return[new jr(n,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.lengtho)return[new jr(e,i,`${i} is greater than the maximum value ${o}`)]}return[]}function $r(t){const e=t.valueSpec,i=Xt(t.value.type);let r,o,n,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Er(t.value.stops)&&"array"===Er(t.value.stops[0])&&"object"===Er(t.value.stops[0][0]),u=Nr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new jr(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Gr({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Er(r)&&0===r.length&&e.push(new jr(t.key,r,"array must have at least one stop")),e},default:function(t){return wo({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&u.push(new jr(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||u.push(new jr(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Tr(t.valueSpec)&&u.push(new jr(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!br(t.valueSpec)?u.push(new jr(t.key,t.value,"property functions not supported")):a&&!wr(t.valueSpec)&&u.push(new jr(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||u.push(new jr(t.key,t.value,'"property" property is required')),u;function h(t){let i=[];const r=t.value,a=t.key;if("array"!==Er(r))return[new jr(a,r,`array expected, ${Er(r)} found`)];if(2!==r.length)return[new jr(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Er(r[0]))return[new jr(a,r,`object expected, ${Er(r[0])} found`)];if(void 0===r[0].zoom)return[new jr(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new jr(a,r,"object stop key must have value")];const e=Xt(r[0].zoom);if("number"!=typeof e)return[new jr(a,r[0].zoom,"stop zoom values must be numbers")];if(n&&n>e)return[new jr(a,r[0].zoom,"stop zoom values must appear in ascending order")];e!==n&&(n=e,o=void 0,s={}),i=i.concat(Nr({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Zr,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return Lr(Wt(r[1]))?i.concat([new jr(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(wo({key:`${a}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,n){const a=Er(t.value),l=Xt(t.value),c=null!==t.value?t.value:n;if(r){if(a!==r)return[new jr(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new jr(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return br(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jr(t.key,c,r)]}return"categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof o&&void 0!==o&&lnew jr(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new jr(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!li(i))return[new jr(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Xr(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!ci(i,["zoom","feature-state"]))return[new jr(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!ai(i))return[new jr(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Xr(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const t of e.valueSpec.expression.parameters)i.delete(t);if(0===i.size)return[];const r=[];return t instanceof je&&i.has(t.name)?[new jr(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{r.push(...Xr(t,e))})),r)}function Wr(t){const e=t.key,i=t.value,r=t.valueSpec,o=[];return Array.isArray(r.values)?-1===r.values.indexOf(Xt(i))&&o.push(new jr(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Xt(i))&&o.push(new jr(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function Hr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Hr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Yr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Hr(t)||(t=ro(t));const i=t;let r=!0;try{r=function(t){if(!Qr(t))return t;let e=Wt(t);return Jr(e),e=Kr(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const o=$t[`filter_${e}`],n=Br(r,o);let s=null;if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>n.value.evaluate(t,e,{},i);let a=null,l=null;if(r!==i){const t=Br(i,o);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,r,o,n)=>t.value.evaluate(e,i,{},r,void 0,void 0,o,n),l=!ai(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:io(r),needFeature:!!l}}function Kr(t){if(!Array.isArray(t))return t;const e=function(t){if(to.has(t[0]))for(let e=1;eKr(t)))}function Jr(t){let e=!1;const i=[];if("case"===t[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function eo(t,e){return te?1:0}function io(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?oo(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(ro))):"all"===e?["all"].concat(t.slice(1).map(ro)):"none"===e?["all"].concat(t.slice(1).map(ro).map(ao)):"in"===e?no(t[1],t.slice(2)):"!in"===e?ao(no(t[1],t.slice(2))):"has"===e?so(t[1]):"!has"===e?ao(so(t[1])):"within"!==e||t;var i}function oo(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function no(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(eo)]]:["filter-in-small",t,["literal",e]]}}function so(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ao(t){return["!",t]}function lo(t){return Hr(Wt(t.value))?qr(qt({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):co(t)}function co(t){const e=t.value,i=t.key;if("array"!==Er(e))return[new jr(i,e,`array expected, ${Er(e)} found`)];const r=t.styleSpec;let o,n=[];if(e.length<1)return[new jr(i,e,"filter array must have at least 1 element")];switch(n=n.concat(Wr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),Xt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Xt(e[1])&&n.push(new jr(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new jr(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=Er(e[1]),"string"!==o&&n.push(new jr(`${i}[1]`,e[1],`string expected, ${o} found`)));for(let s=2;s{t in i&&e.push(new jr(r,i[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((e=>{Xt(e.id)===a&&(t=e)})),t?t.ref?e.push(new jr(r,i.ref,"ref cannot reference another ref layer")):s=Xt(t.type):"string"==typeof a&&e.push(new jr(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const t=o.sources&&o.sources[i.source],n=t&&Xt(t.type);t?"vector"===n&&"raster"===s?e.push(new jr(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===n&&"raster"!==s?e.push(new jr(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==s?e.push(new jr(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===n&&t.lineMetrics||e.push(new jr(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new jr(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new jr(r,i.source,`source "${i.source}" not found`))}else e.push(new jr(r,i,'missing required property "source"'));return e=e.concat(Nr({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>wo({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>lo(qt({layerType:s},t)),layout:t=>Nr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>po(qt({layerType:s},t))}}),paint:t=>Nr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>ho(qt({layerType:s},t))}})}})),e}function mo(t){const e=t.value,i=t.key,r=Er(e);return"string"!==r?[new jr(i,e,`string expected, ${r} found`)]:[]}const _o={promoteId:function({key:t,value:e}){if("string"===Er(e))return mo({key:t,value:e});{const i=[];for(const r in e)i.push(...mo({key:`${t}.${r}`,value:e[r]}));return i}}};function go(t){const e=t.value,i=t.key,r=t.styleSpec,o=t.style;if(!e.type)return[new jr(i,e,'"type" is required')];const n=Xt(e.type);let s;switch(n){case"vector":case"raster":case"raster-dem":return s=Nr({key:i,value:e,valueSpec:r[`source_${n.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:_o}),s;case"geojson":if(s=Nr({key:i,value:e,valueSpec:r.source_geojson,style:o,styleSpec:r,objectElementValidators:_o}),e.cluster)for(const t in e.clusterProperties){const[r,o]=e.clusterProperties[t],n="string"==typeof r?[r,["accumulated"],["get",t]]:r;s.push(...qr({key:`${i}.${t}.map`,value:o,expressionContext:"cluster-map"})),s.push(...qr({key:`${i}.${t}.reduce`,value:n,expressionContext:"cluster-reduce"}))}return s;case"video":return Nr({key:i,value:e,valueSpec:r.source_video,style:o,styleSpec:r});case"image":return Nr({key:i,value:e,valueSpec:r.source_image,style:o,styleSpec:r});case"canvas":return[new jr(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Wr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:o,styleSpec:r})}}function yo(t){const e=t.value,i=t.styleSpec,r=i.light,o=t.style;let n=[];const s=Er(e);if(void 0===e)return n;if("object"!==s)return n=n.concat([new jr("light",e,`object expected, ${s} found`)]),n;for(const t in e){const s=t.match(/^(.*)-transition$/);n=n.concat(s&&r[s[1]]&&r[s[1]].transition?wo({key:t,value:e[t],valueSpec:i.transition,style:o,styleSpec:i}):r[t]?wo({key:t,value:e[t],valueSpec:r[t],style:o,styleSpec:i}):[new jr(t,e[t],`unknown property "${t}"`)])}return n}function xo(t){const e=t.value,i=t.key,r=t.style,o=t.styleSpec,n=o.terrain;let s=[];const a=Er(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new jr("terrain",e,`object expected, ${a} found`)]),s;for(const t in e){const i=t.match(/^(.*)-transition$/);s=s.concat(i&&n[i[1]]&&n[i[1]].transition?wo({key:t,value:e[t],valueSpec:o.transition,style:r,styleSpec:o}):n[t]?wo({key:t,value:e[t],valueSpec:n[t],style:r,styleSpec:o}):[new jr(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=r.sources&&r.sources[e.source],o=t&&Xt(t.type);t?"raster-dem"!==o&&s.push(new jr(i,e.source,`terrain cannot be used with a source of type ${String(o)}, it only be used with a "raster-dem" source type`)):s.push(new jr(i,e.source,`source "${e.source}" not found`))}else s.push(new jr(i,e,'terrain is missing required property "source"'));return s}function vo(t){const e=t.value,i=t.style,r=t.styleSpec,o=r.fog;let n=[];const s=Er(e);if(void 0===e)return n;if("object"!==s)return n=n.concat([new jr("fog",e,`object expected, ${s} found`)]),n;for(const t in e){const s=t.match(/^(.*)-transition$/);n=n.concat(s&&o[s[1]]&&o[s[1]].transition?wo({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):o[t]?wo({key:t,value:e[t],valueSpec:o[t],style:i,styleSpec:r}):[new jr(t,e[t],`unknown property "${t}"`)])}return n}const bo={"*":()=>[],array:Gr,boolean:function(t){const e=t.value,i=t.key,r=Er(e);return"boolean"!==r?[new jr(i,e,`boolean expected, ${r} found`)]:[]},number:Zr,color:function(t){const e=t.key,i=t.value,r=Er(i);return"string"!==r?[new jr(e,i,`color expected, ${r} found`)]:null===_e.parseCSSColor(i)?[new jr(e,i,`color expected, "${i}" found`)]:[]},enum:Wr,filter:lo,function:$r,layer:fo,object:Nr,source:go,light:yo,terrain:xo,fog:vo,string:mo,formatted:function(t){return 0===mo(t).length?[]:qr(t)},resolvedImage:function(t){return 0===mo(t).length?[]:qr(t)},projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,o=t.style;let n=[];const s=Er(e);if("object"===s)for(const t in e)n=n.concat(wo({key:t,value:e[t],valueSpec:r[t],style:o,styleSpec:i}));else"string"!==s&&(n=n.concat([new jr("projection",e,`object or string expected, ${s} found`)]));return n}};function wo(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Sr(Xt(e))?$r(t):i.expression&&Lr(Wt(e))?qr(t):i.type&&bo[i.type]?bo[i.type](t):Nr(qt({},t,{valueSpec:i.type?r[i.type]:i}))}function To(t){const e=t.value,i=t.key,r=mo(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new jr(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new jr(i,e,'"glyphs" url must include a "{range}" token'))),r}function Eo(t,e=$t){return Mo(wo({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:To,"*":()=>[]}}))}const So=t=>Mo(ho(t)),Co=t=>Mo(po(t));function Mo(t){return t.slice().sort(((t,e)=>t.line&&e.line?t.line-e.line:0))}function Ao(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new Gt(new Error(r.message))),i=!0;return i}var Io=zo;function zo(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(e=o[1])+2*(i=o[2]);for(var n=0;n=u[d+0]&&r>=u[d+1])?(s[p]=!0,n.push(c[p])):s[p]=!1}}},zo.prototype._forEachCell=function(t,e,i,r,o,n,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&o.call(this,t,e,i,r,f,n,s,a))return}},zo.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},zo.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},zo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,i=0,r=0;r=0||(o[e]=Bo(t[e],i)));t instanceof Error&&(o.message=t.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(o.$name=r),o}throw new Error("can't serialize object of type "+typeof t)}function Ro(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Do(t)||Lo(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map(Ro);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=ko[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(r[e]=Ro(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class Fo{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=1536&&t<=1791,Uo=t=>t>=1872&&t<=1919,Vo=t=>t>=2208&&t<=2303,jo=t=>t>=11904&&t<=12031,No=t=>t>=12032&&t<=12255,Go=t=>t>=12272&&t<=12287,Zo=t=>t>=12288&&t<=12351,$o=t=>t>=12352&&t<=12447,qo=t=>t>=12448&&t<=12543,Xo=t=>t>=12544&&t<=12591,Wo=t=>t>=12704&&t<=12735,Ho=t=>t>=12736&&t<=12783,Yo=t=>t>=12784&&t<=12799,Ko=t=>t>=12800&&t<=13055,Jo=t=>t>=13056&&t<=13311,Qo=t=>t>=13312&&t<=19903,tn=t=>t>=19968&&t<=40959,en=t=>t>=40960&&t<=42127,rn=t=>t>=42128&&t<=42191,on=t=>t>=44032&&t<=55215,nn=t=>t>=63744&&t<=64255,sn=t=>t>=64336&&t<=65023,an=t=>t>=65040&&t<=65055,ln=t=>t>=65072&&t<=65103,cn=t=>t>=65104&&t<=65135,un=t=>t>=65136&&t<=65279,hn=t=>t>=65280&&t<=65519;function pn(t){for(const e of t)if(mn(e.charCodeAt(0)))return!0;return!1}function dn(t){for(const e of t)if(!fn(e.charCodeAt(0)))return!1;return!0}function fn(t){return!(Oo(t)||Uo(t)||Vo(t)||sn(t)||un(t))}function mn(t){return!(746!==t&&747!==t&&(t<4352||!(Wo(t)||Xo(t)||ln(t)&&!(t>=65097&&t<=65103)||nn(t)||Jo(t)||jo(t)||Ho(t)||!(!Zo(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Qo(t)||tn(t)||Ko(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||on(t)||$o(t)||Go(t)||(t=>t>=12688&&t<=12703)(t)||No(t)||Yo(t)||qo(t)&&12540!==t||!(!hn(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!cn(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||an(t)||(t=>t>=19904&&t<=19967)(t)||en(t)||rn(t))))}function _n(t){return!(mn(t)||function(t){return!!((t=>t>=128&&t<=255)(t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||(t=>t>=8192&&t<=8303)(t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||(t=>t>=8448&&t<=8527)(t)||(t=>t>=8528&&t<=8591)(t)||(t=>t>=8960&&t<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||(t=>t>=9216&&t<=9279)(t)&&9251!==t||(t=>t>=9280&&t<=9311)(t)||(t=>t>=9312&&t<=9471)(t)||(t=>t>=9632&&t<=9727)(t)||(t=>t>=9728&&t<=9983)(t)&&!(t>=9754&&t<=9759)||(t=>t>=11008&&t<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Zo(t)||qo(t)||(t=>t>=57344&&t<=63743)(t)||ln(t)||cn(t)||hn(t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function gn(t){return t>=1424&&t<=2303||sn(t)||un(t)}function yn(t,e){return!(!e&&gn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function xn(t){for(const e of t)if(gn(e.charCodeAt(0)))return!0;return!1}const vn="deferred",bn="loading",wn="loaded";let Tn=null,En="unavailable",Sn=null;const Cn=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(En="error"),Tn&&Tn(t)};function Mn(){An.fire(new Nt("pluginStateChange",{pluginStatus:En,pluginURL:Sn}))}const An=new Zt,In=function(){return En},zn=function(){if(En!==vn||!Sn)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");En=bn,Mn(),Sn&&Pt({url:Sn},(t=>{t?Cn(t):(En=wn,Mn())}))},kn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>En===wn||null!=kn.applyArabicShaping,isLoading:()=>En===bn,setState(t){En=t.pluginStatus,Sn=t.pluginURL},isParsed:()=>null!=kn.applyArabicShaping&&null!=kn.processBidirectionalText&&null!=kn.processStyledBidirectionalText,getPluginURL:()=>Sn};class Pn{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Fo,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!yn(i.charCodeAt(0),e))return!1;return!0}(t,kn.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class Dn{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Sr(t))return new Ur(t,e);if(Lr(t)){const i=Or(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=ye.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Ln{constructor(t){this.property=t,this.value=new Dn(t,void 0)}transitioned(t,e){return new Rn(this.property,this.value,e,v({},t.transition,this.transition),t.now)}untransitioned(){return new Rn(this.property,this.value,null,{},0)}}class Bn{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return z(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ln(this._values[t].property)),this._values[t].value=new Dn(this._values[t].property,null===e?void 0:z(e))}getTransition(t){return z(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ln(this._values[t].property)),this._values[t].transition=z(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new Fn(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new Fn(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Rn{constructor(t,e,i,r,o){const n=r.delay||0,s=r.duration||0;o=o||0,this.property=t,this.value=e,this.begin=o+n,this.end=this.begin+s,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,o=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(n){if(r>this.end)return this.prior=null,o;if(this.value.isDataDriven())return this.prior=null,o;if(rr.zoomHistory.lastIntegerZoom?{from:t,to:e,other:i}:{from:i,to:e,other:t}}interpolate(t){return t}}class Zn{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const o=t.expression.evaluate(e,null,{},i,r);return this._calculate(o,o,o,e)}return this._calculate(t.expression.evaluate(new Pn(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Pn(Math.floor(e.zoom),e)),t.expression.evaluate(new Pn(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class $n{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class qn{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const e=new Pn(0,{});for(const i in t){const r=t[i];r.specification.overridable&&this.overridableProperties.push(i);const o=this.defaultPropertyValues[i]=new Dn(r,void 0),n=this.defaultTransitionablePropertyValues[i]=new Ln(r);this.defaultTransitioningPropertyValues[i]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=o.possiblyEvaluate(e)}}}function Xn(t,e){return 256*(t=m(Math.floor(t),0,255))+m(Math.floor(e),0,255)}Po(Nn,"DataDrivenProperty"),Po(jn,"DataConstantProperty"),Po(Gn,"CrossFadedDataDrivenProperty"),Po(Zn,"CrossFadedProperty"),Po($n,"ColorRampProperty");const Wn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Hn{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Yn{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Kn(t,e=1){let i=0,r=0;return{members:t.map((t=>{const o=Wn[t.type].BYTES_PER_ELEMENT,n=i=Jn(i,Math.max(e,o)),s=t.components||1;return r=Math.max(r,o),i+=o*s,{name:t.name,type:t.type,components:s,offset:n}})),size:Jn(i,Math.max(r,e)),alignment:e}}function Jn(t,e){return Math.ceil(t/e)*e}class Qn extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Qn.prototype.bytesPerElement=4,Po(Qn,"StructArrayLayout2i4");class ts extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const o=3*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,t}}ts.prototype.bytesPerElement=6,Po(ts,"StructArrayLayout3i6");class es extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=o,t}}es.prototype.bytesPerElement=8,Po(es,"StructArrayLayout4i8");class is extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,o,n,s)}emplace(t,e,i,r,o,n,s,a){const l=6*t,c=12*t,u=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=o,this.uint8[c+6]=n,this.uint8[c+7]=s,this.float32[u+2]=a,t}}is.prototype.bytesPerElement=12,Po(is,"StructArrayLayout2i4ub1f12");class rs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=o,t}}rs.prototype.bytesPerElement=16,Po(rs,"StructArrayLayout4f16");class os extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,i,r,o,n,s,a,l,c)}emplace(t,e,i,r,o,n,s,a,l,c,u){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=o,this.uint16[h+4]=n,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,t}}os.prototype.bytesPerElement=20,Po(os,"StructArrayLayout10ui20");class ns extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,o,n,s,a)}emplace(t,e,i,r,o,n,s,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=o,this.uint16[c+4]=n,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}ns.prototype.bytesPerElement=16,Po(ns,"StructArrayLayout8ui16");class ss extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,o,n)}emplace(t,e,i,r,o,n,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=o,this.int16[a+4]=n,this.int16[a+5]=s,t}}ss.prototype.bytesPerElement=12,Po(ss,"StructArrayLayout6i12");class as extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,o,n,s,a,l,c,u,h)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=o,this.uint16[d+4]=n,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,t}}as.prototype.bytesPerElement=24,Po(as,"StructArrayLayout4i4ui4i24");class ls extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,o,n)}emplace(t,e,i,r,o,n,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=o,this.float32[l+3]=n,this.float32[l+4]=s,t}}ls.prototype.bytesPerElement=20,Po(ls,"StructArrayLayout3i3f20");class cs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}cs.prototype.bytesPerElement=4,Po(cs,"StructArrayLayout1ul4");class us extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,o,n,s,a,l,c,u,h,p)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p,d){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=o,this.int16[f+4]=n,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}us.prototype.bytesPerElement=40,Po(us,"StructArrayLayout5i4f1i1ul2ui40");class hs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,o,n,s)}emplace(t,e,i,r,o,n,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=o,this.int16[l+5]=n,this.int16[l+6]=s,this.int16[l+7]=a,t}}hs.prototype.bytesPerElement=16,Po(hs,"StructArrayLayout3i2i2i16");class ps extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,o)}emplace(t,e,i,r,o,n){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=o,this.int16[a+7]=n,t}}ps.prototype.bytesPerElement=16,Po(ps,"StructArrayLayout2f1f2i16");class ds extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=12*t,s=3*t;return this.uint8[n+0]=e,this.uint8[n+1]=i,this.float32[s+1]=r,this.float32[s+2]=o,t}}ds.prototype.bytesPerElement=12,Po(ds,"StructArrayLayout2ub2f12");class fs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const o=3*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,t}}fs.prototype.bytesPerElement=12,Po(fs,"StructArrayLayout3f12");class ms extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const o=3*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=r,t}}ms.prototype.bytesPerElement=6,Po(ms,"StructArrayLayout3ui6");class _s extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b){const w=30*t,T=15*t,E=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=o,this.float32[T+3]=n,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,t}}_s.prototype.bytesPerElement=60,Po(_s,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class gs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,C,M,A,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,C,M,A,I)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,C,M,A,I,z){const k=38*t,P=19*t;return this.int16[k+0]=e,this.int16[k+1]=i,this.int16[k+2]=r,this.float32[P+2]=o,this.float32[P+3]=n,this.int16[k+8]=s,this.int16[k+9]=a,this.int16[k+10]=l,this.int16[k+11]=c,this.int16[k+12]=u,this.int16[k+13]=h,this.uint16[k+14]=p,this.uint16[k+15]=d,this.uint16[k+16]=f,this.uint16[k+17]=m,this.uint16[k+18]=_,this.uint16[k+19]=g,this.uint16[k+20]=y,this.uint16[k+21]=x,this.uint16[k+22]=v,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=S,this.uint16[k+28]=C,this.uint32[P+15]=M,this.float32[P+16]=A,this.float32[P+17]=I,this.float32[P+18]=z,t}}gs.prototype.bytesPerElement=76,Po(gs,"StructArrayLayout3i2f6i15ui1ul3f76");class ys extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ys.prototype.bytesPerElement=4,Po(ys,"StructArrayLayout1f4");class xs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,o,n,s)}emplace(t,e,i,r,o,n,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=n,this.float32[l+5]=s,this.float32[l+6]=a,t}}xs.prototype.bytesPerElement=28,Po(xs,"StructArrayLayout7f28");class vs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,o)}emplace(t,e,i,r,o,n){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=o,this.float32[s+4]=n,t}}vs.prototype.bytesPerElement=20,Po(vs,"StructArrayLayout5f20");class bs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=6*t;return this.uint32[3*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,this.uint16[n+4]=o,t}}bs.prototype.bytesPerElement=12,Po(bs,"StructArrayLayout1ul3ui12");class ws extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}ws.prototype.bytesPerElement=4,Po(ws,"StructArrayLayout2ui4");class Ts extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Ts.prototype.bytesPerElement=2,Po(Ts,"StructArrayLayout1ui2");class Es extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Es.prototype.bytesPerElement=8,Po(Es,"StructArrayLayout2f8");class Ss extends Hn{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Ss.prototype.size=12;class Cs extends ss{get(t){return new Ss(this,t)}}Po(Cs,"FillExtrusionExtArray");class Ms extends Hn{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Ms.prototype.size=40;class As extends us{get(t){return new Ms(this,t)}}Po(As,"CollisionBoxArray");class Is extends Hn{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}Is.prototype.size=60;class zs extends _s{get(t){return new Is(this,t)}}Po(zs,"PlacedSymbolArray");class ks extends Hn{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}ks.prototype.size=76;class Ps extends gs{get(t){return new ks(this,t)}}Po(Ps,"SymbolInstanceArray");class Ds extends ys{getoffsetX(t){return this.float32[1*t+0]}}Po(Ds,"GlyphOffsetArray");class Ls extends ts{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Po(Ls,"SymbolLineVertexArray");class Bs extends Hn{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Bs.prototype.size=12;class Rs extends bs{get(t){return new Bs(this,t)}}Po(Rs,"FeatureIndexArray");class Fs extends Hn{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Fs.prototype.size=4;class Os extends ws{get(t){return new Fs(this,t)}}Po(Os,"FillExtrusionCentroidArray");class Us extends Hn{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Us.prototype.size=12;class Vs extends ss{get(t){return new Us(this,t)}}Po(Vs,"CircleGlobeExtArray");const js=Kn([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),Ns=Kn([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Gs=me((function(t){t.exports=function(t,e){var i,r,o,n,s,a,l,c;for(r=t.length-(i=3&t.length),o=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:o^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return o^=t.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0}})),Zs=me((function(t){t.exports=function(t,e){for(var i,r=t.length,o=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:o^=(255&t.charCodeAt(n+2))<<16;case 2:o^=(255&t.charCodeAt(n+1))<<8;case 1:o=1540483477*(65535&(o^=255&t.charCodeAt(n)))+((1540483477*(o>>>16)&65535)<<16)}return o=1540483477*(65535&(o^=o>>>13))+((1540483477*(o>>>16)&65535)<<16),(o^=o>>>15)>>>0}})),$s=Gs,qs=Zs;$s.murmur3=Gs,$s.murmur2=qs;class Xs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Ws(t)),this.positions.push(e,i,r)}getPositions(t){const e=Ws(t);let i=0,r=this.ids.length-1;for(;i>1;this.ids[t]>=e?r=t:i=t+1}const o=[];for(;this.ids[i]===e;)o.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return o}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Hs(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Xs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Ws(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:$s(String(t))}function Hs(t,e,i,r){for(;i>1];let n=i-1,s=r+1;for(;;){do{n++}while(t[n]o);if(n>=s)break;Ys(t,n,s),Ys(e,3*n,3*s),Ys(e,3*n+1,3*s+1),Ys(e,3*n+2,3*s+2)}s-i`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new ta(t,e):new Js(t,e)}}class sa{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=e.tl.concat(e.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,e,i,r){const o="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;o&&t.set(o)}getBinding(t,e,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Qs(t,e):new Js(t,e)}}class aa{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,o,n){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Pn(0),e,{},o,r,n);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a)}updatePaintArray(t,e,i,r,o){const n=this.expression.evaluate({zoom:0},i,r,void 0,o);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){const r=oa(i);for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=o,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,r,o,n){const s=this.expression.evaluate(new Pn(this.zoom),e,{},o,r,n),a=this.expression.evaluate(new Pn(this.zoom+1),e,{},o,r,n),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,s,a)}updatePaintArray(t,e,i,r,o){const n=this.expression.evaluate({zoom:this.zoom},i,r,void 0,o),s=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,o);this._setPaintValue(t,e,n,s)}_setPaintValue(t,e,i,r){if("color"===this.type){const o=oa(i),n=oa(r);for(let i=t;i!0)){this.binders={},this._buffers=[];const r=[];for(const o in t.paint._values){if(!i(o))continue;const n=t.paint.get(o);if(!(n instanceof Un&&br(n.property.specification)))continue;const s=da(o,t.type),a=n.value,l=n.property.specification.type,c=n.property.useIntegerZoom,u=n.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(o)&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||h){const i=_a(o,l,"source");this.binders[o]=h?new ca(a,s,l,c,e,i,t.id):new aa(a,s,l,i),r.push(`/a_${o}`)}else{const t=_a(o,l,"composite");this.binders[o]=new la(a,s,l,c,e,t),r.push(`/z_${o}`)}else this.binders[o]=h?new sa(a.value,s):new na(a.value,s,l),r.push(`/u_${o}`)}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof aa||e instanceof la?e.maxValue:0}populatePaintArrays(t,e,i,r,o,n){for(const s in this.binders){const a=this.binders[s];(a instanceof aa||a instanceof la||a instanceof ca)&&a.populatePaintArray(t,e,i,r,o,n)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof sa&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,o,n){let s=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=i.feature(e.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof aa||c instanceof la||c instanceof ca)&&!0===c.expression.isStateDependent){const u=r.paint.get(i);c.expression=u.value,c.updatePaintArray(e.start,e.end,l,t[a],o,n),s=!0}}}}return s}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof na||i instanceof sa)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof aa||i instanceof la||i instanceof ca)for(let e=0;e!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new ua(r,e,i);this.needsUpload=!1,this._featureMap=new Xs,this._bufferOffset=0}populatePaintArrays(t,e,i,r,o,n,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,o,n,s);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r,o){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r,o)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const pa={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function da(t,e){return pa[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const fa={"line-pattern":{source:os,composite:os},"fill-pattern":{source:os,composite:os},"fill-extrusion-pattern":{source:os,composite:os},"line-dasharray":{source:ns,composite:ns}},ma={color:{source:Es,composite:rs},number:{source:ys,composite:Es}};function _a(t,e,i){const r=fa[t];return r&&r[i]||ma[e][i]}Po(na,"ConstantBinder"),Po(sa,"CrossFadedConstantBinder"),Po(aa,"SourceExpressionBinder"),Po(ca,"CrossFadedCompositeBinder"),Po(la,"CompositeExpressionBinder"),Po(ua,"ProgramConfiguration",{omit:["_buffers"]}),Po(ha,"ProgramConfigurationSet");const ga="-transition";class ya extends Zt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new On(e.layout)),e.paint)){this._transitionablePaint=new Bn(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Vn(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(Co,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return M(t,ga)?this._transitionablePaint.getTransition(t.slice(0,-ga.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(So,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(M(t,ga))return this._transitionablePaint.setTransition(t.slice(0,-ga.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],o=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const s=this._transitionablePaint._values[t].value;return s.isDataDriven()||o||r||this._handleOverridablePaintPropertyUpdate(t,n,s)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),I(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,o={}){return(!o||!1!==o.validate)&&Ao(this,t.call(Eo,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:$t,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Un&&br(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Yr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const xa=Kn([{name:"a_pos",components:2,type:"Int16"}],4),va=Kn([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ba{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let o=this.segments[this.segments.length-1];return t>ba.MAX_VERTEX_ARRAY_LENGTH&&P(`Max vertices per segment is ${ba.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!o||o.vertexLength+t>ba.MAX_VERTEX_ARRAY_LENGTH||o.sortKey!==r)&&(o={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(o.sortKey=r),this.segments.push(o)),o}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new ba([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}ba.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Po(ba,"SegmentVector");var wa=8192;class Ta{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Sa?new Sa(t.lng,t.lat):Sa.convert(t),this}setSouthWest(t){return this._sw=t instanceof Sa?new Sa(t.lng,t.lat):Sa.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,o;if(t instanceof Sa)r=t,o=t;else{if(!(t instanceof Ta))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Ta.convert(t)):this.extend(Sa.convert(t)):this;if(r=t._sw,o=t._ne,!r||!o)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(o.lng,i.lng),i.lat=Math.max(o.lat,i.lat)):(this._sw=new Sa(r.lng,r.lat),this._ne=new Sa(o.lng,o.lat)),this}getCenter(){return new Sa((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Sa(this.getWest(),this.getNorth())}getSouthEast(){return new Sa(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Sa.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return!t||t instanceof Ta?t:new Ta(t)}}const Ea=6371008.8;class Sa{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Sa(g(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,o=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Ea*Math.acos(Math.min(o,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Ta(new Sa(this.lng-i,this.lat-e),new Sa(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Sa)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Sa(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Sa(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Ca=2*Math.PI*Ea;function Ma(t){return Ca*Math.cos(t*Math.PI/180)}function Aa(t){return(180+t)/360}function Ia(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function za(t,e){return t/Ma(e)}function ka(t){return 360*t-180}function Pa(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Da(t,e){return t*Ma(Pa(e))}const La=85.051129;class Ba{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Sa.convert(t);return new Ba(Aa(i.lng),Ia(i.lat),za(e,i.lat))}toLngLat(){return new Sa(ka(this.x),Pa(this.y))}toAltitude(){return Da(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ca*(t=Pa(this.y),1/Math.cos(t*Math.PI/180));var t}}function Ra(t,e,i,r,o,s,a,l,c){const u=(e+r)/2,h=(i+o)/2,p=new n(u,h);l(p),function(t,e,i,r,o,n){const s=i-o,a=r-n;return Math.abs((r-e)*s-(i-t)*a)/Math.hypot(s,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(Ra(t,e,i,u,h,s,p,l,c),Ra(t,u,h,r,o,p,a,l,c)):t.push(a)}function Fa(t,e,i){let r=t[0],o=r.x,n=r.y;e(r);const s=[r];for(let a=1;at.x+1||rt.y+1)&&P("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Ga(t,e,i){const r=t.loadGeometry(),o=t.extent,n=wa/o;if(e&&i&&i.projection.isReprojectedInTileSpace){const n=1<{const i=ka((e.x+t.x/o)/n),r=Pa((e.y+t.y/o)/n),u=c.project(i,r);t.x=(u.x*s-a)*o,t.y=(u.y*s-l)*o};for(let e=0;e=o||i.y<0||i.y>=o||(u(i),t.push(i));r[e]=t}}for(const t of r)for(const e of t)Na(e,n);return r}function Za(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Ga(t):[]}}function $a(t,e,i,r,o){t.emplaceBack(2*e+(r+1)/2,2*i+(o+1)/2)}function qa(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class Xa{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Qn,this.indexArray=new ms,this.segments=new ba,this.programConfigurations=new ha(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){const o=this.layers[0],n=[];let s=null;"circle"===o.type&&(s=o.layout.get("circle-sort-key"));for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Za(e,t);if(!this.layers[0]._featureFilter.filter(new Pn(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Ga(e,i,r),patterns:{},sortKey:u};n.push(h)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Vs,a=r.projection);for(const r of n){const{geometry:o,index:n,sourceLayerIndex:s}=r,l=t[n].feature;this.addFeature(r,o,n,e.availableImages,i,a),e.featureIndex.insert(l,o,n,s,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,va.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,r,o,n){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=wa||r<0||r>=wa)continue;if(n){const t=n.projectTilePoint(i,r,o),e=n.upVector(o,i,r),s=this.globeExtVertexArray;qa(s,t,e),qa(s,t,e),qa(s,t,e),qa(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;$a(this.layoutVertexArray,i,r,-1,-1),$a(this.layoutVertexArray,i,r,1,-1),$a(this.layoutVertexArray,i,r,1,1),$a(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r,o)}}function Wa(t,e){for(let i=0;i1){if(Ja(t,e))return!0;for(let r=0;r1?i:i.sub(e)._mult(o)._add(e))}function il(t,e){let i,r,o,n=!1;for(let s=0;se.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(n=!n)}return n}function rl(t,e){let i=!1;for(let r=0,o=t.length-1;re.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(i=!i)}return i}function ol(t,e,i,r,o){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&o>=n.y)return!0;const s=[new n(e,i),new n(e,o),new n(r,o),new n(r,i)];if(t.length>2)for(const e of s)if(rl(t,e))return!0;for(let e=0;eo.x&&e.x>o.x||t.yo.y&&e.y>o.y)return!1;const n=D(t,e,i[0]);return n!==D(t,e,i[1])||n!==D(t,e,i[2])||n!==D(t,e,i[3])}function sl(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function al(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ll(t,e,i,r,o){if(!e[0]&&!e[1])return t;const s=n.convert(e)._mult(o);"viewport"===i&&s._rotate(-r);const a=[];for(let e=0;e0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Bl(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rl(t,e,i){var r=e[0],o=e[1],n=e[2],s=i[0],a=i[1],l=i[2];return t[0]=o*l-n*a,t[1]=n*s-r*l,t[2]=r*a-o*s,t}function Fl(t,e,i){var r=e[0],o=e[1],n=e[2],s=i[3]*r+i[7]*o+i[11]*n+i[15];return t[0]=(i[0]*r+i[4]*o+i[8]*n+i[12])/(s=s||1),t[1]=(i[1]*r+i[5]*o+i[9]*n+i[13])/s,t[2]=(i[2]*r+i[6]*o+i[10]*n+i[14])/s,t}function Ol(t,e,i){var r=i[0],o=i[1],n=i[2],s=e[0],a=e[1],l=e[2],c=o*l-n*a,u=n*s-r*l,h=r*a-o*s,p=o*h-n*u,d=n*c-r*h,f=r*u-o*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,t[0]=s+(c*=m)+(p*=2),t[1]=a+u+d,t[2]=l+h+f,t}var Ul,Vl=Al,jl=Il,Nl=Sl;function Gl(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Zl(t,e,i){var r=e[0],o=e[1],n=e[2],s=e[3];return t[0]=i[0]*r+i[4]*o+i[8]*n+i[12]*s,t[1]=i[1]*r+i[5]*o+i[9]*n+i[13]*s,t[2]=i[2]*r+i[6]*o+i[10]*n+i[14]*s,t[3]=i[3]*r+i[7]*o+i[11]*n+i[15]*s,t}function $l(){var t=new dl(4);return dl!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ql(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Xl(t,e,i){i*=.5;var r=e[0],o=e[1],n=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+s*a,t[1]=o*l+n*a,t[2]=n*l-o*a,t[3]=s*l-r*a,t}function Wl(t,e,i){i*=.5;var r=e[0],o=e[1],n=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l-n*a,t[1]=o*l+s*a,t[2]=n*l+r*a,t[3]=s*l-o*a,t}Tl(),Ul=new dl(4),dl!=Float32Array&&(Ul[0]=0,Ul[1]=0,Ul[2]=0,Ul[3]=0),Tl(),Cl(1,0,0),Cl(0,1,0),$l(),$l(),fl();class Hl{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,i){const r=Bl(e,this.dir);if(Math.abs(r)<1e-6)return!1;const o=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/r;return i[0]=this.pos[0]+this.dir[0]*o,i[1]=this.pos[1]+this.dir[1]*o,i[2]=this.pos[2]+this.dir[2]*o,!0}closestPointOnSphere(t,e,i){if(function(t,e){var i=t[0],r=t[1],o=t[2],n=e[0],s=e[1],a=e[2];return Math.abs(i-n)<=pl*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-s)<=pl*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=pl*Math.max(1,Math.abs(o),Math.abs(a))}(this.pos,t)||0===e)return i[0]=i[1]=i[2]=0,!1;const[r,o,n]=this.dir,s=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=r*r+o*o+n*n,u=2*(s*r+a*o+l*n),h=u*u-4*c*(s*s+a*a+l*l-e*e);if(h<0){const t=Math.max(-u/2,0),c=s+r*t,h=a+o*t,p=l+n*t,d=Math.hypot(c,h,p);return i[0]=c*e/d,i[1]=h*e/d,i[2]=p*e/d,!1}{const t=(-u-Math.sqrt(h))/(2*c);if(t<0){const t=Math.hypot(s,a,l);return i[0]=s*e/t,i[1]=a*e/t,i[2]=l*e/t,!1}return i[0]=s+r*t,i[1]=a+o*t,i[2]=l+n*t,!0}}}class Yl{constructor(t,e,i,r,o){this.TL=t,this.TR=e,this.BR=i,this.BL=r,this.horizon=o}static fromInvProjectionMatrix(t,e,i){const r=[-1,1,1],o=[1,1,1],n=[1,-1,1],s=[-1,-1,1],a=Fl(r,r,t),l=Fl(o,o,t),c=Fl(n,n,t),u=Fl(s,s,t);return new Yl(a,l,c,u,e/i)}}class Kl{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i,r){const o=Math.pow(2,i),n=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const n=Zl([],i,t),s=1/n[3]/e*o;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(n,n,[s,s,r?1/n[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=Ll([],Rl([],Vl([],n[t[0]],n[t[1]]),Vl([],n[t[2]],n[t[1]]))),i=-Bl(e,n[t[1]]);return e.concat(i)}));return new Kl(n,s)}}class Jl{constructor(t,e){this.min=t,this.max=e,this.center=Pl([],Ml([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],i=El(this.min),r=El(this.max);for(let t=0;t=0;if(0===n)return 0;n!==e.length&&(i=!1)}if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let o=0;othis.max[e]-this.min[e])return 0}return 1}}function Ql(t,e,i,r,o,n,s,a,l){if(n&&t.queryGeometry.isAboveHorizon)return!1;n&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(a),p=o&&i.elevation?i.elevation.exaggeration()*o.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const t=i.projection.upVector(c,h.x,h.y);d.x+=t[0]*u*p,d.y+=t[1]*u*p,d.z+=t[2]*u*p}const f=n?h:tc(d.x,d.y,d.z,r),m=n?t.tilespaceRays.map((t=>rc(t,p))):t.queryGeometry.screenGeometry,_=Zl([],[d.x,d.y,d.z,1],r);if(!s&&n?l*=_[3]/i.cameraToCenterDistance:s&&!n&&(l*=i.cameraToCenterDistance/_[3]),n){const t=Pa((e.y/wa+c.y)/(1<t.width||o.height>t.height||i.x>t.width-o.width||i.y>t.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||r.x>e.width-o.width||r.y>e.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,a=e.data;for(let l=0;l{e[t.evaluationKey]=n;const s=t.expression.evaluate(e);o.data[i+r+0]=Math.floor(255*s.r/s.a),o.data[i+r+1]=Math.floor(255*s.g/s.a),o.data[i+r+2]=Math.floor(255*s.b/s.a),o.data[i+r+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,o=0;e80*i){r=n=t[0],o=s=t[1];for(var f=i;fn&&(n=a),l>s&&(s=l);c=0!==(c=Math.max(n-r,s-o))?1/c:0}return vc(p,d,i,r,o,c),d}function yc(t,e,i,r,o){var n,s;if(o===Nc(t,e,i,r)>0)for(n=e;n=e;n-=r)s=Uc(n,t[n],t[n+1],s);return s&&Dc(s,s.next)&&(Vc(s),s=s.next),s}function xc(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Dc(r,r.next)&&0!==Pc(r.prev,r,r.next))r=r.next;else{if(Vc(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function vc(t,e,i,r,o,n,s){if(t){!s&&n&&function(t,e,i,r){var o=t;do{null===o.z&&(o.z=Ac(o.x,o.y,e,i,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,function(t){var e,i,r,o,n,s,a,l,c=1;do{for(i=t,t=null,n=null,s=0;i;){for(s++,r=i,a=0,e=0;e0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(o=i,i=i.nextZ,a--):(o=r,r=r.nextZ,l--),n?n.nextZ=o:t=o,o.prevZ=n,n=o;i=r}n.nextZ=null,c*=2}while(s>1)}(o)}(t,r,o,n);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?wc(t,r,o,n):bc(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),Vc(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?vc(t=Tc(xc(t),e,i),e,i,r,o,n,2):2===s&&Ec(t,e,i,r,o,n):vc(xc(t),e,i,r,o,n,1);break}}}function bc(t){var e=t.prev,i=t,r=t.next;if(Pc(e,i,r)>=0)return!1;for(var o=t.next.next;o!==t.prev;){if(zc(e.x,e.y,i.x,i.y,r.x,r.y,o.x,o.y)&&Pc(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function wc(t,e,i,r){var o=t.prev,n=t,s=t.next;if(Pc(o,n,s)>=0)return!1;for(var a=o.x>n.x?o.x>s.x?o.x:s.x:n.x>s.x?n.x:s.x,l=o.y>n.y?o.y>s.y?o.y:s.y:n.y>s.y?n.y:s.y,c=Ac(o.x=c&&p&&p.z<=u;){if(h!==t.prev&&h!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==t.prev&&p!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=c;){if(h!==t.prev&&h!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=u;){if(p!==t.prev&&p!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Tc(t,e,i){var r=t;do{var o=r.prev,n=r.next.next;!Dc(o,n)&&Lc(o,r,r.next,n)&&Fc(o,n)&&Fc(n,o)&&(e.push(o.i/i),e.push(r.i/i),e.push(n.i/i),Vc(r),Vc(r.next),r=t=n),r=r.next}while(r!==t);return xc(r)}function Ec(t,e,i,r,o,n){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&kc(s,a)){var l=Oc(s,a);return s=xc(s,s.next),l=xc(l,l.next),vc(s,e,i,r,o,n),void vc(l,e,i,r,o,n)}a=a.next}s=s.next}while(s!==t)}function Sc(t,e){return t.x-e.x}function Cc(t,e){var i=function(t,e){var i,r=e,o=t.x,n=t.y,s=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=o&&a>s){if(s=a,a===o){if(n===r.y)return r;if(n===r.next.y)return r.next}i=r.x=r.x&&r.x>=u&&o!==r.x&&zc(ni.x||r.x===i.x&&Mc(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Oc(i,t),o=xc(i,i.next);return xc(r,r.next),e===i?o:e}function Mc(t,e){return Pc(t.prev,t,e.prev)<0&&Pc(e.next,t,t.next)<0}function Ac(t,e,i,r,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*o)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*o)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ic(t){var e=t,i=t;do{(e.x=0&&(t-s)*(r-a)-(i-s)*(e-a)>=0&&(i-s)*(n-a)-(o-s)*(r-a)>=0}function kc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Lc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Fc(t,e)&&Fc(e,t)&&function(t,e){var i=t,r=!1,o=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&o<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Pc(t.prev,t,e.prev)||Pc(t,e.prev,e))||Dc(t,e)&&Pc(t.prev,t,t.next)>0&&Pc(e.prev,e,e.next)>0)}function Pc(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Dc(t,e){return t.x===e.x&&t.y===e.y}function Lc(t,e,i,r){var o=Rc(Pc(t,e,i)),n=Rc(Pc(t,e,r)),s=Rc(Pc(i,r,t)),a=Rc(Pc(i,r,e));return o!==n&&s!==a||!(0!==o||!Bc(t,i,e))||!(0!==n||!Bc(t,r,e))||!(0!==s||!Bc(i,t,r))||!(0!==a||!Bc(i,e,r))}function Bc(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Rc(t){return t>0?1:t<0?-1:0}function Fc(t,e){return Pc(t.prev,t,t.next)<0?Pc(t,e,t.next)>=0&&Pc(t,t.prev,e)>=0:Pc(t,e,t.prev)<0||Pc(t,t.next,e)<0}function Oc(t,e){var i=new jc(t.i,t.x,t.y),r=new jc(e.i,e.x,e.y),o=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=o,o.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Uc(t,e,i,r){var o=new jc(t,e,i);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Vc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function jc(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Nc(t,e,i,r){for(var o=0,n=e,s=i-r;ni;){if(r-i>600){var n=r-i+1,s=e-i+1,a=Math.log(n),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(n-l)/n)*(s-n/2<0?-1:1);Zc(t,e,Math.max(i,Math.floor(e-s*l/n+c)),Math.min(r,Math.floor(e+(n-s)*l/n+c)),o)}var u=t[e],h=i,p=r;for($c(t,i,e),o(t[r],u)>0&&$c(t,i,r);h0;)p--}0===o(t[i],u)?$c(t,i,p):$c(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function $c(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function qc(t,e){return te?1:0}function Xc(t,e){const i=t.length;if(i<=1)return[t];const r=[];let o,n;for(let e=0;e1)for(let t=0;t0&&i.holes.push(r+=t[o-1].length)}return i},mc.default=_c;class Kc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Qn,this.indexArray=new ms,this.indexArray2=new ws,this.programConfigurations=new ha(t.layers,t.zoom),this.segments=new ba,this.segments2=new ba,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,i,r){this.hasPattern=Hc("fill",this.layers,e);const o=this.layers[0].layout.get("fill-sort-key"),n=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Za(s,t);if(!this.layers[0]._featureFilter.filter(new Pn(this.zoom),u,i))continue;const h=o?o.evaluate(u,{},i,e.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?u.geometry:Ga(s,i,r),patterns:{},sortKey:h};n.push(p)}o&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:o,index:n,sourceLayerIndex:s}=r;if(this.hasPattern){const t=Yc("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,o,n,i,{},e.availableImages);e.featureIndex.insert(t[n].feature,o,n,s,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,o,n=[]){for(const t of Xc(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,o=[],n=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&n.push(o.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),o.push(e[0].x),o.push(e[0].y);for(let t=1;t>3}if(o--,1===r||2===r)s+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new n(s,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},nu.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,o=0,n=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(r--,1===i||2===i)(o+=t.readSVarint())a&&(a=o),(n+=t.readSVarint())c&&(c=n);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},nu.prototype.toGeoJSON=function(t,e,i){var r,o,n=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=nu.types[this.type];function u(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}function hu(t,e,i){if(3===t){var r=new lu(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}cu.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new ou(this._pbf,e,this.extent,this._keys,this._values)};var pu={VectorTile:function(t,e){this.layers=t.readFields(hu,{},e)},VectorTileFeature:ou,VectorTileLayer:lu};function du(t,e,i,r){const o=[],s=0===r?(t,e,i,r,o,s)=>{t.push(new n(s,i+(s-e)/(r-e)*(o-i)))}:(t,e,i,r,o,s)=>{t.push(new n(e+(s-i)/(o-i)*(r-e),s))};for(const n of t){const t=[];for(const o of n){if(o.length<=2)continue;const n=[];for(let t=0;te&&s(n,a,l,c,u,e):h>i?p=e&&s(n,a,l,c,u,e),p>i&&h<=i&&s(n,a,l,c,u,i)}let a=o[o.length-1];const l=0===r?a.x:a.y;l>=e&&l<=i&&n.push(a),n.length&&(a=n[n.length-1],n[0].x===a.x&&n[0].y===a.y||n.push(n[0]),t.push(n))}t.length&&o.push(t)}return o}const fu=pu.VectorTileFeature.types,mu=Math.pow(2,13);function _u(t,e,i,r,o,n,s,a){t.emplaceBack((e<<1)+s,(i<<1)+n,(Math.floor(r*mu)<<1)+o,Math.round(a))}function gu(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class yu{constructor(){this.acc=new n(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new n(t.x,t.y),this.max=new n(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const i=this.min,r=this.max;t.xr.x&&(r.x=t.x),t.yr.y&&(r.y=t.y),((0===t.x||t.x===wa)&&t.x===e.x)!=((0===t.y||t.y===wa)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,yi(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>wa!=t.x>wa&&this.addBorderIntersection(1,yi(e.y,t.y,(wa-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,yi(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>wa!=t.y>wa&&this.addBorderIntersection(3,yi(e.x,t.x,(wa-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new n(0,0)}span(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class xu{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new es,this.centroidVertexArray=new Os,this.indexArray=new ms,this.programConfigurations=new ha(t.layers,t.zoom),this.segments=new ba,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i,r){this.features=[],this.hasPattern=Hc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<=0;t--){const e=p[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=wa))||d.every((t=>t.y<=0))||d.every((t=>t.y>=wa)))&&p.splice(t,1)}var d;let f;if(u)f=wu(p,l,r);else{f=[];for(const t of p)f.push({polygon:t,bounds:l})}for(const e of f){const i=e.polygon;let o=0,n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let t=0;t=1){const o=s[t-1];if(!vu(i,o,e.bounds)){h&&h.append(i,o),n.vertexLength+4>ba.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(o)._perp(),e=t.x/(Math.abs(t.x)+Math.abs(t.y)),s=t.y>0?1:0,l=o.dist(i);a+l>32768&&(a=0),_u(this.layoutVertexArray,i.x,i.y,e,s,0,0,a),_u(this.layoutVertexArray,i.x,i.y,e,s,0,1,a),a+=l,_u(this.layoutVertexArray,o.x,o.y,e,s,0,0,a),_u(this.layoutVertexArray,o.x,o.y,e,s,0,1,a);const p=n.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),n.vertexLength+=4,n.primitiveLength+=2,u){const t=this.layoutVertexExtArray,e=c.projectTilePoint(i.x,i.y,r),n=c.projectTilePoint(o.x,o.y,r),s=c.upVector(r,i.x,i.y),a=c.upVector(r,o.x,o.y);gu(t,e,s),gu(t,e,s),gu(t,n,a),gu(t,n,a)}}}}}if(n.vertexLength+o>ba.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(o,this.layoutVertexArray,this.indexArray)),"Polygon"!==fu[t.type])continue;const s=[],a=[],l=n.vertexLength;for(let t=0;t0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const t=h.borders,e=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,o,s,r)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let r,o;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),o=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),o=0;else r=0,o=+i;let n=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(n++,0,o),this.centroidVertexArray.emplace(n++,r,o);for(let e=0;ei[1].x)||t.y===e.y&&(t.yi[1].y)}function bu(){const t=Math.PI/32,e=Math.tan(t),i=Ea;return i*Math.sqrt(1+2*e*e)-i}function wu(t,e,i){const r=1<{for(const i of t)a.push({polygon:i,bounds:e})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(r)),h=c-u,p=[];for(let t=0;t0?0:1);for(let t=0;te+1?f.push({polygons:d,bounds:t,depth:e+1}):l(d,t)}if(m.length){const t=[new n(0===i?h:r.x,1===i?h:r.y),a];p.length>e+1?f.push({polygons:m,bounds:t,depth:e+1}):l(m,t)}}return a}(t,e,Math.ceil((s-o)/11.25),Math.ceil((a-l)/11.25),1,((t,e,o)=>{if(0===t)return.5*(e+o);{const t=Pa((i.y+e/wa)/r);return(Ia(.5*(Pa((i.y+o/wa)/r)+t))*r-i.y)*wa}}))}Po(xu,"FillExtrusionBucket",{omit:["layers","features"]}),Po(yu,"PartMetadata");var Tu={paint:new qn({"fill-extrusion-opacity":new jn($t["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Nn($t["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new jn($t["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new jn($t["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Gn($t["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Nn($t["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Nn($t["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new jn($t["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Eu(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Su{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=Au(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=function(t,e,i){var r=Eu(256*t,256*(e=Math.pow(2,i)-e-1),i),o=Eu(256*(t+1),256*(e+1),i);return r[0]+","+r[1]+","+o[0]+","+o[1]}(this.x,this.y,this.z),r=function(t,e,i){let r,o="";for(let n=t;n>0;n--)r=1<this.canonical.z?new Mu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Mu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Au(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Au(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Mu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Mu(e,this.wrap,e,i,r),new Mu(e,this.wrap,e,i+1,r),new Mu(e,this.wrap,e,i,r+1),new Mu(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.yt.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new is,this.layoutVertexArray2=new rs,this.indexArray=new ms,this.programConfigurations=new ha(t.layers,t.zoom),this.segments=new ba,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){this.hasPattern=Hc("line",this.layers,e);const o=this.layers[0].layout.get("line-sort-key"),n=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Za(e,t);if(!this.layers[0]._featureFilter.filter(new Pn(this.zoom),c,i))continue;const u=o?o.evaluate(c,{},i):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Ga(e,i,r),patterns:{},sortKey:u};n.push(h)}o&&n.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:s,featureIndex:a}=e,l=this.addConstantDashes(s);for(const r of n){const{geometry:o,index:n,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const t=Yc("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,o,n,i,s.positions,e.availableImages);a.insert(t[n].feature,o,n,c,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,o=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==o.kind)e=!0;else{const e=o.value,i=r.value;if(!i)continue;t.addDash(i.from,e),t.addDash(i.to,e),i.other&&t.addDash(i.other,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const r of this.layers){const o=r.paint.get("line-dasharray").value,n=r.layout.get("line-cap").value;if("constant"===o.kind&&"constant"===n.kind)continue;let s,a,l,c,u,h;if("constant"===o.kind){const t=o.value;if(!t)continue;s=t.other||t.to,a=t.to,l=t.from}else s=o.evaluate({zoom:i-1},t),a=o.evaluate({zoom:i},t),l=o.evaluate({zoom:i+1},t);"constant"===n.kind?c=u=h=n.value:(c=n.evaluate({zoom:i-1},t),u=n.evaluate({zoom:i},t),h=n.evaluate({zoom:i+1},t)),e.addDash(s,c),e.addDash(a,u),e.addDash(l,h);const p=e.getKey(s,c),d=e.getKey(a,u),f=e.getKey(l,h);t.patterns[r.id]={min:p,mid:d,max:f}}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ru)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Lu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,o,n){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap").evaluate(t,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,o,n,r)}addLine(t,e,i,r,o,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l0;if(b&&e>l){const t=h.dist(p);if(t>2*c){const e=h.sub(h.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,f,0,0,u),p=e}}const T=p&&d;let E=T?i:s?"butt":r;if(T&&"round"===E&&(xo&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x100)_=m.mult(-1);else{const t=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(h,_,0,0,u),this.addCurrentVertex(h,_.mult(-1),0,0,u)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(h,f,e,i,u),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e2*c){const e=h.add(d.sub(h)._mult(c/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,u),h=e}}}}addCurrentVertex(t,e,i,r,o,n=!1){const s=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,o),this.addHalfVertex(t,s,a,n,!0,-r,o)}addHalfVertex({x:t,y:e},i,r,o,n,s,a){this.layoutVertexArray.emplaceBack((t<<1)+(o?1:0),(e<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),n?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Po(Uu,"LineBucket",{omit:["layers","patternFeatures"]});const Vu=new qn({"line-cap":new Nn($t.layout_line["line-cap"]),"line-join":new Nn($t.layout_line["line-join"]),"line-miter-limit":new jn($t.layout_line["line-miter-limit"]),"line-round-limit":new jn($t.layout_line["line-round-limit"]),"line-sort-key":new Nn($t.layout_line["line-sort-key"])});var ju={paint:new qn({"line-opacity":new Nn($t.paint_line["line-opacity"]),"line-color":new Nn($t.paint_line["line-color"]),"line-translate":new jn($t.paint_line["line-translate"]),"line-translate-anchor":new jn($t.paint_line["line-translate-anchor"]),"line-width":new Nn($t.paint_line["line-width"]),"line-gap-width":new Nn($t.paint_line["line-gap-width"]),"line-offset":new Nn($t.paint_line["line-offset"]),"line-blur":new Nn($t.paint_line["line-blur"]),"line-dasharray":new Gn($t.paint_line["line-dasharray"]),"line-pattern":new Gn($t.paint_line["line-pattern"]),"line-gradient":new $n($t.paint_line["line-gradient"]),"line-trim-offset":new jn($t.paint_line["line-trim-offset"])}),layout:Vu};const Nu=new class extends Nn{possiblyEvaluate(t,e){return e=new Pn(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=v({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(ju.paint.properties["line-width"].specification);function Gu(t,e){return e>0?e+2*t:t}Nu.useIntegerZoom=!0;const Zu=Kn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),$u=Kn([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),qu=Kn([{name:"a_projected_pos",components:4,type:"Float32"}],4);Kn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Xu=Kn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Wu=Kn([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Kn([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Hu=Kn([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Yu=Kn([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Kn([{name:"triangle",components:3,type:"Uint16"}]),Kn([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Kn([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Kn([{type:"Float32",name:"offsetX"}]),Kn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Ku=24;const Ju=128;function Qu(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Pn(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let o=0;for(;o{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),kn.applyArabicShaping&&(t=kn.applyArabicShaping(t)),t}(t.text,e,i)})),t}const oh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function nh(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function sh(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var ah=function(t,e,i,r,o){var n,s,a=8*o-r-1,l=(1<>1,u=-7,h=i?o-1:0,p=i?-1:1,d=t[e+h];for(h+=p,n=d&(1<<-u)-1,d>>=-u,u+=a;u>0;n=256*n+t[e+h],h+=p,u-=8);for(s=n&(1<<-u)-1,n>>=-u,u+=r;u>0;s=256*s+t[e+h],h+=p,u-=8);if(0===n)n=1-c;else{if(n===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),n-=c}return(d?-1:1)*s*Math.pow(2,n-r)},lh=function(t,e,i,r,o,n){var s,a,l,c=8*n-o-1,u=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:n-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*l-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[i+d]=255&a,d+=f,a/=256,o-=8);for(s=s<0;t[i+d]=255&s,d+=f,s/=256,c-=8);t[i+d-f]|=128*m},ch=uh;function uh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}uh.Varint=0,uh.Fixed64=1,uh.Bytes=2,uh.Fixed32=5;var hh=4294967296,ph=1/hh,dh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function fh(t){return t.type===uh.Bytes?t.readVarint()+t.pos:t.pos+1}function mh(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function _h(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var o=i.pos-1;o>=t;o--)i.buf[o+r]=i.buf[o]}function gh(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Ah(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Ih(t,e,i){e.glyphs=[],1===t&&i.readMessage(zh,e)}function zh(t,e,i){if(3===t){const{id:t,bitmap:r,width:o,height:n,left:s,top:a,advance:l}=i.readMessage(kh,{});e.glyphs.push({id:t,bitmap:new lc({width:o+6,height:n+6},r),metrics:{width:o,height:n,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function kh(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Ph(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let o=0,n=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),o=Math.max(o,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t>3,n=this.pos;this.type=7&r,t(o,e,this),this.pos===n&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Ch(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Ah(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Ch(this.buf,this.pos)+Ch(this.buf,this.pos+4)*hh;return this.pos+=8,t},readSFixed64:function(){var t=Ch(this.buf,this.pos)+Ah(this.buf,this.pos+4)*hh;return this.pos+=8,t},readFloat:function(){var t=ah(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ah(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,o,n=i.buf;if(r=(112&(o=n[i.pos++]))>>4,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<3,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<10,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<17,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<24,o<128)return mh(t,r,e);if(r|=(1&(o=n[i.pos++]))<<31,o<128)return mh(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&dh?function(t,e,i){return dh.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",o=e;o239?4:l>223?3:l>191?2:1;if(o+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(n=t[o+1]))&&(c=(31&l)<<6|63&n)<=127&&(c=null):3===u?(s=t[o+2],128==(192&(n=t[o+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&n)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=t[o+2],a=t[o+3],128==(192&(n=t[o+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&n)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),o+=u}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==uh.Bytes)return t.push(this.readVarint(e));var i=fh(this);for(t=t||[];this.pos127;);else if(e===uh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===uh.Fixed32)this.pos+=4;else{if(e!==uh.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,o,n=0;n55295&&r<57344){if(!o){r>56319||n+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):o=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,o=r;continue}r=o-55296<<10|r-56320|65536,o=null}else o&&(t[i++]=239,t[i++]=191,t[i++]=189,o=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&_h(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),lh(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),lh(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&_h(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,uh.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,gh,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,yh,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,bh,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xh,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,vh,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,wh,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Th,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Eh,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Sh,e)},writeBytesField:function(t,e){this.writeTag(t,uh.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,uh.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,uh.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,uh.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,uh.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,uh.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,uh.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,uh.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,uh.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,uh.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class Dh{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:o,content:n}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=o,this.content=n,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Lh{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const o=[];this.addImages(t,i,o),this.addImages(e,r,o);const{w:n,h:s}=Ph(o),a=new cc({width:n||1,height:s||1});for(const e in t){const r=t[e],o=i[e].paddedRect;cc.copy(r.data,a,{x:0,y:0},{x:o.x+1,y:o.y+1},r.data)}for(const t in e){const i=e[t],o=r[t].paddedRect,n=o.x+1,s=o.y+1,l=i.data.width,c=i.data.height;cc.copy(i.data,a,{x:0,y:0},{x:n,y:s},i.data),cc.copy(i.data,a,{x:0,y:c-1},{x:n,y:s-1},{width:l,height:1}),cc.copy(i.data,a,{x:0,y:0},{x:n,y:s+c},{width:l,height:1}),cc.copy(i.data,a,{x:l-1,y:0},{x:n-1,y:s},{width:1,height:c}),cc.copy(i.data,a,{x:0,y:0},{x:n+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const o=t[r],n={x:0,y:0,w:o.data.width+2,h:o.data.height+2};i.push(n),e[r]=new Dh(n,o),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e))),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,o]=t.tl;i.update(e.data,void 0,{x:r,y:o})}}Po(Dh,"ImagePosition"),Po(Lh,"ImageAtlas");const Bh={horizontal:1,vertical:2,horizontalOnly:3};class Rh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Rh;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Rh;return e.imageName=t,e}}class Fh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Fh;for(let r=0;r=0&&i>=t&&Uh[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Fh;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Rh.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Oh(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m){const _=Fh.fromFeature(t,o);let g;h===Bh.vertical&&_.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:x}=kn;if(y&&1===_.sections.length){g=[];const t=y(_.toString(),qh(_,c,n,e,r,d,f));for(const e of t){const t=new Fh;t.text=e,t.sections=_.sections;for(let i=0;i0&&n>b&&(b=n)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(E=t[m]);const r=e[a.fontStack];if(!r)continue;const n=r.glyphs[m];if(!n)continue;if(x=n.metrics,C=8203!==m?Ku:0,_){const t=void 0!==r.ascender?Math.abs(r.ascender):0,e=void 0!==r.descender?Math.abs(r.descender):0,i=(t+e)*g;w=0;let u=0;for(let i=0;i-i/2;){if(s--,s<0)return!1;a-=t[s].dist(n),n=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>o)return!1;s++,a+=e.dist(i)}return!0}function Qh(t){let e=0;for(let i=0;ic){const u=(c-l)/n,h=yi(r.x,o.x,u),p=yi(r.y,o.y,u),d=new Kh(h,p,0,o.angleTo(r),i);return!s||Jh(t,d,a,s,e)?d:void 0}l+=n}}function rp(t,e,i,r,o,n,s,a,l){const c=tp(r,n,s),u=ep(r,o),h=u*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&y=0&&p+c<=u){const i=new Kh(g,y,0,m,e);i._round(),r&&!Jh(t,i,n,r,o)||d.push(i)}}h+=f}return a||d.length||s||(d=op(t,h/2,i,r,o,n,s,!0,l)),d}function np(t,e,i,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new n(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new n(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}Po(Kh,"Anchor");const sp=1e20;function ap(t,e,i,r,o,n,s,a,l){for(let c=e;c-1);l++,n[l]=a,s[l]=c,s[l+1]=sp}for(let a=0,l=0;a{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=r.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(r,t,e),o)return r.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const n=Math.floor(e/256);if(256*n>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[n])return void i(null,{stack:t,id:e,glyph:o});let s=r.requests[n];s||(s=r.requests[n]=[],up.loadGlyphRange(t,n,this.url,this.requestManager,((t,e)=>{if(e){r.ascender=e.ascender,r.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e.glyphs[+t]);r.ranges[n]=!0}for(const i of s)i(t,e);delete r.requests[n]}))),s.push(((r,o)=>{r?i(r):o&&i(null,{stack:t,id:e,glyph:o.glyphs[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:o}of i)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[r]=o&&{id:o.id,bitmap:o.bitmap.clone(),metrics:o.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==cp.none&&(this.localGlyphMode===cp.all?!!this.localFontFamily:!!this.localFontFamily&&(tn(t)||on(t)||$o(t)||qo(t)||Zo(t)))}_tinySDF(t,e,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let o=t.tinySDF;if(!o){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),o=t.tinySDF=new up.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),o.fontWeight=i}if(this.localGlyphs[o.fontWeight][i])return this.localGlyphs[o.fontWeight][i];const n=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=o.draw(n);return this.localGlyphs[o.fontWeight][i]={id:i,bitmap:new lc({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function hp(t,e,i,r){const o=[],s=t.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,u=t.right-t.left,h=t.bottom-t.top,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],f=(t,e)=>t+e[1]-e[0],m=p.reduce(f,0),_=d.reduce(f,0),g=l-m,y=c-_;let x=0,v=m,b=0,w=_,T=0,E=g,S=0,C=y;if(s.content&&r){const t=s.content;x=pp(p,0,t[0]),b=pp(d,0,t[1]),v=pp(p,t[0],t[2]),w=pp(d,t[1],t[3]),T=t[0]-x,S=t[1]-b,E=t[2]-t[0]-v,C=t[3]-t[1]-w}const M=(r,o,l,c)=>{const p=fp(r.stretch-x,v,u,t.left),d=mp(r.fixed-T,E,r.stretch,m),f=fp(o.stretch-b,w,h,t.top),g=mp(o.fixed-S,C,o.stretch,_),y=fp(l.stretch-x,v,u,t.left),M=mp(l.fixed-T,E,l.stretch,m),A=fp(c.stretch-b,w,h,t.top),I=mp(c.fixed-S,C,c.stretch,_),z=new n(p,f),k=new n(y,f),P=new n(y,A),D=new n(p,A),L=new n(d/a,g/a),B=new n(M/a,I/a),R=e*Math.PI/180;if(R){const t=Math.sin(R),e=Math.cos(R),i=[e,-t,t,e];z._matMult(i),k._matMult(i),D._matMult(i),P._matMult(i)}const F=r.stretch+r.fixed,O=o.stretch+o.fixed;return{tl:z,tr:k,bl:D,br:P,tex:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+O,w:l.stretch+l.fixed-F,h:c.stretch+c.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:B,minFontScaleX:E/a/u,minFontScaleY:C/a/h,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const t=dp(p,g,m),e=dp(d,y,_);for(let i=0;i{if(t)o(t);else if(e){const t={},i=function(t){return new ch(t).readFields(Ih,{})}(e);for(const e of i.glyphs)t[e.id]=e;o(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},up.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:n="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${n} ${t}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:n}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.min(this.size-this.buffer,Math.ceil(n-o)),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(sp,0,h),_.fill(0,0,h);for(let t=0;t0?t*t:0,_[r]=t<0?t*t:0}}ap(g,0,0,c,u,c,this.f,this.v,this.z),ap(_,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const o=t-1>>1,n=e[o];if(i(r,n)>=0)break;e[t]=n,t=o}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,o=e[t];for(;t=0)break;e[t]=n,t=r}e[t]=o}}function yp(t,e){return te?1:0}function xp(t,e=1,i=!1){let r=1/0,o=1/0,s=-1/0,a=-1/0;const l=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y)}const c=Math.min(s-r,a-o);let u=c/2;const h=new gp([],vp);if(0===c)return new n(r,o);for(let e=r;ep.d||!p.d)&&(p=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-p.d<=e||(u=r.h/2,h.push(new bp(r.p.x-u,r.p.y-u,u,t)),h.push(new bp(r.p.x+u,r.p.y-u,u,t)),h.push(new bp(r.p.x-u,r.p.y+u,u,t)),h.push(new bp(r.p.x+u,r.p.y+u,u,t)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function vp(t,e){return e.max-t.max}function bp(t,e,i,r){this.p=new n(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let o=0;ot.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(i=!i),r=Math.min(r,el(t,o,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const wp=Number.POSITIVE_INFINITY,Tp=Math.sqrt(2);function Ep(t,e){return e[1]!==wp?function(t,e,i){let r=0,o=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":o=i-7;break;case"bottom-right":case"bottom-left":case"bottom":o=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,o]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const o=e/Tp;switch(t){case"top-right":case"top-left":r=o-7;break;case"bottom-right":case"bottom-left":r=7-o;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-o;break;case"top-left":case"bottom-left":i=o;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Sp(t,e,i,r,o,n,s,a,l,c){t.createArrays(),t.tilePixelRatio=wa/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Pn(e),a),h["text-size"].possiblyEvaluate(new Pn(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Pn(e),a),h["icon-size"].possiblyEvaluate(new Pn(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Pn(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Pn(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Pn(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const n of t.features){const l=u.get("text-font").evaluate(n,{},a).join(","),h=f.evaluate(n,{},a),m=p.layoutTextSize.evaluate(n,{},a),_=(p.layoutIconSize.evaluate(n,{},a),{horizontal:{},vertical:void 0}),g=n.text;let y,x=[0,0];if(g){const r=g.toString(),s=u.get("text-letter-spacing").evaluate(n,{},a)*Ku,c=u.get("text-line-height").evaluate(n,{},a)*Ku,p=dn(r)?s:0,f=u.get("text-anchor").evaluate(n,{},a),y=u.get("text-variable-anchor");if(!y){const t=u.get("text-radial-offset").evaluate(n,{},a);x=t?Ep(f,[t*Ku,wp]):u.get("text-offset").evaluate(n,{},a).map((t=>t*Ku))}let v=d?"center":u.get("text-justify").evaluate(n,{},a);const b=u.get("symbol-placement"),w="point"===b,T="point"===b?u.get("text-max-width").evaluate(n,{},a)*Ku:0,E=n=>{t.allowVerticalPlacement&&pn(r)&&(_.vertical=Oh(g,e,i,o,l,T,c,f,n,p,x,Bh.vertical,!0,b,m,h))};if(!d&&y){const t="auto"===v?y.map((t=>Cp(t))):[v];let r=!1;for(let n=0;n=0||!pn(r)){const t=Oh(g,e,i,o,l,T,c,f,v,p,x,Bh.horizontal,!1,b,m,h);t&&(_.horizontal[v]=t)}E("point"===b?"left":v)}}let v=!1;if(n.icon&&n.icon.name){const e=r[n.icon.name];e&&(y=Hh(o[n.icon.name],u.get("icon-offset").evaluate(n,{},a),u.get("icon-anchor").evaluate(n,{},a)),v=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&P("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const b=zp(_.horizontal)||_.vertical;t.iconsInText||(t.iconsInText=!!b&&b.iconsInText),(b||y)&&Mp(t,n,_,y,r,p,m,0,x,v,s,a,c)}n&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function Cp(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Mp(t,e,i,r,o,n,s,a,l,u,h,p,d){let f=n.textMaxSize.evaluate(e,{},p);void 0===f&&(f=s);const m=t.layers[0].layout,_=m.get("icon-offset").evaluate(e,{},p),g=zp(i.horizontal)||i.vertical,y="globe"===d.name,x=s/24,v=t.tilePixelRatio*f/24,b=(I=t.overscaling,t.zoom>18&&I>2&&(I>>=1),Math.max(wa/(512*I),1)*m.get("symbol-spacing")),w=m.get("text-padding")*t.tilePixelRatio,T=m.get("icon-padding")*t.tilePixelRatio,E=c(m.get("text-max-angle")),S="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),C="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),M=m.get("symbol-placement"),A=b/2;var I;const z=m.get("icon-text-fit");let k;r&&"none"!==z&&(t.allowVerticalPlacement&&i.vertical&&(k=Yh(r,i.vertical,z,m.get("icon-text-fit-padding"),_,x)),g&&(r=Yh(r,g,z,m.get("icon-text-fit-padding"),_,x)));const D=(s,a,c)=>{if(a.x<0||a.x>=wa||a.y<0||a.y>=wa)return;let f=null;if(y){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,c);f={anchor:new Kh(t,e,i,0,void 0),up:d.upVector(c,a.x,a.y)}}!function(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E){const S=t.addToLineVertexArray(e,r);let C,M,A,I,z,k,D,L=0,B=0,R=0,F=0,O=-1,U=-1;const V={};let j=$s("");const N=i?i.anchor:e;let G=0,Z=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=l.layout.get("text-offset").evaluate(v,{},E).map((t=>t*Ku)):(G=l.layout.get("text-radial-offset").evaluate(v,{},E)*Ku,Z=wp),t.allowVerticalPlacement&&o.vertical){const t=o.vertical;if(f)k=Pp(t),a&&(D=Pp(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},E)+90;A=kp(c,N,e,u,h,p,t,d,i,m),a&&(I=kp(c,N,e,u,h,p,a,g,i))}}if(n){const r=l.layout.get("icon-rotate").evaluate(v,{},E),o="none"!==l.layout.get("icon-text-fit"),s=hp(n,r,w,o),d=a?hp(a,r,w,o):void 0;M=kp(c,N,e,u,h,p,n,g,r),L=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Ju*l.layout.get("icon-size").evaluate(v,{},E)],m[0]>Ap&&P(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Ju*b.compositeIconSizes[0].evaluate(v,{},E),Ju*b.compositeIconSizes[1].evaluate(v,{},E)],(m[0]>Ap||m[1]>Ap)&&P(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,x,y,v,!1,i,e,S.lineStartIndex,S.lineLength,-1,T,E),O=t.icon.placedSymbolArray.length-1,d&&(B=4*d.length,t.addSymbols(t.icon,d,m,x,y,v,Bh.vertical,i,e,S.lineStartIndex,S.lineLength,-1,T,E),U=t.icon.placedSymbolArray.length-1)}for(const r in o.horizontal){const n=o.horizontal[r];C||(j=$s(n.text),f?z=Pp(n):C=kp(c,N,e,u,h,p,n,d,l.layout.get("text-rotate").evaluate(v,{},E),m));const a=1===n.positionedLines.length;if(R+=Ip(t,i,e,n,s,l,f,v,m,S,o.vertical?Bh.horizontal:Bh.horizontalOnly,a?Object.keys(o.horizontal):[r],V,O,b,T,E),a)break}o.vertical&&(F+=Ip(t,i,e,o.vertical,s,l,f,v,m,S,Bh.vertical,["vertical"],V,U,b,T,E));let $=-1;const q=(t,e)=>t?Math.max(t,e):e;$=q(z,$),$=q(k,$),$=q(D,$);const X=$>-1?1:0;t.glyphOffsetArray.length>=Ud.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(N.x,N.y,N.z,e.x,e.y,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,O,U,j,void 0!==C?C:t.collisionBoxArray.length,void 0!==C?C+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,I||t.collisionBoxArray.length,I?I+1:t.collisionBoxArray.length,u,R,F,L,B,X,0,G,Z,$)}(t,a,f,s,i,r,o,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,w,S,l,0,T,C,_,e,n,u,h,p)};if("line"===M)for(const o of np(e.geometry,0,0,wa,wa)){const e=rp(o,b,E,i.vertical||g,r,24,v,t.overscaling,wa);for(const i of e){const e=g;e&&Dp(t,e.text,A,i)||D(o,i,p)}}else if("line-center"===M){for(const t of e.geometry)if(t.length>1){const e=ip(t,E,i.vertical||g,r,24,v);e&&D(t,e,p)}}else if("Polygon"===e.type)for(const t of Xc(e.geometry,0)){const e=xp(t,16);D(t[0],new Kh(e.x,e.y,0,0,void 0),p)}else if("LineString"===e.type)for(const t of e.geometry)D(t,new Kh(t[0].x,t[0].y,0,0,void 0),p);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)D([e],new Kh(e.x,e.y,0,0,void 0),p)}const Ap=32640;function Ip(t,e,i,r,o,s,a,l,c,u,h,p,d,f,m,_,g){const y=function(t,e,i,r,o,s,a,l){const c=[];if(0===e.positionedLines.length)return c;const u=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],r=e*i;return r>0?[e,-i]:r<0?[-e,i]:0===e?[i,e]:[i,-e]}(i);let p=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)p-=t.lineOffset;const d=e.positionedLines.length,f=p/d;let m=e.top-i[1];for(let t=0;tAp&&P(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===x.kind&&(v=[Ju*m.compositeTextSizes[0].evaluate(l,{},g),Ju*m.compositeTextSizes[1].evaluate(l,{},g)],(v[0]>Ap||v[1]>Ap)&&P(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,y,v,c,a,l,h,e,i,u.lineStartIndex,u.lineLength,f,_,g);for(const e of p)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function zp(t){for(const e in t)return t[e];return null}function kp(t,e,i,r,o,s,a,l,u,h){let p=a.top,d=a.bottom,f=a.left,m=a.right;const _=a.collisionPadding;if(_&&(f-=_[0],p-=_[1],m+=_[2],d+=_[3]),u){const t=new n(f,p),e=new n(m,p),i=new n(f,d),r=new n(m,d),o=c(u);let s=new n(0,0);h&&(s=new n(h[0],h[1])),t._rotateAround(o,s),e._rotateAround(o,s),i._rotateAround(o,s),r._rotateAround(o,s),f=Math.min(t.x,e.x,i.x,r.x),m=Math.max(t.x,e.x,i.x,r.x),p=Math.min(t.y,e.y,i.y,r.y),d=Math.max(t.y,e.y,i.y,r.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,f,p,m,d,l,r,o,s),t.length-1}function Pp(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Dp(t,e,i,r){const o=t.compareText;if(e in o){const t=o[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])1?null:function(t,e,i,r){const o=Math.sin(i);return t*(Math.sin((1-r)*i)/o)+e*(Math.sin(r*i)/o)}(t.a[e],t.b[e],t.angle,m(i,0,1))+t.center[e]}function Xp(t){if(t.z<=1)return Gp[t.z+2*t.y+t.x];const[e,i]=Hp(t),r=[Kp(e[0],e[1]),Kp(e[0],i[1]),Kp(i[0],e[1]),Kp(i[0],i[1])],o=[Np,Np,Np],n=[jp,jp,jp];for(const t of r)o[0]=Math.min(o[0],t[0]),o[1]=Math.min(o[1],t[1]),o[2]=Math.min(o[2],t[2]),n[0]=Math.max(n[0],t[0]),n[1]=Math.max(n[1],t[1]),n[2]=Math.max(n[2],t[2]);return new Jl(o,n)}function Wp(t,e,i){const r=e/t.worldSize,o=Number.MAX_VALUE,n=[-o,-o,-o],s=[o,o,o],a=ml(new Float64Array(16));if(yl(a,a,[r,r,r]),_l(a,a,t.globeMatrix),i.z<=1){const t=Xp(i).getCorners();for(let e=0;e.5?T-=1:T<-.5&&(T+=1),Math.abs(T)>Math.abs(E))w=T>=0?1:3,b=d;else{w=E>=0?0:2;const t=[a[4],a[5],a[6]];let e;e=E>=0?-Math.sin(c(h.getSouth()))*Op:-Math.sin(c(h.getNorth()))*Op,b=Dl(b,d,t,e)}const S=p[w],C=p[(w+1)%4],M=new $p(S,C,b),A=[qp(M,0)||S[0],qp(M,1)||S[1],qp(M,2)||S[2]];return s[2]=Math.min(S[2],C[2]),zl(s,s,A),kl(n,n,A),new Jl(s,n)}function Hp(t){const e=1<x&&(v(t,c,r,o,a,l),v(c,i,a,l,n,s))}v(h,p,r,n,o,n),v(p,d,o,n,o,s),v(d,f,o,s,r,s),v(f,h,r,s,r,n),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}const ud=ml(new Float32Array(16));class hd{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new Sa(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return za(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return ld(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,r){const o=t.horizonLineFromTop(!1),s=new n(e,Math.max(o,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,r))}pointCoordinate3D(t,e,i){const r=new n(e,i);if(t.elevation)return t.elevation.pointCoordinate(r);{const e=this.pointCoordinate(t,r.x,r.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?e<-vd+i&&(e=-vd+i):e>vd-i&&(e=vd-i);const n=o/Math.pow(bd(e),r),s=n*Math.sin(r*t),a=o-n*Math.cos(r*t);return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:r}=this,o=r-e,n=Math.sign(o),s=Math.sign(i)*Math.sqrt(t*t+o*o);let a=Math.atan2(t,Math.abs(o))*n;o*i<0&&(a-=Math.PI*Math.sign(t)*n);const l=m(u(a/i)+this.center[0],-180,180),c=m(u(2*Math.atan(Math.pow(r/s,1/i))-vd),-85.051129,La);return new Sa(l,c)}}class Td extends hd{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:Aa(t),y:Ia(e),z:0}}unproject(t,e){const i=ka(t),r=Pa(e);return new Sa(i,r)}}const Ed=c(La);class Sd extends hd{project(t,e){const i=(e=c(e))*e,r=i*i;return{x:.5*((t=c(t))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=25,o=0,n=i*i;do{n=i*i;const t=n*n;o=(i*(1.007226+n*(.015085+t*(.028874*n-.044475-.005916*t)))-e)/(1.007226+n*(.045255+t*(.259866*n-.311325-.005916*11*t))),i=m(i-o,-Ed,Ed)}while(Math.abs(o)>1e-6&&--r>0);n=i*i;const s=m(u(t/(.8707+n*(n*(n*n*n*(.003971-.001529*n)-.013791)-.131979))),-180,180),a=u(i);return new Sa(s,a)}}const Cd=c(La);class Md extends hd{project(t,e){e=c(e),t=c(t);const i=Math.cos(e),r=2/Math.PI,o=Math.acos(i*Math.cos(t/2)),n=Math.sin(o)/o,s=.5*(t*r+2*i*Math.sin(t/2)/n)||0,a=.5*(e+Math.sin(e)/n)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,r=e=(2*(1-e)-1)*Math.PI,o=25;const n=1e-6;let s=0,a=0;do{const o=Math.cos(r),n=Math.sin(r),l=2*n*o,c=n*n,u=o*o,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,f=p*p,_=1-u*h*h,g=_?1/_:0,y=_?Math.acos(o*h)*Math.sqrt(1/_):0,x=.5*(2*y*o*p+2*i/Math.PI)-t,v=.5*(y*n+r)-e,b=.5*g*(u*f+y*o*h*c)+1/Math.PI,w=g*(d*l/4-y*n*p),T=.125*g*(l*p-y*n*u*d),E=.5*g*(c*h+y*f*o)+.5,S=w*T-E*b;s=(v*w-x*E)/S,a=(x*T-v*b)/S,i=m(i-s,-Math.PI,Math.PI),r=m(r-a,-Cd,Cd)}while((Math.abs(s)>n||Math.abs(a)>n)&&--o>0);return new Sa(u(i),u(r))}}class Ad extends hd{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(c(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:r}=this;return{x:c(t)*r*i+.5,y:-Math.sin(c(e))/r*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:r}=this,o=-(e-.5)/i,n=m(u((t-.5)/i)/r,-180,180),s=Math.asin(m(o*r,-1,1)),a=m(u(s),-85.051129,La);return new Sa(n,a)}}class Id extends Td{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(t,e,i){const r=Math.pow(2,i.z),o=(t/wa+i.x)/r,n=Kp(Pa((e/wa+i.y)/r),ka(o));return Fl(n,n,td(Xp(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Kp(e.lat,e.lng),r=Ll([],i),o=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Dl(i,i,r,za(1,0)*wa*o);const s=ml(new Float64Array(16));return _l(s,t.pixelMatrix,t.globeMatrix),Fl(i,i,s),new n(i[0],i[1])}pixelsPerMeter(t,e){return za(1,0)*e}pixelSpaceConversion(t,e,i){const r=yi(za(1,45)*e,za(1,t)*e,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const r=ed(Xp(i.canonical));return _l(new Float64Array(16),t.globeMatrix,r)}createInversionMatrix(t,e){const{center:i}=t,r=ml(new Float64Array(16));return _l(r,r,td(Xp(e))),vl(r,r,c(i.lng)),xl(r,r,c(i.lat)),yl(r,r,[t._projectionScaler,t._projectionScaler,1]),Float32Array.from(r)}pointCoordinate(t,e,i,r){return Zp(t,e,i,!0)||new Ba(0,0)}pointCoordinate3D(t,e,i){const r=this.pointCoordinate(t,e,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(t,e){return!Zp(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,r=t._centerAltitude*e,o=t._camera,n=t._camera.forward(),s=Ml([],Pl([],n,-i),[0,0,r]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,u=Math.tan(t.fovAboveCenter),h=Pl([],o.up(),u),p=Pl([],o.right(),u*c),d=Ll([],Ml([],Ml([],n,h),p)),f=[];let m;if(new Hl(s,d).closestPointOnSphere(l,a,f)){const e=Ml([],f,l),i=Vl([],e,s);m=Math.cos(t.fovAboveCenter)*Sl(i)}else{const t=Vl([],s,l),e=Vl([],l,s);Ll(e,e);const i=Sl(t)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(Bl(n,e));m*=Math.cos(r)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=rd(t.zoom);if(i>0){const r=ld(t,za(1,t.center.lat)*t.worldSize),o=t.worldSize/(2*Math.PI),n=Math.max(t.width,t.height)/t.worldSize*Math.PI;return yi(e,r+o*(1-Math.cos(n)),Math.pow(i,10))}return e}upVector(t,e,i){const r=1<0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,$u.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Po(Fd,"SymbolBuffers");class Od{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new ba,this.collisionVertexArray=new ds,this.collisionVertexArrayExt=new fs}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Xu.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Wu.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Po(Od,"CollisionBuffers");class Ud{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ml([]),this.placementViewportMatrix=ml([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Qu(this.zoom,e["text-size"]),this.iconSizeData=Qu(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),o=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Bh[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Fd(new ha(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Fd(new ha(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Ds,this.lineVertexArray=new Ls,this.symbolInstances=new Ps}calculateGlyphDependencies(t,e,i,r,o){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=n.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Pn(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=o._featureFilter.needGeometry,y=Za(e,t);if(!o._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=Ga(e,i,r)),s&&1!==e.type&&i.z<=5){const t=y.geometry,e=1<t),((t,i)=>Bl(Kp(Pa((t.y/wa+o)/e),ka((t.x/wa+r)/e),1),Kp(Pa((i.y/wa+o)/e),ka((i.x/wa+r)/e),1))=0;for(const i of x.sections)if(i.image)d[i.image.name]=!0;else{const r=pn(x.toString()),o=i.fontStack||t,n=f[o]=f[o]||{};this.calculateGlyphDependencies(i.text,n,e,this.allowVerticalPlacement,r)}}}"line"===n.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let o=0;function n(e){r.push(t[e]),o++}function s(t,e,o){const n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(o[0]),n}function a(t,i,o){const n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=o[0].concat(r[n].geometry[0]),n}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=zd(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length,r=t.segment;if(void 0!==r){let i=t.dist(e[r+1]),o=t.dist(e[r]);const n={};for(let t=r+1;t=0;t--)n[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:o},t>0&&(o+=e[t-1].dist(e[t]));for(let t=0;t=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),n=th(this.textSizeData,t,o)/Ku;return this.tilePixelRatio*n}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),o=th(this.iconSizeData,t,r);return this.tilePixelRatio*o}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,o,n){for(let s=r;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;er[t]-r[e]||o[e]-o[t])),n}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Po(Ud,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Ud.MAX_GLYPHS=65535,Ud.addDynamicAttributes=Bd;const Vd=new qn({"symbol-placement":new jn($t.layout_symbol["symbol-placement"]),"symbol-spacing":new jn($t.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new jn($t.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Nn($t.layout_symbol["symbol-sort-key"]),"symbol-z-order":new jn($t.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new jn($t.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new jn($t.layout_symbol["icon-ignore-placement"]),"icon-optional":new jn($t.layout_symbol["icon-optional"]),"icon-rotation-alignment":new jn($t.layout_symbol["icon-rotation-alignment"]),"icon-size":new Nn($t.layout_symbol["icon-size"]),"icon-text-fit":new jn($t.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new jn($t.layout_symbol["icon-text-fit-padding"]),"icon-image":new Nn($t.layout_symbol["icon-image"]),"icon-rotate":new Nn($t.layout_symbol["icon-rotate"]),"icon-padding":new jn($t.layout_symbol["icon-padding"]),"icon-keep-upright":new jn($t.layout_symbol["icon-keep-upright"]),"icon-offset":new Nn($t.layout_symbol["icon-offset"]),"icon-anchor":new Nn($t.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new jn($t.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new jn($t.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new jn($t.layout_symbol["text-rotation-alignment"]),"text-field":new Nn($t.layout_symbol["text-field"]),"text-font":new Nn($t.layout_symbol["text-font"]),"text-size":new Nn($t.layout_symbol["text-size"]),"text-max-width":new Nn($t.layout_symbol["text-max-width"]),"text-line-height":new Nn($t.layout_symbol["text-line-height"]),"text-letter-spacing":new Nn($t.layout_symbol["text-letter-spacing"]),"text-justify":new Nn($t.layout_symbol["text-justify"]),"text-radial-offset":new Nn($t.layout_symbol["text-radial-offset"]),"text-variable-anchor":new jn($t.layout_symbol["text-variable-anchor"]),"text-anchor":new Nn($t.layout_symbol["text-anchor"]),"text-max-angle":new jn($t.layout_symbol["text-max-angle"]),"text-writing-mode":new jn($t.layout_symbol["text-writing-mode"]),"text-rotate":new Nn($t.layout_symbol["text-rotate"]),"text-padding":new jn($t.layout_symbol["text-padding"]),"text-keep-upright":new jn($t.layout_symbol["text-keep-upright"]),"text-transform":new Nn($t.layout_symbol["text-transform"]),"text-offset":new Nn($t.layout_symbol["text-offset"]),"text-allow-overlap":new jn($t.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new jn($t.layout_symbol["text-ignore-placement"]),"text-optional":new jn($t.layout_symbol["text-optional"])});var jd={paint:new qn({"icon-opacity":new Nn($t.paint_symbol["icon-opacity"]),"icon-color":new Nn($t.paint_symbol["icon-color"]),"icon-halo-color":new Nn($t.paint_symbol["icon-halo-color"]),"icon-halo-width":new Nn($t.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Nn($t.paint_symbol["icon-halo-blur"]),"icon-translate":new jn($t.paint_symbol["icon-translate"]),"icon-translate-anchor":new jn($t.paint_symbol["icon-translate-anchor"]),"text-opacity":new Nn($t.paint_symbol["text-opacity"]),"text-color":new Nn($t.paint_symbol["text-color"],{runtimeType:re,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Nn($t.paint_symbol["text-halo-color"]),"text-halo-width":new Nn($t.paint_symbol["text-halo-width"]),"text-halo-blur":new Nn($t.paint_symbol["text-halo-blur"]),"text-translate":new jn($t.paint_symbol["text-translate"]),"text-translate-anchor":new jn($t.paint_symbol["text-translate-anchor"])}),layout:Vd};class Nd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Qt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Po(Nd,"FormatSectionOverride",{omit:["defaultValue"]});class Gd extends ya{constructor(t){super(t,jd)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const o=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||Lr(n.value)||!o?o:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,o)}createBucket(t){return new Ud(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of jd.paint.overridableProperties){if(!Gd.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Nd(e),r=new Dr(i,e.property.specification);let o=null;o="constant"===e.value.kind||"source"===e.value.kind?new Rr("source",r):new Fr("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Un(e.property,o,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Gd.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=jd.paint.properties[e];let o=!1;const n=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(o=!0)};if("constant"===i.value.kind&&i.value.value instanceof be)n(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{o||(e instanceof Ae&&Se(e.value)===ae?n(e.value.sections):e instanceof De?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return o}getProgramConfiguration(t){return new ua(this,t)}}var Zd={paint:new qn({"background-color":new jn($t.paint_background["background-color"]),"background-pattern":new Zn($t.paint_background["background-pattern"]),"background-opacity":new jn($t.paint_background["background-opacity"])})},$d={paint:new qn({"raster-opacity":new jn($t.paint_raster["raster-opacity"]),"raster-hue-rotate":new jn($t.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new jn($t.paint_raster["raster-brightness-min"]),"raster-brightness-max":new jn($t.paint_raster["raster-brightness-max"]),"raster-saturation":new jn($t.paint_raster["raster-saturation"]),"raster-contrast":new jn($t.paint_raster["raster-contrast"]),"raster-resampling":new jn($t.paint_raster["raster-resampling"]),"raster-fade-duration":new jn($t.paint_raster["raster-fade-duration"])})};class qd extends ya{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var Xd={paint:new qn({"sky-type":new jn($t.paint_sky["sky-type"]),"sky-atmosphere-sun":new jn($t.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new jn($t.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new jn($t.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new jn($t.paint_sky["sky-gradient-radius"]),"sky-gradient":new $n($t.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new jn($t.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new jn($t.paint_sky["sky-atmosphere-color"]),"sky-opacity":new jn($t.paint_sky["sky-opacity"])})};function Wd(t,e,i){const r=[0,0,1],o=ql([]);return Wl(o,o,i?-c(t)+Math.PI:c(t)),Xl(o,o,-c(e)),Ol(r,r,o),Ll(r,r)}const Hd={circle:class extends ya{constructor(t){super(t,hl)}createBucket(t){return new Xa(t)}queryRadius(t){const e=t;return sl("circle-radius",this,e)+sl("circle-stroke-width",this,e)+al(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,o,n,s,a){const l=cl(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),n.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Ql(t,r,n,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new ua(this,t)}},heatmap:class extends ya{createBucket(t){return new oc(t)}constructor(t){super(t,uc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=hc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return sl("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return Ql(t,r,s,a,l,!0,!0,new n(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new ua(this,t)}},hillshade:class extends ya{constructor(t){super(t,pc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ya{constructor(t){super(t,Qc)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new ua(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Kc(t)}queryRadius(){return al(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,o,n){return!t.queryGeometry.isAboveHorizon&&Ya(ll(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),n.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends ya{constructor(t){super(t,Tu)}createBucket(t){return new xu(t)}queryRadius(){return al(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new ua(this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l,c){const u=cl(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(e,i),p=this.paint.get("fill-extrusion-base").evaluate(e,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,_=t.tile.getBucket(this);if(f&&_ instanceof xu){const t=_.centroidVertexArray,e=c+1;if(et.polygon)).flat());const g=function(t,e,i,r,o,s,a,l,c,u,h){return"globe"===t.projection.name?function(t,e,i,r,o,n,s,a,l,c,u){const h=[],p=[],d=t.projection.upVectorScale(u,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,r)=>{t[0]=e,t[1]=i,t[2]=r,t[3]=1},g=bu();i>0&&(i+=g),r+=g;for(const g of e){const e=[],y=[];for(const h of g){const p=h.x+o.x,g=h.y+o.y,x=t.projection.projectTilePoint(p,g,u),v=t.projection.upVector(u,h.x,h.y);let b=i,w=r;if(s){const t=Pu(p,g,i,r,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,x.x+v[0]*d*b,x.y+v[1]*d*b,x.z+v[2]*d*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*d*w,x.y+v[1]*d*w,x.z+v[2]*d*w),Fl(f,f,n),Fl(m,m,n),e.push(ku(f)),y.push(ku(m))}h.push(e),p.push(y)}return[h,p]}(t,e,i,r,o,s,a,l,c,u,h):a?function(t,e,i,r,o,n,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of t){const t=[],d=[];for(const c of p){const u=c.x+r.x,p=c.y+r.y,f=Pu(u,p,e,i,n,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,Zl(h,h,o),h[3]=Math.max(h[3],1e-5);const m=ku([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,Zl(h,h,o),h[3]=Math.max(h[3],1e-5);const _=ku([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);t.push(m),d.push(_)}c.push(t),u.push(d)}return[c,u]}(e,i,r,o,s,a,l,c,u):function(t,e,i,r,o){const s=[],a=[],l=o[8]*e,c=o[9]*e,u=o[10]*e,h=o[11]*e,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x+r.x,a=s.y+r.y,_=o[0]*e+o[4]*a+o[12],g=o[1]*e+o[5]*a+o[13],y=o[2]*e+o[6]*a+o[14],x=o[3]*e+o[7]*a+o[15],v=_+l,b=g+c,w=y+u,T=Math.max(x+h,1e-5),E=_+p,S=g+d,C=y+f,M=Math.max(x+m,1e-5),A=new n(v/T,b/T);A.z=w/T,t.push(A);const I=new n(E/M,S/M);I.z=C/M,i.push(I)}s.push(t),a.push(i)}return[s,a]}(e,i,r,o,s)}(s,r,p,h,u,a,f?l:null,d,m,s.center.lat,t.tileID.canonical),y=t.queryGeometry;return function(t,e,i){let r=1/0;Ya(i,e)&&(r=zu(i,e[0]));for(let o=0;o=3)for(let e=0;e1&&(s=t[++n]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=e/i*(r+1);if(s.isDash){const t=r-Math.abs(p);h=Math.sqrt(u*u+t*t)}else h=r-Math.sqrt(u*u+p*p);this.image.data[o+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const o=this.width*this.nextRow;let n=0,s=t[n];for(let i=0;i1&&(s=t[++n]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[o+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,o=r?7:0,n=2*o+1;if(this.nextRow+n>this.height)return P("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Qd{constructor(){this.tasks={},this.taskQueue=[],C(["process"],this),this.invoker=new Jd(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===r){B();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){B();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i>=1)>1;){const t=i+o>>1,l=r+n>>1;1&e?(o=i,n=r,i=s,r=a):(i=o,r=n,o=s,n=a),s=t,a=l}const l=4*t;sf[l+0]=i,sf[l+1]=r,sf[l+2]=o,sf[l+3]=n}const af=new Uint16Array(2178),lf=new Uint8Array(1089),cf=new Uint16Array(1089);function uf(t){return 0===t?-.03125:32===t?.03125:0}var hf=Kn([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const pf={type:2,extent:wa,loadGeometry:()=>[[new n(0,0),new n(8193,0),new n(8193,8193),new n(0,8193),new n(0,0)]]};class df{constructor(t,e,i,r,o){this.tileID=t,this.uid=w(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Ud){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Ud&&e.hasRTLText){this.hasRTLText=!0,kn.isLoading()||kn.isLoaded()||"deferred"!==In()||zn();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new As}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Yd(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Yd(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Yd(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,o,n,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:n,params:o,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),o=e?e.sourceLayer:"",n=r._geojsonTileLayer||r[o];if(!n)return;const s=Yr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let e=0;et)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=sf[e+0],r=sf[e+1],o=sf[e+2],n=sf[e+3],s=i+o>>1,a=r+n>>1,l=s+a-r,c=a+i-s,u=r*nf+i,h=n*nf+o,p=a*nf+s,d=Math.hypot((af[2*u+0]+af[2*h+0])/2-af[2*p+0],(af[2*u+1]+af[2*h+1])/2-af[2*p+1])>=16;if(lf[p]=lf[p]||(d?1:0),t<1022){const t=(r+c>>1)*nf+(i+l>>1),e=(n+c>>1)*nf+(o+l>>1);lf[p]=lf[p]||lf[t]||lf[e]}}const o=new es,n=new ms;let s=0;function a(t,e){const i=e*nf+t;return 0===cf[i]&&(o.emplaceBack(af[2*i+0],af[2*i+1],t*wa/of,e*wa/of),cf[i]=++s),cf[i]-1}function l(t,e,i,r,o,s){const c=t+i>>1,u=e+r>>1;if(Math.abs(t-o)+Math.abs(e-s)>1&&lf[u*nf+c])l(o,s,t,e,c,u),l(i,r,o,s,c,u);else{const l=a(t,e),c=a(i,r),u=a(o,s);n.emplaceBack(l,c,u)}}return l(0,0,of,of,of,0),l(of,of,0,0,0,of),{vertices:o,indices:n}}(this.tileID.canonical,e);r=t.vertices,o=t.indices}else{r=new es,o=new ms;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=mc(r.int16,void 0,4);for(let e=0;e{const u=(a-t)/(c-1),h=(l-s)/(c-1),p=r.length;for(let a=0;as*t+e;for(let t=0;te[s])return null}else{const a=1/r[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>o&&(o=l),cn)return null}return o}function gf(t,e,i,r,o,n,s,a,l,c,u){const h=r-t,p=o-e,d=n-i,f=s-t,m=a-e,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,x=u[0]*m-u[1]*f,v=h*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-t,T=c[1]-e,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const C=T*d-E*p,M=E*h-w*d,A=w*p-T*h,I=(u[0]*C+u[1]*M+u[2]*A)*b;return I<0||S+I>1?null:(f*C+m*M+_*A)*b}function yf(t,e,i){return(t-e)/(i-e)}function xf(t,e,i,r,o,n,s,a,l){const c=1<{const n=r?1:0,s=(t+1)*i-n,a=e*i,l=(e+1)*i-n;o[0]=t*i,o[1]=a,o[2]=s,o[3]=l};let s=new mf(r);const a=[];for(let e=0;e=1;r/=2){const t=i[i.length-1];s=new mf(r);for(let e=0;e0;){const{idx:a,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[a]){xf(f,m,_,t,e,i,r,u,h);const a=1<<_,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,g=(m+1)/a,y=wf(l,p,this.dem)*s,x=wf(c,p,this.dem)*s,v=wf(c,g,this.dem)*s,b=wf(l,g,this.dem)*s,w=gf(u[0],u[1],y,h[0],u[1],x,h[0],h[1],v,o,n),T=gf(h[0],h[1],v,u[0],h[1],b,u[0],u[1],y,o,n),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const t=Dl([],o,n,d);if(bf(y,x,b,v,yf(t[0],u[0],h[0]),yf(t[1],u[1],h[1]))>=t[2])return d}continue}let g=0;for(let p=0;p=l[c[i]]&&(c.splice(i,0,p),e=!0);e||(c[g]=p),g++}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=Ef.getUnpackVector(e);let o=Math.floor((t+r[3])/r[2]);return i[2]=o%256,o=Math.floor(o/256),i[1]=o%256,o=Math.floor(o/256),i[0]=o,i}getPixels(){return new cc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,o=e*this.dim+this.dim,n=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:r=o-1;break;case 1:o=r+1}switch(i){case-1:n=s-1;break;case 1:s=n+1}const a=-e*this.dim,l=-i*this.dim;for(let e=n;e{this.remove(t,o)}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Cf{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Cf.ReadOnly=!1,Cf.ReadWrite=!0,Cf.disabled=new Cf(519,Cf.ReadOnly,[0,1]);const Mf=7680;class Af{constructor(t,e,i,r,o,n){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=o,this.pass=n}}Af.disabled=new Af({func:519,mask:0},0,0,Mf,Mf,Mf);class If{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}If.Replace=[1,0],If.disabled=new If(If.Replace,ye.transparent,[!1,!1,!1,!1]),If.unblended=new If(If.Replace,ye.transparent,[!0,!0,!0,!0]),If.alphaBlended=new If([1,771],ye.transparent,[!0,!0,!0,!0]);const zf=1029,kf=2305;class Pf{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}Pf.disabled=new Pf(!1,zf,kf),Pf.backCCW=new Pf(!0,zf,kf),Pf.backCW=new Pf(!0,zf,2304),Pf.frontCW=new Pf(!0,1028,2304),Pf.frontCCW=new Pf(!0,1028,kf);class Df extends Zt{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Sf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new ff,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const e in this._tiles){const i=this._tiles[e];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(t),i.prepare(this.map.style.imageManager)}else for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return x(this._tiles).map((t=>t.tileID)).sort(Lf).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,o=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Lf).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new Gt(r,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=W.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Nt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[n]&&(t.neighboringTiles[n].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const o in this._tiles){let n=this._tiles[o];if(r[o]||!n.hasData()||n.tileID.overscaledZ<=e||n.tileID.overscaledZ>i)continue;let s=n.tileID;for(;n&&n.tileID.overscaledZ>e+1;){const t=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[t.key],n&&n.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){r[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,o=Math.floor(i*r*5),n="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,o):o,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Mu(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const o=this._updateRetainedTiles(r);if(Bf(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const r of i){const i=o[r],n=this._tiles[r];if(!n||n.fadeEndTime&&n.fadeEndTime<=W.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Df.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),e[r]=i}const n=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(o[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>n;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const n=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,o);for(const t of n){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),o=t[0].overscaledZ,n=Math.max(o-Df.maxOverzooming,this._source.minzoom),s=Math.max(o+Df.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let o=t.wasRequested();for(let s=r.overscaledZ-1;s>=n;--s){const n=r.scaledTo(s);if(i[n.key])break;if(i[n.key]=!0,t=this.getTile(n),!t&&o&&(t=this._addTile(n)),t&&(e[n.key]=n,o=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return this._source.prepareTile&&this._source.prepareTile(e),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null;e=new df(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(e)||this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Nt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const r=[],o=this.transform;if(!o)return r;const n="globe"===o.projection.name,s=Aa(o.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(n){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(m(s,...Rf(t,-1))-s),Math.abs(m(s,...Rf(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(m(s,...Rf(t,-1))-s),Math.abs(m(s,...Rf(t,0))-s),Math.abs(m(s,...Rf(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const n=t.containsTile(l,o,e,i);n&&r.push(n)}}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Bf(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=W.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){const i=new Map,r=Array.isArray(t)?t:[t],o=this.map.painter.terrain,n=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const t of r){const e=t.coveringTiles({tileSize:n,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}y(Array.from(i.values()),((t,e)=>{const i=new df(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Lf(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Bf(t){return"raster"===t||"image"===t||"video"===t}function Rf(t,e){const i=1<=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new pu.VectorTile(new ch(this.rawTileData)).layers,this.sourceLayerCoder=new tf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,r){this.loadVTLayers();const o=t.params||{},n=Yr(o.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>ol(s.bufferedTilespaceGeometry,t,e,i,r)));c.sort(Vf);let u=null;a.elevation&&c.length>0&&(u=Ff.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a(f||(f=Ga(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,r,f,this.z,t.transform,t.pixelPosMatrix,u,o))))}return h}loadMatchingFeature(t,e,i,r,o,n,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,d=this.bucketLayerIDs[u];if(r&&!function(t,e){for(let i=0;i=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Za(m,!0);if(!i.filter(new Pn(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Pn(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof Vn?e.get(n):null;return s&&s.evaluate?s.evaluate(i,r,o):s}))}function Vf(t,e){return e-t}Po(Of,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class jf{constructor(t){const e={},i=[];for(const r in t){const o=t[r],n=e[r]={};for(const t in o.glyphs){const e=o.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,s={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(s),n[t]=s}}const{w:r,h:o}=Ph(i),n=new lc({width:r||1,height:o||1});for(const i in t){const r=t[i];for(const t in r.glyphs){const o=r.glyphs[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const s=e[i][t],a=o.metrics.localGlyph?2:1;lc.copy(o.bitmap,n,{x:0,y:0},{x:s.x+a,y:s.y+a},o.bitmap)}}this.image=n,this.positions=e}}Po(jf,"GlyphAtlas");class Nf{constructor(t){this.tileID=new Mu(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=cd(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,e,i,r,o){this.status="parsing",this.data=t,this.collisionBoxArray=new As;const n=new tf(Object.keys(t.layers).sort()),s=new Of(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Kd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=e.familiesBySource[this.source];for(const e in u){const r=t.layers[e];if(!r)continue;let o=!1,l=!1;for(const t of u[e])"symbol"===t[0].type?o=!0:l=!0;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&P(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=n.encode(e),p=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(Gf(t,this.zoom,i),(a[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:i})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(t.map((t=>t.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=A(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{h||(h=t,p=e,v.call(this))}),void 0,!1,m):p={};const g=Object.keys(c.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{h||(h=t,d=e,v.call(this))}),void 0,!1,m):d={};const y=Object.keys(c.patternDependencies);function v(){if(h)return o(h);if(p&&d&&f){const t=new jf(p),e=new Lh(d,f);for(const r in a){const o=a[r];o instanceof Ud?(Gf(o.layers,this.zoom,i),Sp(o,p,t.positions,d,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection)):o.hasPattern&&(o instanceof Uu||o instanceof Kc||o instanceof xu)&&(Gf(o.layers,this.zoom,i),o.addFeatures(c,this.tileID.canonical,e.patternPositions,i,this.tileTransform))}this.status="done",o(null,{buckets:x(a).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?t.positions:null})}}y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{h||(h=t,f=e,v.call(this))}),void 0,!1,m):f={},v.call(this)}}function Gf(t,e,i){const r=new Pn(e);for(const e of t)e.recalculate(r,i)}class Zf{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const o=this.entries[t]=this.entries[t]||{callbacks:[]};if(o.result){const[t,i]=o.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return o.callbacks.push(r),o.cancel||(o.cancel=i(((i,r)=>{o.result=[i,r];for(const t of o.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{o.result||(o.callbacks=o.callbacks.filter((t=>t!==r)),o.callbacks.length||(o.cancel(),delete this.entries[t]))}}}function $f(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const r=Pt(t.request,((t,r,o,n)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new pu.VectorTile(new ch(r)),rawData:r,cacheControl:o,expires:n})}));return()=>{r.cancel(),e()}}),e)}t.ARRAY_TYPE=dl,t.AUTH_ERR_MSG=ot,t.Aabb=Jl,t.Actor=class{constructor(t,i,r){this.target=t,this.parent=i,this.mapId=r,this.callbacks={},this.cancelCallbacks={},C(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=B()?t:e,this.scheduler=new Qd}send(t,e,i,r,o=!1,n){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=n,this.callbacks[s]=i);const a=O(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:t,hasCallback:!!i,targetMapId:r,mustQueue:o,sourceMapId:this.mapId,data:Bo(e,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||B()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ro(e.error)):i(null,Ro(e.data)))}else{const i=O(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Bo(e):null,data:Bo(r,i)},i)}:t=>{},o=Ro(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,o,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],o.source)[t[1]](o,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=Su,t.Color=ye,t.ColorMode=If,t.CullFaceMode=Pf,t.DEMData=Ef,t.DataConstantProperty=jn,t.DedupedRequest=Zf,t.DepthMode=Cf,t.EXTENT=wa,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,r=1<1)return e;const o=r.getSource().maxzoom,n=1<{const n=this.getAtTileOffset(t,o.x,o.y),s=r.upVector(t.canonical,o.x,o.y);return Pl(s,s,n*r.upVectorScale(t.canonical,e,i).metersToTile),s}}getForTilePoints(t,e,i,r){const o=Ff.create(this,t,r);return!!o&&(e.forEach((t=>{t[2]=this.exaggeration()*o.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,o=1<this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!nt(t))return t;const i=lt(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!nt(t))return t;const i=lt(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,r){if(!nt(t))return t;const o=lt(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),i&&o.params.push(`language=${i}`),r&&o.params.push(`worldview=${r}`),this._makeAPIURL(o,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const o=lt(t);return nt(t)?(o.path=`/styles/v1${o.path}/sprite${e}${i}`,this._makeAPIURL(o,this._customAccessToken||r)):(o.path+=`${e}${i}`,ct(o))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!nt(t))return t;const r=lt(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${K.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${Y.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${Y.TILE_URL_VERSION}${r.path}`);const o=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||Y.ACCESS_TOKEN;return Y.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,o)}canonicalizeTileURL(t,e){const i=lt(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${Y.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${Y.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&nt(e),r=[];for(const e of t.tiles||[])st(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=lt(Y.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!Y.REQUIRE_ACCESS_TOKEN)return ct(t);if(e=e||Y.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),ct(t)}},t.ResourceType=At,t.SegmentVector=ba,t.SourceCache=Df,t.StencilMode=Af,t.StructArrayLayout1ui2=Ts,t.StructArrayLayout2f1f2i16=ps,t.StructArrayLayout2i4=Qn,t.StructArrayLayout2ui4=ws,t.StructArrayLayout3f12=fs,t.StructArrayLayout3ui6=ms,t.StructArrayLayout4i8=es,t.StructArrayLayout5f20=vs,t.Texture=Yd,t.Tile=df,t.Transitionable=Bn,t.Uniform1f=Js,t.Uniform1i=class extends Ks{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends Ks{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends Ks{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=Qs,t.UniformColor=ta,t.UniformMatrix2f=class extends Ks{constructor(t,e){super(t,e),this.current=ra}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}},t.UniformMatrix3f=class extends Ks{constructor(t,e){super(t,e),this.current=ia}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},t.UniformMatrix4f=class extends Ks{constructor(t,e){super(t,e),this.current=ea}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=Cu,t.ValidationError=jr,t.VectorTileWorkerSource=class extends Zt{constructor(t,e,i,r,o){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=o||$f,this.loading={},this.loaded={},this.deduped=new Zf(t.scheduler),this.isSpriteLoaded=r,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,r=t&&t.request,o=r&&r.collectResourceTiming,n=this.loading[i]=new Nf(t);n.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return n.status="done",l||(this.loaded[i]=n),e(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),n.vectorTile=a.vectorTile||new pu.VectorTile(new ch(c));const h=()=>{n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const n={};if(o){const t=N(r);t.length>0&&(n.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,v({rawTileData:c.slice(0)},i,u,n))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[i]=n}))}reloadTile(t,e){const i=this.loaded,r=t.uid,o=this;if(i&&i[r]){const n=i[r];n.showCollisionBoxes=t.showCollisionBoxes,n.enableTerrain=!!t.enableTerrain,n.projection=t.projection,n.tileTransform=cd(t.tileID.canonical,t.projection);const s=(t,i)=>{const r=n.reloadCallback;r&&(delete n.reloadCallback,n.parse(n.vectorTile,o.layerIndex,this.availableImages,o.actor,r)),e(t,i)};"parsing"===n.status?n.reloadCallback=s:"done"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(t,e){const i=t.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}},t.WritingMode=Bh,t.ZoomHistory=Fo,t.add=Ml,t.addDynamicAttributes=Bd,t.adjoint=function(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=s*u-a*c,t[1]=o*c-r*u,t[2]=r*a-o*s,t[3]=a*l-n*u,t[4]=i*u-o*l,t[5]=o*n-i*a,t[6]=n*c-s*l,t[7]=r*l-i*c,t[8]=i*s-r*n,t},t.asyncAll=y,t.bezier=d,t.bindAll=C,t.boundsAttributes=hf,t.bufferConvexPolygon=function(t,e){const i=[];for(let r=0;rbt&&(t.getActor().send("enforceCacheSizeLimit",vt),Mt=0)},t.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:r}=t.point,o=id(i,r,t.worldSize/t._projectionScaler,0,0);return _l(o,o,ed(Xp(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:r,lat:o}=t._center;return id(e,i,t.worldSize,r,o)},t.calculateGlobeMercatorMatrix=function(t){const e=t.worldSize,i=t.point,r=za(1,t.center.lat)*e,o=t.pixelsPerMeter,n=e/(r/t.pixelsPerMeter),s=ml(new Float64Array(16));return gl(s,s,[i.x,i.y,0]),yl(s,s,[n,n,o]),Float32Array.from(s)},t.circumferenceAtLatitude=Ma,t.clamp=m,t.clearTileCache=function(t){const i=[];for(const t in wt)i.push(e.caches.delete(t)),delete wt[t];t&&Promise.all(i).catch(t).then((()=>t()))},t.clipLine=np,t.clone=function(t){var e=new dl(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=z,t.collisionCircleLayout=Yu,t.config=Y,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new dl(16);return dl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=fl,t.createExpression=Br,t.createLayout=Kn,t.createStyleLayer=function(t){return"custom"===t.type?new qd(t):new Hd[t.type](t)},t.cross=Rl,t.degToRad=c,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},t.dot=Bl,t.ease=f,t.easeCubicInOut=p,t.emitValidationErrors=Ao,t.endsWith=M,t.enforceCacheSizeLimit=function(t){for(const e in wt)Et(e),wt[e].then((e=>{e.keys().then((i=>{for(let r=0;rn&&(r+=(t[o]-n)*(t[o]-n)),e[o]{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=ml(new Float64Array(16));return _l(i,t.pixelMatrix,t.globeMatrix),Fl(e,e,i),new n(e[0],e[1])},t.globeECEFOrigin=function(t,e){const i=[0,0,0];return Fl(i,i,td(Xp(e.canonical))),Fl(i,i,t),i},t.globeNormalizeECEF=td,t.globePixelsToTileUnits=function(t,e){return wa/(512*Math.pow(2,t))*Qp(Xp(e))},t.globePoleMatrixForTile=function(t,e,i){const r=ml(new Float64Array(16)),o=1<0;return 0===r&&!o&&!s&&n},t.identity=ml,t.identity$1=ql,t.invert=function(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*s,x=i*l-o*s,v=i*c-n*s,b=r*l-o*a,w=r*c-n*a,T=o*c-n*l,E=u*m-h*f,S=u*_-p*f,C=u*g-d*f,M=h*_-p*m,A=h*g-d*m,I=p*g-d*_,z=y*I-x*A+v*M+b*C-w*S+T*E;return z?(t[0]=(a*I-l*A+c*M)*(z=1/z),t[1]=(o*A-r*I-n*M)*z,t[2]=(m*T-_*w+g*b)*z,t[3]=(p*w-h*T-d*b)*z,t[4]=(l*C-s*I-c*S)*z,t[5]=(i*I-o*C+n*S)*z,t[6]=(_*v-f*T-g*x)*z,t[7]=(u*T-p*v+d*x)*z,t[8]=(s*A-a*C+c*E)*z,t[9]=(r*C-i*A-n*E)*z,t[10]=(f*w-m*v+g*y)*z,t[11]=(h*v-u*w-d*y)*z,t[12]=(a*S-s*M-l*E)*z,t[13]=(i*M-r*S+o*E)*z,t[14]=(m*x-f*b-_*y)*z,t[15]=(u*b-h*x+p*y)*z,t):null},t.isLngLatBehindGlobe=function(t,e){return od(t,e)>Math.PI/2*1.01},t.isMapAuthenticated=function(t){return yt.has(t)},t.isMapboxURL=nt,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!O(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Pa,t.len=Nl,t.length=Sl,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=$f,t.makeRequest=kt,t.mapValue=function(t,e,i,r,o){return m((t-e)/(i-e)*(o-r)+r,r,o)},t.mercatorXfromLng=Aa,t.mercatorYfromLat=Ia,t.mercatorZfromAltitude=za,t.mul=wl,t.mul$1=jl,t.multiply=_l,t.multiply$1=function(t,e,i){var r=e[0],o=e[1],n=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=i[0],d=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return t[0]=p*r+d*s+f*c,t[1]=p*o+d*a+f*u,t[2]=p*n+d*l+f*h,t[3]=m*r+_*s+g*c,t[4]=m*o+_*a+g*u,t[5]=m*n+_*l+g*h,t[6]=y*r+x*s+v*c,t[7]=y*o+x*a+v*u,t[8]=y*n+x*l+v*h,t},t.multiply$2=Il,t.nextPowerOfTwo=E,t.normalize=Ll,t.normalize$1=function(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=i*i+r*r+o*o+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=r*s,t[2]=o*s,t[3]=n*s,t},t.number=yi,t.ortho=function(t,e,i,r,o,n,s){var a=1/(e-i),l=1/(r-o),c=1/(n-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(o+r)*l,t[14]=(s+n)*c,t[15]=1,t},t.pbf=ch,t.perspective=function(t,e,i,r,o){var n,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=o&&o!==1/0?(t[10]=(o+r)*(n=1/(r-o)),t[14]=2*o*r*n):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){const i={};for(let r=0;rMo(lo(t)),t.validateFog=t=>Mo(vo(t)),t.validateLayer=t=>Mo(fo(t)),t.validateLight=t=>Mo(yo(t)),t.validateSource=t=>Mo(go(t)),t.validateStyle=Eo,t.validateTerrain=t=>Mo(xo(t)),t.values=x,t.vectorTile=pu,t.version=G,t.warnOnce=P,t.window=e,t.wrap=g})),o(["./shared"],(function(t){function e(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let i="[";for(const r of t)i+=`${e(r)},`;return`${i}]`}let i="{";for(const r of Object.keys(t).sort())i+=`${r}:${e(t[r])},`;return`${i}}`}function i(i){let r="";for(const o of t.refProperties)r+=`/${e(i[o])}`;return r}class r{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const r={};for(let o=0;othis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const n=i.sourceLayer||"_geojsonTileLayer";let s=o[n];s||(s=o[n]=[]),s.push(e)}}}class o{loadTile(e,i){const{uid:r,encoding:o,rawImageData:n,padding:s,buildQuadTree:a}=e,l=t.window.ImageBitmap&&n instanceof t.window.ImageBitmap?this.getImageData(n,s):n;i(null,new t.DEMData(r,l,o,s<1,a))}getImageData(t,e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const i=this.offscreenCanvasContext.getImageData(-e,-e,t.width+2*e,t.height+2*e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}var n=function t(e,i){var r,o=e&&e.type;if("FeatureCollection"===o)for(r=0;r=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!e&&t.reverse()}const l=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class c{constructor(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return l.call(this,t,e,i)}}class u{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new c(this._features[t])}}var h=t.vectorTile.VectorTileFeature,p=d;function d(t,e){this.options=e||{},this.features=t,this.length=t.length}function f(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}d.prototype.feature=function(t){return new f(this.features[t],this.options.extent)},f.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function T(t,e){for(var i=t.loadGeometry(),r=t.type,o=0,n=0,s=i.length,a=0;a>1;C(t,e,s,r,o,n%2),S(t,e,i,r,s-1,n+1),S(t,e,i,s+1,o,n+1)}function C(t,e,i,r,o,n){for(;o>r;){if(o-r>600){const s=o-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);C(t,e,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(o,Math.floor(i+(s-a)*c/s+u)),n)}const s=e[2*i+n];let a=r,l=o;for(M(t,e,r,i),e[2*o+n]>s&&M(t,e,r,o);as;)l--}e[2*r+n]===s?M(t,e,r,l):(l++,M(t,e,l,o)),l<=i&&(r=l+1),i<=l&&(o=l-1)}}function M(t,e,i,r){A(t,i,r),A(e,2*i,2*r),A(e,2*i+1,2*r+1)}function A(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function I(t,e,i,r){const o=t-i,n=e-r;return o*o+n*n}m.fromVectorTileJs=g,m.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new p(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return g({layers:i})},m.GeoJSONWrapper=_;const z=t=>t[0],k=t=>t[1];class P{constructor(t,e=z,i=k,r=64,o=Float64Array){this.nodeSize=r,this.points=t;const n=t.length<65536?Uint16Array:Uint32Array,s=this.ids=new n(t.length),a=this.coords=new o(2*t.length);for(let r=0;r=i&&c<=o&&u>=r&&u<=n&&l.push(t[s]);continue}const f=Math.floor((d+p)/2);c=e[2*f],u=e[2*f+1],c>=i&&c<=o&&u>=r&&u<=n&&l.push(t[f]);const m=(h+1)%2;(0===h?i<=c:r<=u)&&(a.push(d),a.push(f-1),a.push(m)),(0===h?o>=c:n>=u)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,o,n){const s=[0,t.length-1,0],a=[],l=o*o;for(;s.length;){const c=s.pop(),u=s.pop(),h=s.pop();if(u-h<=n){for(let o=h;o<=u;o++)I(e[2*o],e[2*o+1],i,r)<=l&&a.push(t[o]);continue}const p=Math.floor((h+u)/2),d=e[2*p],f=e[2*p+1];I(d,f,i,r)<=l&&a.push(t[p]);const m=(c+1)%2;(0===c?i-o<=d:r-o<=f)&&(s.push(h),s.push(p-1),s.push(m)),(0===c?i+o>=d:r+o>=f)&&(s.push(p+1),s.push(u),s.push(m))}return a}(this.ids,this.coords,t,e,i,this.nodeSize)}}const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},L=Math.fround||(B=new Float32Array(1),t=>(B[0]=+t,B[0]));var B;class R{constructor(t){this.options=Z(Object.create(D),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:o}=this.options;e&&console.time("total time");const n=`prepare ${t.length} points`;e&&console.time(n),this.points=t;let s=[];for(let e=0;e=i;t--){const i=+Date.now();s=this._cluster(s,t),this.trees[t]=new P(s,$,q,o,Float32Array),e&&console.log("z%d: %d clusters in %dms",t,s.length,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let o=180===t[2]?180:((t[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,o=180;else if(i>o){const t=this.getClusters([i,r,180,n],e),s=this.getClusters([-180,r,o,n],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(j(i),N(n),j(o),N(r)),l=[];for(const t of a){const e=s.points[t];l.push(e.numPoints?U(e):this.points[e.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",o=this.trees[i];if(!o)throw new Error(r);const n=o.points[e];if(!n)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=o.within(n.x,n.y,s),l=[];for(const e of a){const i=o.points[e];i.parentId===t&&l.push(i.numPoints?U(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],o=Math.pow(2,t),{extent:n,radius:s}=this.options,a=s/n,l=(i-a)/o,c=(i+1+a)/o,u={features:[]};return this._addTileFeatures(r.range((e-a)/o,l,(e+1+a)/o,c),r.points,e,i,o,u),0===e&&this._addTileFeatures(r.range(1-a/o,l,1,c),r.points,o,i,o,u),e===o-1&&this._addTileFeatures(r.range(0,l,a/o,c),r.points,-1,i,o,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,o){const n=this.getChildren(e);for(const e of n){const n=e.properties;if(n&&n.cluster?o+n.point_count<=r?o+=n.point_count:o=this._appendLeaves(t,n.cluster_id,i,r,o):oe&&(h+=i.numPoints||1)}if(h>u&&h>=s){let t=o.x*u,s=o.y*u,a=n&&u>1?this._map(o,!0):null;const p=(r<<5)+(e+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=e)continue;r.zoom=e;const c=r.numPoints||1;t+=r.x*c,s+=r.y*c,r.parentId=p,n&&(a||(a=this._map(o,!0)),n(a,this._map(r)))}o.parentId=p,i.push(F(t/h,s/h,p,h,a))}else if(i.push(o),h>1)for(const t of c){const r=l.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?Z({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?Z({},r):r}}function F(t,e,i,r,o){return{x:L(t),y:L(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:o}}function O(t,e){const[i,r]=t.geometry.coordinates;return{x:L(j(i)),y:L(N(r)),zoom:1/0,index:e,parentId:-1}}function U(t){return{type:"Feature",id:t.id,properties:V(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),G(t.y)]}};var e}function V(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return Z(Z({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function j(t){return t/360+.5}function N(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function G(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function Z(t,e){for(const i in e)t[i]=e[i];return t}function $(t){return t.x}function q(t){return t.y}function X(t,e,i,r){for(var o,n=r,s=i-e>>1,a=i-e,l=t[e],c=t[e+1],u=t[i],h=t[i+1],p=e+3;pn)o=p,n=d;else if(d===n){var f=Math.abs(p-s);fr&&(o-e>3&&X(t,e,o,r),t[o+2]=n,i-o>3&&X(t,o,i,r))}function W(t,e,i,r,o,n){var s=o-i,a=n-r;if(0!==s||0!==a){var l=((t-i)*s+(e-r)*a)/(s*s+a*a);l>1?(i=o,r=n):l>0&&(i+=s*l,r+=a*l)}return(s=t-i)*s+(a=e-r)*a}function H(t,e,i,r){var o={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)Y(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r0&&(s+=r?(o*c-l*n)/2:Math.sqrt(Math.pow(l-o,2)+Math.pow(c-n,2))),o=l,n=c}var u=e.length-3;e[2]=1,X(e,0,u,i),e[u+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function tt(t,e,i,r){for(var o=0;o1?1:i}function rt(t,e,i,r,o,n,s,a){if(r/=e,n>=(i/=e)&&s=r)return null;for(var l=[],c=0;c=i&&f=r)){var m=[];if("Point"===p||"MultiPoint"===p)ot(h,m,i,r,o);else if("LineString"===p)nt(h,m,i,r,o,!1,a.lineMetrics);else if("MultiLineString"===p)at(h,m,i,r,o,!1);else if("Polygon"===p)at(h,m,i,r,o,!0);else if("MultiPolygon"===p)for(var _=0;_=i&&s<=r&&(e.push(t[n]),e.push(t[n+1]),e.push(t[n+2]))}}function nt(t,e,i,r,o,n,s){for(var a,l,c=st(t),u=0===o?ct:ut,h=t.start,p=0;pi&&(l=u(c,d,f,_,g,i),s&&(c.start=h+a*l)):y>r?x=i&&(l=u(c,d,f,_,g,i),v=!0),x>r&&y<=r&&(l=u(c,d,f,_,g,r),v=!0),!n&&v&&(s&&(c.end=h+a*l),e.push(c),c=st(t)),s&&(h+=a)}var b=t.length-3;d=t[b],f=t[b+1],m=t[b+2],(y=0===o?d:f)>=i&&y<=r&<(c,d,f,m),b=c.length-3,n&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&<(c,c[0],c[1],c[2]),c.length&&e.push(c)}function st(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function at(t,e,i,r,o,n){for(var s=0;ss.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function _t(t,e,i,r){var o=e.geometry,n=e.type,s=[];if("Point"===n||"MultiPoint"===n)for(var a=0;a0&&e.size<(o?s:r))i.numPoints+=e.length/3;else{for(var a=[],l=0;ls)&&(i.numSimplified++,a.push(e[l]),a.push(e[l+1])),i.numPoints++;o&&function(t,e){for(var i=0,r=0,o=t.length,n=o-2;r0===e)for(r=0,o=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r1&&console.time("creation"),p=this.tiles[h]=mt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=t,o){if(e===l.maxZoom||e===o)continue;var f=1<1&&console.time("clipping");var m,_,g,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,x=rt(t,u,i-b,i+T,0,p.minX,p.maxX,l),v=rt(t,u,i+w,i+E,0,p.minX,p.maxX,l),t=null,x&&(m=rt(x,u,r-b,r+T,1,p.minY,p.maxY,l),_=rt(x,u,r+w,r+E,1,p.minY,p.maxY,l),x=null),v&&(g=rt(v,u,r-b,r+T,1,p.minY,p.maxY,l),y=rt(v,u,r+w,r+E,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(m||[],e+1,2*i,2*r),a.push(_||[],e+1,2*i,2*r+1),a.push(g||[],e+1,2*i+1,2*r),a.push(y||[],e+1,2*i+1,2*r+1)}}},yt.prototype.getTile=function(t,e,i){var r=this.options,o=r.extent,n=r.debug;if(t<0||t>24)return null;var s=1<1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,u=e,h=i;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[xt(c,u,h)];return l&&l.source?(n>1&&console.log("found parent tile z%d-%d-%d",c,u,h),n>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,t,e,i),n>1&&console.timeEnd("drilling down"),this.tiles[a]?dt(this.tiles[a],o):null):null};class bt extends t.VectorTileWorkerSource{constructor(t,e,i,r,o){super(t,e,i,r,vt),o&&(this.loadGeoJSON=o)}loadData(e,i){const r=e&&e.request,o=r&&r.collectResourceTiming;this.loadGeoJSON(e,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{n(a,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=a.features.filter((t=>i.value.evaluate({zoom:0},t)));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=e.cluster?new R(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},o={},n={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const e of a){const[n,s]=i[e],a=t.createExpression(s),l=t.createExpression("string"==typeof n?[n,["accumulated"],["get",e]]:n);r[e]=a.value,o[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(n,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)n.accumulated=t[e],t[e]=o[e].evaluate(n,s)},e}(e)).load(a.features):function(t,e){return new yt(t,e)}(a,e.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(o){const i=t.getPerformanceMeasurement(r);i&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)t.getJSON(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class wt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:bt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}clearCaches(t,e,i){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],i()}checkIfReady(t,e,i){i()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,i){this.isSpriteLoaded[e]=i;for(const r in this.workerSources[e]){const o=this.workerSources[e][r];for(const e in o)o[e]instanceof t.VectorTileWorkerSource&&(o[e].isSpriteLoaded=i,o[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const r=this.workerSources[t][i];for(const t in r)r[t].availableImages=e}i()}enableTerrain(t,e,i){this.terrain=e,i()}setProjection(e,i){this.projections[e]=t.getProjection(i)}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(e,i,r){const o=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;o.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).loadTile(o,r)}loadDEMTile(e,i,r){const o=this.enableTerrain?t.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(e,i.source).loadTile(o,r)}reloadTile(e,i,r){const o=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;o.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).reloadTile(o,r)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,r){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e}getWorkerSource(t,e,i){return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][i]||(this.workerSources[t][e][i]=new this.workerSourceTypes[e]({send:(e,i,r,o,n,s)=>{this.actor.send(e,i,r,t,n,s)},scheduler:this.actor.scheduler},this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded[t])),this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new o),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(t,e,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new wt(self)),wt})),o(["./shared"],(function(t){function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r{t.window.removeEventListener("click",p,!0)}),0)}function f(t,e){const i=t.getBoundingClientRect();return g(t,i,e)}function m(t,e){const i=t.getBoundingClientRect(),r=[];for(let o=0;o=0?0:e.button}function g(e,i,r){const o=e.offsetWidth===i.width?1:e.offsetWidth/i.width;return new t.pointGeometry((r.clientX-i.left)*o,(r.clientY-i.top)*o)}function y(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=i*n-o*r;return s?(t[0]=n*(s=1/s),t[1]=-r*s,t[2]=-o*s,t[3]=i*s,t):null}function x(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class v extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}hasImage(t){return!!this.getImage(t)}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]{this.ready=!0}))}broadcast(e,i,r){t.asyncAll(this.actors,((t,r)=>{t.send(e,i,r)}),r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function D(e,i,r){return i*(t.EXTENT/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}P.Actor=t.Actor;class L{constructor(t,e,i,r){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(e,i){let r,o;if(e instanceof t.pointGeometry||"number"==typeof e[0]){const n=t.pointGeometry.convert(e);r=[t.pointGeometry.convert(e)],o=i.isPointAboveHorizon(n)}else{const n=t.pointGeometry.convert(e[0]),s=t.pointGeometry.convert(e[1]);r=[n,s],o=t.polygonizeBounds(n,s).every((t=>i.isPointAboveHorizon(t)))}return new L(r,i.getCameraPoint(),o,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],o=t.polygonizeBounds(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=r.x?o[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(o[3]=this.cameraPoint)),t.bufferConvexPolygon(o,e)}bufferedCameraGeometryGlobe(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],o=t.polygonizeBounds(i,r,e),n=this.cameraPoint.clone();switch(3*((n.y>i.y)+(n.y>r.y))+((n.x>i.x)+(n.x>r.x))){case 0:o[0]=n,o[4]=n.clone();break;case 1:o.splice(1,0,n);break;case 2:o[1]=n;break;case 3:o.splice(4,0,n);break;case 5:o.splice(2,0,n);break;case 6:o[3]=n;break;case 7:o.splice(3,0,n);break;case 8:o[2]=n}return o}containsTile(e,i,r,o=0){const n=e.queryPadding/i._projectionScaler+1,s=r?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let a=e.tileID.wrap+(s.unwrapped?o:0);const l=s.polygon.map((i=>t.getTilePoint(e.tileTransform,i,a)));if(!t.polygonIntersectsBox(l,0,0,t.EXTENT,t.EXTENT))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?o:0);const c=this.screenGeometryMercator.polygon.map((i=>t.getTileVec3(e.tileTransform,i,a))),u=c.map((e=>new t.pointGeometry(e[0],e[1]))),h=i.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),p=t.getTileVec3(e.tileTransform,h,a),d=c.map((e=>{const i=t.sub(e,e,p);return t.normalize(i,i),new t.Ray(p,i)})),f=D(e,1,i.zoom)*i._projectionScaler;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=t.getBounds(l),m.min.x=t.clamp(m.min.x,0,t.EXTENT),m.min.y=t.clamp(m.min.y,0,t.EXTENT),m.max.x=t.clamp(m.max.x,0,t.EXTENT),m.max.y=t.clamp(m.max.y,0,t.EXTENT),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(t,e){const i=F(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===e.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),e):{polygon:this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(t,e){const i=F(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===e.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),e):{polygon:this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,i){const r=function(e,i){const r=t.multiply([],i.pixelMatrix,i.globeMatrix),o=[0,-t.GLOBE_RADIUS,0,1],n=[0,t.GLOBE_RADIUS,0,1],s=[0,0,0,1];t.transformMat4$1(o,o,r),t.transformMat4$1(n,n,r),t.transformMat4$1(s,s,r);const a=new t.pointGeometry(o[0]/o[3],o[1]/o[3]),l=new t.pointGeometry(n[0]/n[3],n[1]/n[3]),c=t.polygonContainsPoint(e,a)&&o[3]1?B(e.slice(0,p),i):[],m=pnew t.pointGeometry(R(e.x),e.y))),m=m.map((e=>new t.pointGeometry(R(e.x),e.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=t.number(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new t.pointGeometry(0,g),new t.pointGeometry(0,0),new t.pointGeometry(1,0),new t.pointGeometry(1,g)]:[new t.pointGeometry(1,g),new t.pointGeometry(1,1),new t.pointGeometry(0,1),new t.pointGeometry(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,i);if(r)return r;const o=function(e,i){let r=!1,o=-1/0,n=0;for(let t=0;to&&(o=e[t].x,n=t);for(let t=0;t.5&&(o.x{t.x-=1})),{polygon:e,unwrapped:r}}(B(e,i).map((e=>new t.pointGeometry(R(e.x),e.y))),i);return{polygon:o.polygon.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:o.unwrapped}}}function B(e,i){return t.resample(e,(t=>{const e=i.pointCoordinate3D(t);t.x=e.x,t.y=e.y}),1/256)}function R(t){return t<0?1+t%1:t%1}function F(t){return 100*t|0}function O(e,i,r,o,n){const s=function(r,o){if(r)return n(r);if(o){const r=t.pick(t.extend(o,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);o.vector_layers&&(r.vectorLayers=o.vector_layers,r.vectorLayerIds=r.vectorLayers.map((t=>t.id))),o.language_options&&(r.languageOptions=o.language_options),o.language&&o.language[o.id]&&(r.language=o.language[o.id]),o.worldview_options&&(r.worldviewOptions=o.worldview_options),o.worldview?r.worldview=o.worldview[o.id]:o.worldview_default&&(r.worldview=o.worldview_default),r.tiles=i.canonicalizeTileset(r,e.url),n(null,r)}};return e.url?t.getJSON(i.transformRequest(i.normalizeSourceURL(e.url,null,r,o),t.ResourceType.Source),s):t.exported.frame((()=>s(null,e)))}class U{constructor(e,i,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),o=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),n=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new U(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const r=t.exported.devicePixelRatio>=2,o=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(o,t.ResourceType.Tile),((r,o,n,s)=>(delete e.request,e.aborted?(e.state="unloaded",i(null)):r?(e.state="errored",i(r)):o?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:n,expires:s}),e.setTexture(o,this.map.painter),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))))}static loadTileData(t,e,i){t.setTexture(e,i)}static unloadTileData(t,e){t.texture&&e.saveTileTexture(t.texture)}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let At;function It(e,i,r,o,n,s,a,l){const c=[e,r,n,i,o,s,1,1,1],u=[a,l,1],h=t.adjoint([],c),[p,d,f]=t.transformMat3(u,u,t.transpose(h,h));return t.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class zt extends t.Evented{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(e,i){this._loaded=i||!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((i,r)=>{if(this._loaded=!0,i)this.fire(new t.ErrorEvent(i));else if(r){const{HTMLImageElement:i}=t.window;this.image=r instanceof i?t.exported.getImageData(r):r,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const i=e.map(t.MercatorCoordinate.fromLngLat);return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,n=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),n=Math.max(n,t.y);const s=Math.max(o-i,n-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new t.CanonicalTileID(a,Math.floor((i+o)/2*l),Math.floor((r+n)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const i=t.tileTransform(this.tileID,this.map.transform.projection),[r,o,n,s]=this.coordinates.map((e=>{const r=i.projection.project(e[0],e[1]);return t.getTilePoint(i,r)._round()}));this.perspectiveTransform=function(e,i,r,o,n,s,a,l,c,u){const h=It(0,0,e,0,0,i,e,i),p=It(r,o,n,s,a,l,c,u);return t.multiply$1(p,t.adjoint(h,h),p),[p[6]/p[8]*e/t.EXTENT,p[7]/p[8]*i/t.EXTENT]}(this.width,this.height,r.x,r.y,o.x,o.y,s.x,s.y,n.x,n.y);const a=this._boundsArray=new t.StructArrayLayout4i8;a.emplaceBack(r.x,r.y,0,0),a.emplaceBack(o.x,o.y,t.EXTENT,0),a.emplaceBack(s.x,s.y,0,t.EXTENT),a.emplaceBack(n.x,n.y,t.EXTENT,t.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,t.boundsAttributes.members),this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture?this.texture.update(this.image):(this.texture=new t.Texture(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._prepareData(e)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const kt={vector:class extends t.Evented{constructor(e,i,r,o){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(i,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o),this._tileWorkers={},this._deduped=new t.DedupedRequest}load(e){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"}));const i=this.language||this.map._language,r=this.worldview||this.map._worldview;this._tileJSONRequest=O(this._options,this.map._requestManager,i,r,((o,n)=>{this._tileJSONRequest=null,this._loaded=!0,o?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new t.ErrorEvent(o))):n&&(t.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(o)}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load((()=>{const t=this.map.style._getSourceCaches(this.id);for(const e of t)e.clearTiles()}))}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}_setLanguage(t){return t===this.language||this.setSourceProperty((()=>{this.language=t})),this}_setWorldview(t){return t===this.worldview?this:this.worldviewOptions&&t&&!this.worldviewOptions[t]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${t}".`),this):(this.setSourceProperty((()=>{this.worldview=t})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),o={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(o.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",o,n.bind(this));else if(e.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",o,n.bind(this),void 0,!0);else{const i=t.loadVectorTile.call({deduped:this._deduped},o,((t,i)=>{t||!i?n.call(this,t):(o.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",o,n.bind(this),void 0,!0))}),!0);e.request={cancel:i}}function n(r,o){return delete e.request,e.aborted?i(null):r&&404!==r.status?i(r):(o&&o.resourceTiming&&(e.resourceTiming=o.resourceTiming),this.map._refreshExpiredTiles&&o&&e.setExpiryData(o),e.loadVectorData(o,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Mt,"raster-dem":class extends Mt{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function o(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,n,s,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const i=t.window.ImageBitmap&&n instanceof t.window.ImageBitmap&&(null==At&&(At=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.window.createImageBitmap),At),r=1-(n.width-t.prevPowerOfTwo(n.width))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=i?n:t.exported.getImageData(n,r),c={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,o.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,n=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,a=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,n,i.z,o,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,n,i.z,o,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new t.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(e.resourceTiming=i.resourceTiming[this.id]),this.fire(new t.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,i){const r=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(r,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((t,o)=>(delete e.request,e.unloadVectorData(),e.aborted?i(null):t?i(t):(e.loadVectorData(o,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends zt{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:zt,canvas:class extends zt{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends t.Evented{constructor(e,i,r,o){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(o),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new t.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new t.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new U(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.coveringTiles=this._coveringTiles.bind(this),t.extend(this,t.pick(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return t.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:i,z:r}=t.canonical;return this._implementation.hasTile({x:e,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const{x:r,y:o,z:n}=e.tileID.canonical,s=new t.window.AbortController,a=this._implementation.loadTile({x:r,y:o,z:n},{signal:s.signal});if(!a)return this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null);a.cancel=()=>s.abort(),e.request=a.then(function(r){return delete e.request,e.aborted?(e.state="unloaded",i(null)):r?function(e){return e instanceof t.window.ImageData||e instanceof t.window.ImageBitmap||e instanceof t.window.HTMLCanvasElement}(r)?(this.loadTileData(e,r),e.state="loaded",void i(null)):(e.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",i(t))}))}loadTileData(t,e){Mt.loadTileData(t,e,this._map.painter)}unloadTileData(t){Mt.unloadTileData(t,this._map.painter)}prepareTile(t){if(!this._implementation.prepareTile)return null;const{x:e,y:i,z:r}=t.tileID.canonical,o=this._implementation.prepareTile({x:e,y:i,z:r});return o?(this.loadTileData(t,o),t.state="loaded",o):null}unloadTile(t,e){if(this.unloadTileData(t),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z})))}_update(){this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Pt=function(e,i,r,o){const n=new kt[i.type](e,i,r,o);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],n),n};function Dt(e,i){const r=t.identity([]);return t.scale(r,r,[.5*e.width,.5*-e.height,1]),t.translate(r,r,[1,-1,0]),t.multiply(r,r,e.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}function Lt(t,e,i,r,o,n,s,a=!1){const l=t.tilesIn(r,s,a);l.sort(Rt);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r,o,n,Dt(t.transform,r.tile.tileID),a)});const u=function(t){const e={},i={};for(const r of t){const t=r.queryResults,o=r.wrappedTileID,n=i[o]=i[o]||{};for(const i in t){const r=t[i],o=n[i]=n[i]||{},s=e[i]=e[i]||[];for(const t of r)o[t.featureIndex]||(o[t.featureIndex]=!0,s.push(t))}}return e}(c);for(const e in u)u[e].forEach((e=>{const i=e.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?t.getFeatureState(r["source-layer"],i.id):{})}));return u}function Bt(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],o={};for(let t=0;t{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Ot]}numActive(){return Object.keys(this.active).length}}let Vt;function jt(){return Vt||(Vt=new Ut),Vt}function Nt(e,i){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(r[t]=i[t])})),r}function Gt(t){t=t.slice();const e=Object.create(null);for(let i=0;i0?(o-s)/a:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}class Qt{constructor(t,e,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||r<0||e>this.height)return!o&&[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(o)return!0;for(let t=0;t0:s}_queryCircle(t,e,i,r,o){const n=t-i,s=t+i,a=e-i,l=e+i;if(s<0||n>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(n,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},o),r?c.length>0:c}query(t,e,i,r,o){return this._query(t,e,i,r,!1,o)}hitTest(t,e,i,r,o){return this._query(t,e,i,r,!0,o)}hitTestCircle(t,e,i,r){return this._queryCircle(t,e,i,!0,r)}_queryCell(t,e,i,r,o,n,s,a){const l=s.seenUids,c=this.boxCells[o];if(null!==c){const o=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(t<=o[c+2]&&e<=o[c+3]&&i>=o[c+0]&&r>=o[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[u],x1:o[c],y1:o[c+1],x2:o[c+2],y2:o[c+3]})}}}const u=this.circleCells[o];if(null!==u){const o=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],t,e,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return n.push(!0),!0;{const t=o[u],e=o[u+1],i=o[u+2];n.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,r,o,n,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[o];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return n.push(!0),!0}}const h=this.circleCells[o];if(null!==h){const t=this.circles;for(const e of h)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return n.push(!0),!0}}}_forEachCell(t,e,i,r,o,n,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(o.call(this,t,e,i,r,this.xCellCount*l+p,n,s,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,o,n){const s=r-t,a=o-e,l=i+n;return l*l>s*s+a*a}_circleAndRectCollide(t,e,i,r,o,n,s){const a=(n-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(s-o)/2,u=Math.abs(e-(o+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=i*i}}const te=Math.tan(85*Math.PI/180);function ee(e,i,r,o,n,s,a){const l=t.create();if(r)if("globe"===s.name){const e=t.calculateGlobeLabelMatrix(n,i);t.multiply(l,l,e)}else{const e=y([],a);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3],o||t.rotateZ(l,l,n.angle)}else t.multiply(l,n.labelPlaneMatrix,e);return l}function ie(t,e,i,r,o,n,s){const a=ee(t,e,i,r,o,n,s);return"globe"===n.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function re(e,i,r,o,n,s,a){if(r){if("globe"===s.name){const l=ee(e,i,r,o,n,s,a);return t.invert(l,l),t.multiply(l,e,l),l}{const i=t.clone(e),r=t.identity([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],t.multiply(i,i,r),o||t.rotateZ(i,i,-n.angle),i}}return n.glCoordMatrix}function oe(e,i,r=0){const o=[e.x,e.y,r,1];r?t.transformMat4$1(o,o,i):ge(o,o,i);const n=o[3];return{point:[o[0]/n,o[1]/n,o[2]/n],signedDistanceFromCamera:n}}function ne(e,i){const r=[e[0],e[1],e[2],1];t.transformMat4$1(r,r,i);const o=r[3];return{point:[r[0]/o,r[1]/o,r[2]/o],signedDistanceFromCamera:o}}function se(t,e){return Math.min(.5+t/e*.5,1.5)}function ae(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function le(e,i,r,o,n,s,a,l,c,u){const h=r.transform,p=o?e.textSizeData:e.iconSizeData,d=t.evaluateSizeForZoom(p,r.transform.zoom),f="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=o?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=o?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,x=o?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b=!1;for(let o=0;oMath.abs(r.x-i.x)*o?{useVertical:!0}:e.writingMode===t.WritingMode.vertical?i.yte}(i,r,o)?1===e.flipState?{needsFlipping:!0}:null:i.x>r.x?{needsFlipping:!0}:null}function he(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x){const v=i/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v;let T;if(e.numGlyphs>1){const i=e.glyphStartIndex+e.numGlyphs,n=e.lineStartIndex,u=e.lineStartIndex+e.lineLength,h=ce(v,l,b,w,r,p,d,e,c,s,f,_,!1,g,y,x);if(!h)return{notEnoughRoom:!0};const E=ne(h.first.point,a).point,S=ne(h.last.point,a).point,C=new t.pointGeometry(E[0],E[1]),M=new t.pointGeometry(S[0],S[1]);if(o&&!r){const t=ue(e,C,M,m);if(e.flipState=t&&t.needsFlipping?1:2,t)return t}T=[h.first];for(let t=e.glyphStartIndex+1;t0?s.point:de(d,o,i,1,n,void 0,g,y.canonical),l=ue(e,new t.pointGeometry(i[0],i[1]),new t.pointGeometry(a[0],a[1]),m);if(e.flipState=l&&l.needsFlipping?1:2,l)return l}const i=fe(v*l.getoffsetX(e.glyphStartIndex),b,w,r,p,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,s,f,_,!1,!1,g,y,x);if(!i)return{notEnoughRoom:!0};T=[i]}if(h)for(const e of T)t.updateGlobeVertexNormal(h,u.length+0,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+1,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+2,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+3,e.up[0],e.up[1],e.up[2]),t.addDynamicAttributes(u,e.point[0],e.point[1],e.point[2],e.angle);else for(const e of T)t.addDynamicAttributes(u,e.point[0],e.point[1],e.point[2],e.angle);return{}}function pe(e,i,r,o,n){const s=o.projectTilePoint(e.x,e.y,i);if(!n)return oe(s,r,s.z);const a=n(e);return oe(new t.pointGeometry(s.x+a[0],s.y+a[1]),r,s.z+a[2])}function de(e,i,r,o,n,s,a,l){const c=pe(e.add(e.sub(i)._unit()),l,n,a,s).point,u=t.sub([],r,c);return t.scaleAndAdd([],r,u,o/t.length(u))}function fe(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y){const x=o?e-i:e+i;let v=x>0?1:-1,b=0;o&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=v>0?l+a:l+a+1,T=n,E=n,S=0,C=0;const M=Math.abs(x),A=[],I=[];let z=s;const k=()=>{const e=w-v;return 0===S?s:new t.pointGeometry(u.getx(e),u.gety(e))},P=()=>de(k(),z,E,M-S+1,h,d,_,g.canonical);for(;S+C<=M;){if(w+=v,w=c)return null;if(E=T,A.push(T),f&&I.push(z||k()),T=p[w],void 0===T){z=new t.pointGeometry(u.getx(w),u.gety(w));const e=pe(z,g.canonical,h,_,d);T=e.signedDistanceFromCamera>0?p[w]=e.point:P()}else z=null;S+=C,C=t.distance(E,T)}z=z||new t.pointGeometry(u.getx(w),u.gety(w));const D=k();m&&d&&(p[w]=T=void 0===p[w]?T:P(),C=t.distance(E,T));const L=(M-S)/C,B=z.sub(D).mult(L)._add(D),R=t.sub([],T,E),F=t.scaleAndAdd([],E,R,L);let O=[0,0,1],U=R[0],V=R[1];if(y&&(O=_.upVector(g.canonical,B.x,B.y),0!==O[0]||0!==O[1]||1!==O[2])){const e=[1,0,0],i=[0,1,0];e[0]=O[2],e[1]=0,e[2]=-O[0],t.cross(i,O,e),t.normalize(e,e),t.normalize(i,i),U=t.dot(R,e),V=t.dot(R,i)}if(r){const e=t.cross([],O,R);t.normalize(e,e),t.scaleAndAdd(F,F,e,r*v)}const j=b+Math.atan2(V,U);return A.push(F),f&&I.push(B),{point:F,angle:j,path:A,tilePath:I,up:O}}const me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _e(t,e){for(let i=0;i0,t.getProjection()),f=n*d.perspectiveRatio,m=(i.x1*e+r.x-i.padding)*f+d.point.x,_=(i.y1*e+r.y-i.padding)*f+d.point.y,g=(i.x2*e+r.x+i.padding)*f+d.point.x,y=(i.y2*e+r.y+i.padding)*f+d.point.y,x=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!o&&this.grid.hitTest(m,_,g,y,a)||x?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,e.getProjection()):t=>[0,0,0],x=new t.pointGeometry(r.tileAnchorX,r.tileAnchorY),v=e.getProjection().projectTilePoint(r.tileAnchorX,r.tileAnchorY,m.canonical),b=y(x),w=[v.x+b[0],v.y+b[1],v.z+b[2]],T="globe"===e.projection.name,E=this.projectAndGetPerspectiveRatio(a,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,e.getProjection()),{perspectiveRatio:S}=E,C=(h?s/S:s*S)/t.ONE_EM,M=oe(new t.pointGeometry(w[0],w[1]),l,w[2]).point,A=E.signedDistanceFromCamera>0?ce(C,n,r.lineOffsetX*C,r.lineOffsetY*C,!1,M,x,r,o,l,{},g&&!h?y:null,h&&!!g,e.getProjection(),m,h):null;let I=!1,z=!1,k=!0;if(A&&!E.occluded){const e=.5*d*S+f,r=new t.pointGeometry(-100,-100),o=new t.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new Jt,s=A.first,a=A.last;let l=[];for(let t=s.path.length-1;t>=1;t--)l.push(s.path[t]);for(let t=1;t{const i=y(ene(t,c));l=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let m=[];if(l.length>0){const e=l.map((e=>new t.pointGeometry(e[0],e[1])));let i=1/0,n=-1/0,s=1/0,a=-1/0;for(let t=0;t=r.x&&n<=o.x&&s>=r.y&&a<=o.y?[e]:no.x||ao.y?[]:t.clipLine([e],r.x,r.y,o.x,o.y)}for(const t of m){n.reset(t,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/h)+1;for(let t=0;t0){t.transformMat4$1(s,s,e);const o="globe"===n.name;this.fogState&&r&&!o&&(a=function(e,i,r,o,n,s){const a=s.calculateFogTileMatrix(n),l=[i,r,o];return t.transformMat4(l,l,a),M(e,l,s.pitch,s._fov)}(this.fogState,i[0],i[1],i[2],r.toUnwrapped(),this.transform)>.9)}else ge(s,s,e);return{point:new t.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+ye,(-s[1]/s[3]+1)/2*this.transform.height+ye),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(n)/s[3]*.5,1.5),signedDistanceFromCamera:s[3],occluded:o&&s[2]>s[3]||a}}isOffscreen(t,e,i,r){return i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t=0&&et.collisionGroupID===e}}return this.collisionGroups[t]}}function Ie(e,i,r,o,n){const{horizontalAlign:s,verticalAlign:a}=t.getAnchorAlignment(e),l=-(s-.5)*i,c=-(a-.5)*r,u=t.evaluateVariableOffset(e,o);return new t.pointGeometry(l+u[0]*n,c+u[1]*n)}function ze(e,i,r,o,n){const s=new t.pointGeometry(e,i);return r&&s._rotate(o?n:-n),s}class ke{constructor(t,e,i,r,o){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new xe(this.transform,o),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new Ae(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,r,o){const n=r.getBucket(i),s=r.latestFeatureIndex;if(!n||!s||i.id!==n.layerIds[0])return;const a=n.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(n.projection);const p=(d=r.tileID,f=n.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):ve(m,f,d));var d,f,m;const _="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),v=this.transform.calculatePixelsToTileUnitsMatrix(r),b=ie(p,r.tileID.canonical,_,g,this.transform,n.getProjection(),v);let w=null;if(_){const e=re(p,r.tileID.canonical,_,g,this.transform,n.getProjection(),v);w=t.multiply([],this.transform.labelPlaneMatrix,e)}let T=null;y&&r.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:x,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Me(n.bucketInstanceId,s,n.sourceLayerIndex,n.index,r.tileID);const E={bucket:n,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(o)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:E})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:E})}attemptAnchorPlacement(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g){const y=[h.textOffset0,h.textOffset1],x=Ie(t,i,r,y,o),v=this.collisionIndex.placeCollisionBox(d,o,e,ze(x.x,x.y,n,s,this.transform.angle),u,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,ze(x.x,x.y,n,s,this.transform.angle),u,a,l,c.predicate).box.length)&&v.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(e=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:o,prevAnchor:e},this.markUsedJustification(d,t,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(e,i,r,o){const{bucket:n,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(n.projection);let S=x&&(v||!n.hasIconData()||y),C=v&&(x||!n.hasTextData()||g);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),r&&o&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const M=(e,o,d)=>{if(u){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let o=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[n.bucketInstanceId];o=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(r,o,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new t.pointGeometry(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[e.crossTileID]=new Se(!1,!1,!1,!0),void(i[e.crossTileID]=!0)}if(i[e.crossTileID])return;if(p)return void(this.placements[e.crossTileID]=new Se(!1,!1,!1));let E=!1,M=!1,A=!0,I=!1,z=!1,k=null,P={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},L=null,B=null,R=null,F=0,O=0,U=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(O=d.verticalTextFeatureIndex);const V=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID,(this.transform.elevation||t.elevation)&&(t.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[n.bucketInstanceId].tileID,t.tileAnchorX,t.tileAnchorY):0)},j=d.textBox;if(j){V(j);const i=i=>{let r=t.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},r=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of n.writingModes)if(e===t.WritingMode.vertical?(P=r(),D=P):P=i(),P&&P.box&&P.box.length)break}else P=i()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];l.indexOf(t.anchor)>0&&(l=l.filter((e=>e!==t.anchor)),l.unshift(t.anchor))}const c=(t,i,r)=>{const s=n.getSymbolInstanceTextSize(f,e,this.transform.zoom,o),c=(t.x2-t.x1)*s+2*t.padding,u=(t.y2-t.y1)*s+2*t.padding,p=T&&!v?i:null;p&&V(p);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,e,o,n,r,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,k=g.shift;break}}return d};r((()=>c(j,d.iconBox,t.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return i&&V(i),n.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&e.numVerticalGlyphVertices>0&&i?c(i,d.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),P&&(E=P.box,A=P.offscreen,I=P.occluded);const u=i(P&&P.box);if(!E&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,u))}}else{const s=(i,r)=>{const s=n.getSymbolInstanceTextSize(f,e,this.transform.zoom,o),l=this.collisionIndex.placeCollisionBox(n,s,i,new t.pointGeometry(0,0),x,h,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(n,r,e),this.placedOrientations[e.crossTileID]=r),l};r((()=>s(j,t.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?(V(i),s(i,t.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(P&&P.box&&P.box.length)}}if(L=P,E=L&&L.box&&L.box.length>0,A=L&&L.offscreen,I=L&&L.occluded,e.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),o=t.evaluateSizeForFeature(n.textSizeData,f,i),u=s.get("text-padding");B=this.collisionIndex.placeCollisionCircles(n,x,i,n.lineVertexArray,n.glyphOffsetArray,o,a,l,c,r,w,_.predicate,e.collisionCircleDiameter*o/t.ONE_EM,u,this.retainedQueryData[n.bucketInstanceId].tileID),E=x||B.circles.length>0&&!B.collisionDetected,A=A&&B.offscreen,I=B.occluded}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>{V(e);const i=T&&k?ze(k.x,k.y,b,w,this.transform.angle):new t.pointGeometry(0,0),r=n.getSymbolInstanceIconSize(m,this.transform.zoom,o);return this.collisionIndex.placeCollisionBox(n,r,e,i,v,h,a,_.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(R=e(d.verticalIconBox),M=R.box.length>0):(R=e(d.iconBox),M=R.box.length>0),A=A&&R.offscreen,z=R.occluded}const N=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,G=y||0===e.numIconVertices;if(N||G?G?N||(M=M&&E):E=M&&E:M=E=M&&E,E&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,s.get("text-ignore-placement"),n.bucketInstanceId,D&&D.box&&O?O:F,_.ID),M&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),n.bucketInstanceId,U,_.ID),B&&(E&&this.collisionIndex.insertCollisionCircles(B.circles,s.get("text-ignore-placement"),n.bucketInstanceId,F,_.ID),r)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Ce);for(let t=0;t=0;--e){const i=t[e];M(n.symbolInstances.get(i),i,n.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=n>=0&&t!==n?0:r.crossTileID)}markUsedOrientation(e,i,r){const o=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,n=i===t.WritingMode.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,o=e?e.opacities:{},n=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],n=o[t];n?(this.opacities[t]=new Ee(n,r,e.text,e.icon,null,e.clipped),i=i||e.text!==n.text.placed||e.icon!==n.icon.placed):(this.opacities[t]=new Ee(null,r,e.text,e.icon,e.skipFade,e.clipped),i=i||e.text||e.icon)}for(const t in o){const e=o[t];if(!this.opacities[t]){const o=new Ee(e,r,!1,!1);o.isHidden()||(this.opacities[t]=o,i=i||e.text.placed||e.icon.placed)}}for(const t in n)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=n[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0].layout,n=!!e.layers[0].dynamicFilter(),s=new Ee(null,0,!1,!1,!0),a=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),c=o.get("text-variable-anchor"),u="map"===o.get("text-rotation-alignment"),h="map"===o.get("text-pitch-alignment"),p="none"!==o.get("icon-text-fit"),d=new Ee(null,0,a&&(l||!e.hasIconData()||o.get("icon-optional")),l&&(a||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const f=(t,e,i)=>{for(let r=0;r0||l>0,x=o.numIconVertices>0,v=this.placedOrientations[o.crossTileID],b=v===t.WritingMode.vertical,w=v===t.WritingMode.horizontal||v===t.WritingMode.horizontalOnly;if(!y&&!x||g.isHidden()||m++,y){const t=Ve(g.text);f(e.text,a,b?je:t),f(e.text,l,w?je:t);const i=g.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||b?1:0)})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o))}if(x){const t=Ve(g.icon);o.placedIconSymbolIndex>=0&&(f(e.icon,o.numIconVertices,b?je:t),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=g.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(f(e.icon,o.numVerticalIconVertices,w?je:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[r];if(i){let r=new t.pointGeometry(0,0),o=!0;if(i.textBox||i.verticalTextBox){if(c){const t=this.variableOffsets[_];t?(r=Ie(t.anchor,t.width,t.height,t.textOffset,t.textScale),u&&r._rotate(h?this.transform.angle:-this.transform.angle)):o=!1}n&&(o=!g.clipped),i.textBox&&Pe(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||b,r.x,r.y),i.verticalTextBox&&Pe(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||w,r.x,r.y)}const s=o&&Boolean(!w&&i.verticalIconBox);i.iconBox&&Pe(e.iconCollisionBox.collisionVertexArray,g.icon.placed,s,p?r.x:0,p?r.y:0),i.verticalIconBox&&Pe(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,p?r.x:0,p?r.y:0)}}}if(e.fullyClipped=0===m,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Pe(t,e,i,r,o){t.emplaceBack(e?1:0,i?1:0,r||0,o||0),t.emplaceBack(e?1:0,i?1:0,r||0,o||0),t.emplaceBack(e?1:0,i?1:0,r||0,o||0),t.emplaceBack(e?1:0,i?1:0,r||0,o||0)}const De=Math.pow(2,25),Le=Math.pow(2,24),Be=Math.pow(2,17),Re=Math.pow(2,16),Fe=Math.pow(2,9),Oe=Math.pow(2,8),Ue=Math.pow(2,1);function Ve(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*De+e*Le+i*Be+e*Re+i*Fe+e*Oe+i*Ue+e}const je=0;class Ne{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,o){const n=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex{const e=t.exported.now()-o;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=o)&&(!t.maxzoom||t.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new Ne(t)),this._inProgressLayer.continuePlacement(r[t.source],this.placement,this._showCollisionBoxes,t,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Ze=512/t.EXTENT/2;class $e{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;it.overscaledZ)for(const i in o){const n=o[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{const n=o[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const He=(e,i)=>t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),Ye=t.pick(Zt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Ke=t.pick(Zt,["setCenter","setZoom","setBearing","setPitch"]),Je={version:8,layers:[],sources:{}},Qe={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class ti extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new P(jt(),this),this.imageManager=new v,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(e._requestManager,i.localFontFamily?t.LocalGlyphMode.all:i.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new t.LineAtlas(256,512),this.crossTileSymbolIndex=new We,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const r=this;this._rtlTextPluginCallback=ti.registerForPluginStateChange((e=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in r._sourceCaches){const e=r._sourceCaches[t],i=e.getSource().type;"vector"!==i&&"geojson"!==i||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,i.accessToken);const o=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(o,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,r)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Je,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(e,i){if(i&&He(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=t.clone$1(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const r=Gt(this.stylesheet.layers);this._order=r.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let e of r)e=t.createStyleLayer(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(e){this._spriteRequest=function(e,i,r){let o,n,s;const a=t.exported.devicePixelRatio>1?"@2x":"";let l=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,a,".json"),t.ResourceType.SpriteJSON),((t,e)=>{l=null,s||(s=t,o=e,u())})),c=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,a,".png"),t.ResourceType.SpriteImage),((t,e)=>{c=null,s||(s=t,n=e,u())}));function u(){if(s)r(s);else if(o&&n){const e=t.exported.getImageData(n),i={};for(const r in o){const{width:n,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=o[r],f=new t.RGBAImage({width:n,height:s});t.RGBAImage.copy(e,f,{x:a,y:l},{x:0,y:0},{width:n,height:s}),i[r]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.getSource(e.source);if(!i)return;const r=e.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&Qe[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const r=this.map.painter;if(r){const t=i.getProgramIds();if(!t)continue;const o=i.getProgramConfiguration(e.zoom);for(const e of t)r.useProgram(e,o)}}for(const e in r){const i=this._sourceCaches[e];r[e]!==i.used&&i.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(i){if(this._checkLoaded(),He(this,t.validateStyle(i)))return!1;(i=t.clone$1(i)).layers=Gt(i.layers);const r=function(t,i){if(!t)return[{command:Zt.setStyle,args:[i]}];let r=[];try{if(!e(t.version,i.version))return[{command:Zt.setStyle,args:[i]}];e(t.center,i.center)||r.push({command:Zt.setCenter,args:[i.center]}),e(t.zoom,i.zoom)||r.push({command:Zt.setZoom,args:[i.zoom]}),e(t.bearing,i.bearing)||r.push({command:Zt.setBearing,args:[i.bearing]}),e(t.pitch,i.pitch)||r.push({command:Zt.setPitch,args:[i.pitch]}),e(t.sprite,i.sprite)||r.push({command:Zt.setSprite,args:[i.sprite]}),e(t.glyphs,i.glyphs)||r.push({command:Zt.setGlyphs,args:[i.glyphs]}),e(t.transition,i.transition)||r.push({command:Zt.setTransition,args:[i.transition]}),e(t.light,i.light)||r.push({command:Zt.setLight,args:[i.light]}),e(t.fog,i.fog)||r.push({command:Zt.setFog,args:[i.fog]}),e(t.projection,i.projection)||r.push({command:Zt.setProjection,args:[i.projection]});const o={},n=[];!function(t,i,r,o){let n;for(n in i=i||{},t=t||{})t.hasOwnProperty(n)&&(i.hasOwnProperty(n)||qt(n,r,o));for(n in i)i.hasOwnProperty(n)&&(t.hasOwnProperty(n)?e(t[n],i[n])||("geojson"===t[n].type&&"geojson"===i[n].type&&Wt(t,i,n)?r.push({command:Zt.setGeoJSONSourceData,args:[n,i[n].data]}):Xt(n,i,r,o)):$t(n,i,r))}(t.sources,i.sources,n,o);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&o[t.source]?r.push({command:Zt.removeLayer,args:[t.id]}):s.push(t)}));let a=t.terrain;a&&o[a.source]&&(r.push({command:Zt.setTerrain,args:[void 0]}),a=void 0),r=r.concat(n),e(a,i.terrain)||r.push({command:Zt.setTerrain,args:[i.terrain]}),function(t,i,r){i=i||[];const o=(t=t||[]).map(Yt),n=i.map(Yt),s=t.reduce(Kt,{}),a=i.reduce(Kt,{}),l=o.slice(),c=Object.create(null);let u,h,p,d,f,m,_;for(u=0,h=0;u!(t.command in Ke)));if(0===r.length)return!1;const o=r.filter((t=>!(t.command in Ye)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((t=>t.command)).join(", ")}.`);return r.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=i,this._updateMapProjection(),!0}addImage(e,i){return this.getImage(e)?this.fire(new t.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,i),this._afterImageUpdated(e),this)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new t.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateSource,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=Pt(e,i,this.dispatcher,this);o.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:o.serialize(),sourceId:e})));const n=i=>{const r=(i?"symbol:":"other:")+e,n=this._sourceCaches[r]=new t.SourceCache(r,o,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[e]=n,n.style=this,n.onAdd(this.map)};n(!1),"vector"!==i.type&&"geojson"!==i.type||n(!0),o.onAdd&&o.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const i=this.getSource(e);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(e);for(const e of r)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${o}" already exists on this map`)));let n;if("custom"===e.type){if(He(this,t.validateCustomStyleLayer(e)))return;n=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(o,e.source),e=t.clone$1(e),e=t.extend(e,{source:o})),this._validate(t.validateLayer,`layers.${o}`,e,{arrayIndex:-1},r))return;n=t.createStyleLayer(e),this._validateLayer(n),n.setEventedParent(this,{layer:{id:o}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=n;const a=this._getLayerSourceCache(n);if(this._removedLayers[o]&&n.source&&a&&"custom"!==n.type){const t=this._removedLayers[o];delete this._removedLayers[o],t.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",a.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,r,o={}){this._checkLoaded();const n=this.getLayer(i);if(n){if(!e(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(t.validateFilter,`layers.${n.id}.filter`,r,{layerType:n.type},o)||(n.filter=t.clone$1(r),this._updateLayer(n)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const i=this.getLayer(e);return i&&t.clone$1(i.filter)}setLayoutProperty(i,r,o,n={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getLayoutProperty(r),o)||(s.setLayoutProperty(r,o,n),this._updateLayer(s)):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(i,r,o,n={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getPaintProperty(r),o)||(s.setPaintProperty(r,o,n)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){const i=this.getLayer(t);return i&&i.getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,n=this.getSource(r);if(!n)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const s=n.type;if("geojson"===s&&o)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!o)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(r);for(const t of a)t.setFeatureState(o,e.id,i)}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.getSource(r);if(!o)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const n=o.type,s="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(r);for(const t of a)t.removeFeatureState(s,e.id,i)}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.getSource(i);if(o){if("vector"!==o.type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:e,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const n=this._order[o];if(e(n)){i[n]=o;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const o=[];for(let n=this._order.length-1;n>=0;n--){const s=this._order[n];if(e(s))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),a=L.createFromScreenPoints(e,r);for(const t in this._sourceCaches){const e=this._sourceCaches[t].getSource().id;i.layers&&!o[e]||n.push(Lt(this._sourceCaches[t],this._layers,this._serializedLayers,a,i,r,s,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(t,e,i,r,o,n,s){const a={},l=n.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(Rt);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],o=r[t];o.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of o)e.push(t)}}for(const e in a)a[e].forEach((r=>{const o=r.feature,n=i(t[e]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=n}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateFilter,"querySourceFeatures.filter",i.filter,null,i);const r=this._getSourceCaches(e);let o=[];for(const t of r)o=o.concat(Bt(t,i));return o}addSourceType(t,e,i){return ti.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(ti.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const i in t)if(!e(t[i],r[i])){o=!0;break}if(!o)return;const n=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(t,i),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,r=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===r){if("object"==typeof i.source){const e="terrain-dem-src";this.addSource(e,i.source),i=t.clone$1(i),i=t.extend(i,{source:e})}if(this._validate(t.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode)this._createTerrain(i,r);else{const r=this.terrain,o=r.get();for(const e of Object.keys(t.spec.terrain))!i.hasOwnProperty(e)&&t.spec.terrain[e].default&&(i[e]=t.spec.terrain[e].default);for(const t in i)if(!e(i[t],o[t])){r.set(i),this.stylesheet.terrain=i;const t=this._setTransitionParameters({duration:0});r.updateTransitions(t);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new k(t,this.map.transform);this.stylesheet.fog=t;const i=this._setTransitionParameters({duration:0});e.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,r=i.get();0===Object.keys(t).length&&i.set(t);for(const o in t)if(!e(t[o],r[o])){i.set(t),this.stylesheet.fog=t;const e=this._setTransitionParameters({duration:0});i.updateTransitions(e);break}}else this._createFog(t);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:t.exported.now(),transition:t.extend(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const i=this.terrain=new C(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(e,i,r,o,n={}){return(!n||!1!==n.validate)&&He(this,e.call(t.validateStyle,t.extend({key:i,style:this.serialize(),value:r,styleSpec:t.spec},o)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(e,i,r,o,n=!1){let s=!1,a=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng,e.projection);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new Ge(e,this._order,n,i,r,o,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};r(this._otherSourceCaches[e.source]),r(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,r){return t.makeRequest(i,r)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(e){const i=this._getSourceCaches(e);return 0===i.length?(this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):i.every((t=>t.loaded()))}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}ti.getSourceType=function(t){return kt[t]},ti.setSourceType=function(t,e){kt[t]=e},ti.registerForPluginStateChange=t.registerForPluginStateChange;var ei="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",ii="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let ri={},oi={};ri=ci("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),oi=ci("#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const ni=ci("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),si=ei,ai="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var li={background:ci("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:ci("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:ci("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:ci("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ci("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:ci("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:ci("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ci("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ci("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:ci("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:ci("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:ci("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:ci("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ci("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:ci("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:ci("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:ci("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:ci("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:ci("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:ci("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:ci("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxGradient:ci("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxCapture:ci("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector.xyz*height;vec4 globe=u_globe_matrix*vec4(globe_pos,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:ci("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function ci(t,e,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,n=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=t.match(o),a=e.match(o),l=ei.match(o);let c=a?a.concat(s):s;i||(ri.staticUniforms&&(c=ri.staticUniforms.concat(c)),oi.staticUniforms&&(c=oi.staticUniforms.concat(c))),c&&(c=c.concat(l));const u={};return{fragmentSource:t=t.replace(r,((t,e,i,r,o)=>(u[o]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:e=e.replace(r,((t,e,i,r,o)=>{const n="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":n;return u[o]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${n} a_${o};\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${n} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:n,staticUniforms:c}}class ui{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,o,n,s,a,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t{const o=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:hi(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:o,u_highlight:n,u_accent:s}})(e,r,o,e.terrain?i.projMatrix:null);e.prepareDrawProgram(l,h,i.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(r);h.draw(l,c.TRIANGLES,n,s,a,t.CullFaceMode.disabled,p,o.id,d,f,m)}function di(e,i,r){if(!i.needsDEMTextureUpload)return;const o=e.context,n=o.gl;o.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new t.Texture(o,s,n.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function fi(e,i,r,o,n,s){const a=e.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),di(e,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=i.fbo;if(!h){const e=new t.Texture(a,{width:u,height:u,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=i.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(e.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,o,n,s,t.CullFaceMode.disabled,((e,i)=>{const r=i.stride,o=t.create();return t.ortho(o,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(o,o,[0,-t.EXTENT,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),r.id,p,d,f),i.needsHillshadePrepare=!1}const mi=(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image0:new t.Uniform1i(e,i.u_image0),u_skirt_height:new t.Uniform1f(e,i.u_skirt_height)}),_i=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),gi=(t,e,i,r,o,n,s,a,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:o,u_merc_center:n,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function yi(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const xi=new class{constructor(){this.operations={}}newMorphing(t,e,i,r,o){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:r,phase:0,duration:o,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},vi={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bi(t,e){const i=1<({u_matrix:t});function Ti(e,i,r,o,n){if(n>0){const s=t.exported.now(),a=(s-e.timeAdded)/n,l=i?(s-i.timeAdded)/n:-1,c=r.getSource(),u=o.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),p=h&&e.refreshedUponExpiration?1:t.clamp(h?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Ei extends t.SourceCache{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new P(jt(),null),r=Pt("mock-dem",e,i,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class Si extends t.SourceCache{constructor(t){const e=Pt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new P(jt(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,i,r){if(e.freezeTileCoverage)return;this.transform=e;const o=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){const i=new t.Tile(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom);i.state="loaded",this._tiles[r.key]=i}return i}),{});for(const t in this._tiles)t in o||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ci extends t.OverscaledTileID{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class Mi extends t.Elevation{constructor(e,i){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,o,n]=function(e){const i=new t.StructArrayLayout4i8,r=new t.StructArrayLayout3ui6,o=131;i.reserve(17161),r.reserve(33800);const n=t.EXTENT/128,s=t.EXTENT+n/2,a=s+n;for(let e=-n;es||e<0||e>s?24575:0,n=t.clamp(Math.round(r),0,t.EXTENT),a=t.clamp(Math.round(e),0,t.EXTENT);i.emplaceBack(n+o,a,n,a)}const l=(t,e)=>{const i=e*o+t;r.emplaceBack(i+1,i,i+o),r.emplaceBack(i+o,i+o+1,i+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)l(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)l(e,t),l(t,e)})),[i,r,32768]}(),s=e.context;this.gridBuffer=s.createVertexBuffer(r,t.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(o),this.gridSegments=t.SegmentVector.simpleSegment(0,0,r.length,o.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,r.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Si(i.map),this.orthoMatrix=t.create(),t.ortho(this.orthoMatrix,0,t.EXTENT,0,t.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new t.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ei(i.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(e,i,r){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const o=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(o.get("source")),this._exaggeration=o.get("exaggeration");const n=()=>{this.sourceCache.used&&t.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(i,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),i.updateElevation(!r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&t.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const o=this.proxyCoords=i.getIds().map((t=>{const e=i.getTileByID(t).tileID;return e.projMatrix=r.calculateProjMatrix(e.toUnwrapped()),e}));!function(e,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),o=new t.pointGeometry(r.x,r.y);e.sort(((e,i)=>{if(i.overscaledZ-e.overscaledZ)return i.overscaledZ-e.overscaledZ;const r=new t.pointGeometry(e.canonical.x+(1<{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const t in s){const i=s[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],n),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=o.map((t=>new Ci(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(o),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],o=r.dem;!o||r.demTexture&&!r.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),di(this.painter,r,o))}}_prepareDemTileUniforms(t,e,i,r){if(!e||null==e.demTexture)return!1;const o=t.tileID.canonical,n=Math.pow(2,e.tileID.canonical.z-o.z),s=r||"";return i[`u_dem_tl${s}`]=[o.x*n%1,o.y*n%1],i[`u_dem_scale${s}`]=n,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,i=e.gl;if(!this._emptyDepthBufferTexture){const r=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(e,r,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const r=i.dem.tree.minimums[0];return r>0&&t++,e+r}),0);return t?e/t:0}_updateEmptyDEMTexture(){const e=this.painter.context,i=e.gl;e.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),o=new t.RGBAImage({width:1,height:1},new Uint8Array(t.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(o,{premultiply:!1}):n=this._emptyDEMTexture=new t.Texture(e,o,i.RGBA,{premultiply:!1}),n}setupElevationDraw(e,i,r){const o=this.painter.context,n=o.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(a),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection,u=e.tileID.canonical;s.u_tile_tl_up=c.upVector(u,0,0),s.u_tile_tr_up=c.upVector(u,t.EXTENT,0),s.u_tile_br_up=c.upVector(u,t.EXTENT,t.EXTENT),s.u_tile_bl_up=c.upVector(u,0,t.EXTENT),s.u_tile_up_scale=r&&r.useDenormalizedUpVectorScale?t.GLOBE_METERS_TO_ECEF:c.upVectorScale(u,l.center.lat,l.worldSize).metersToTile;let h=null,p=null,d=1;if(r&&r.morphing&&this._useVertexMorphing){const t=r.morphing.srcDemTile,i=r.morphing.dstDemTile;d=r.morphing.phase,t&&i&&(this._prepareDemTileUniforms(e,t,s,"_prev")&&(p=t),this._prepareDemTileUniforms(e,i,s)&&(h=i))}if(p&&h?(o.activeTexture.set(n.TEXTURE2),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),o.activeTexture.set(n.TEXTURE4),p.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),s.u_dem_lerp=d):(h=this.terrainTileForTile[e.tileID.key],o.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(e,h,s)?h.demTexture:this.emptyDEMTexture).bind(n.NEAREST,n.CLAMP_TO_EDGE)),o.activeTexture.set(n.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&h){const e=(1<{if(c===t)return;const r=[vi[t],"PROJECTION_GLOBE_VIEW"];p&&r.push("CUSTOM_ANTIALIASING"),i&&r.push(vi[u]),l=e.useProgram("globeRaster",null,r),c=t},f=e.colorModeForRenderPass(),m=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);xi.update(n);const _=t.calculateGlobeMercatorMatrix(h),g=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],y=e.globeSharedBuffers,x=[h.width*t.exported.devicePixelRatio,h.height*t.exported.devicePixelRatio];if((u?[!1,!0]:[!1]).forEach((u=>{c=-1;const p=u?a.LINES:a.TRIANGLES;for(const c of o){const o=r.getTile(c),v=t.StencilMode.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];yi(b,w)&&xi.newMorphing(c.key,b,w,n,250),s.activeTexture.set(a.TEXTURE0),o.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=xi.getMorphValuesForProxy(c.key),E=T?1:0,S={useDenormalizedUpVectorScale:!0};T&&t.extend$1(S,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:t.easeCubicInOut(T.phase)}});const C=Float32Array.from(h.globeMatrix),M=t.globeTileLatLngCorners(c.canonical),A=t.getLatitudinalLod((M[0][0]+M[1][0])/2),I=t.getGridMatrix(c.canonical,M,A),z=t.globeNormalizeECEF(t.globeTileBounds(c.canonical)),k=gi(h.projMatrix,C,_,z,t.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,I);if(d(E,u),i.setupElevationDraw(o,l,S),e.prepareDrawProgram(s,l,c.toUnwrapped()),y){const[i,r,o]=u?y.getWirefameBuffers(e.context,A):y.getGridBuffers(A);l.draw(s,p,m,v,f,t.CullFaceMode.backCCW,k,"globe_raster",i,r,o)}}})),y){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),l=e.useProgram("globeRaster",null,n);for(const n of o){const{x:o,y:c,z:u}=n.canonical,p=0===c,d=c===(1<e.draw(s,a.TRIANGLES,m,t.StencilMode.disabled,f,t.CullFaceMode.disabled,gi(h.projMatrix,y,y,T,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,{}),e.prepareDrawProgram(s,l,n.toUnwrapped()),p&&E(l,_),d&&(y=t.scale(t.create(),y,[1,-1,1]),E(l,v))}}}}(e,i,r,o,n);else{const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=(t,i)=>{if(c===t)return;const r=[vi[t]];i&&r.push(vi[u]),l=e.useProgram("terrainRaster",null,r),c=t},p=e.colorModeForRenderPass(),d=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);xi.update(n);const f=e.transform,m=6*Math.pow(1.5,22-f.zoom)*i.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const _=u?a.LINES:a.TRIANGLES,[g,y]=u?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of o){const o=r.getTile(c),x=t.StencilMode.disabled,v=i.prevTerrainTileForTile[c.key],b=i.terrainTileForTile[c.key];yi(v,b)&&xi.newMorphing(c.key,v,b,n,250),s.activeTexture.set(a.TEXTURE0),o.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=xi.getMorphValuesForProxy(c.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:t.easeCubicInOut(w.phase)}});const S=_i(c.projMatrix,bi(c.canonical,f.renderWorldCopies)?m/10:m);h(T,u),i.setupElevationDraw(o,l,E),e.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,_,d,x,p,t.CullFaceMode.backCCW,S,"terrain_raster",i.gridBuffer,g,y)}}))}}(i,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,o=this.proxySourceCache,n=this.proxiedCoords[o.id],s=this._drapedRenderBatches.shift(),a=[],l=i.style.order;let c=0;for(const u of n){const n=o.getTileByID(u.proxyTileKey),h=o.proxyCachedFBO[u.key]?o.proxyCachedFBO[u.key][e]:void 0,p=void 0!==h?o.renderCache[h]:this.pool[c++],d=void 0!==h;if(n.texture=p.tex,d&&!p.dirty){a.push(n.tileID);continue}let f;r.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(r.clear({color:t.Color.transparent,stencil:0}),p.dirty=!1);for(let t=s.start;t<=s.end;++t){const e=i.style._layers[l[t]];if(e.isHidden(i.transform.zoom))continue;const o=i.style._getLayerSourceCache(e),n=o?this.proxyToSource[u.key][o.id]:[u];if(!n)continue;const s=n;r.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(o?o.id:null)&&(this._setupStencil(p,n,e,o),f=o?o.id:null),i.renderLayer(i,o,e,s)}this.renderedToTile?(p.dirty=!0,a.push(n.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,r=0,o=0,n=!1;for(let s=0;st.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((t=>t.dem)).map((r=>{const o=r.tileID,n=Math.pow(2,o.overscaledZ),{x:s,y:a}=o.canonical,l=s/n,c=(s+1)/n,u=a/n,h=(a+1)/n;return{minx:l,miny:u,maxx:c,maxy:h,t:r.dem.tree.raycastRoot(l,u,c,h,t,e,i),tile:r}}));r.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.t:Number.MAX_VALUE)));for(const o of r){if(null==o.t)return null;const r=o.tile.dem.tree.raycast(o.minx,o.miny,o.maxx,o.maxy,t,e,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,i=e.gl,r=this.drapeBufferSize;e.activeTexture.set(i.TEXTURE0);const o=new t.Texture(e,{width:r[0],height:r[1],data:null},i.RGBA);o.bind(i.LINEAR,i.CLAMP_TO_EDGE);const n=e.createFramebuffer(r[0],r[1],!1);return n.colorAttachment.set(o.texture),n.depthAttachment=new Et(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:o,dirty:!1}}_initFBOPool(){for(;this.pool.length{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom),r=e.getCrossfadeParameters(),o=!!r&&1!==r.t,n=e.hasTransition();return"custom"!==e.type&&!i&&(o||n)}))}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof Mt){t=!0;break}if(t)for(let t=0;te.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i=0;o--){const n=i[o];if(e.getTileByID(n.key),void 0!==e.proxyCachedFBO[n.key]){const i=t[n.key],o=this.proxyToSource[n.key];let s=0;for(const t in o){const e=o[t],n=i[t];if(!n||n.length!==e.length||e.some(((e,i)=>e!==n[i]||r[t]&&r[t].hasOwnProperty(e.key)))){s=-1;break}++s}for(const t in e.proxyCachedFBO[n.key])e.renderCache[e.proxyCachedFBO[n.key][t]].dirty=s<0||s!==Object.values(i).length}}const o=[...this._drapedRenderBatches];o.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of o)for(const r of i){if(e.proxyCachedFBO[r.key])continue;let i=e.renderCachePool.pop();void 0===i&&e.renderCache.length<50&&(i=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==i&&(e.proxyCachedFBO[r.key]={},e.proxyCachedFBO[r.key][t.start]=i,e.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const o=this.painter.context,n=o.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=e.length,this._overlapStencilMode.test={func:n.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:n.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(o.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(e,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):t.StencilMode.disabled}_renderTileClippingMasks(e,i){const r=this.painter,o=this.painter.context,n=o.gl;r._tileClippingMaskIDs={},o.setColorMode(t.ColorMode.disabled),o.setDepthMode(t.DepthMode.disabled);const s=r.useProgram("clippingMask");for(const a of e){const e=r._tileClippingMaskIDs[a.key]=--i;s.draw(o,n.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,wi(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(e){const i=this.painter.transform;if(e.x<0||e.x>i.width||e.y<0||e.y>i.height)return null;const r=[e.x,e.y,1,1];t.transformMat4$1(r,r,i.pixelMatrixInverse),t.scale$1(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const o=i._camera.position,n=t.mercatorZfromAltitude(1,i.center.lat),s=[o[0],o[1],o[2]/n,0],a=t.subtract([],r.slice(0,3),s);t.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(t.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=n,s):null}drawDepth(){const e=this.painter,i=e.context,r=this.proxySourceCache,o=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===o&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=i.gl,r=i.createFramebuffer(o,n,!0);i.activeTexture.set(e.TEXTURE0);const s=new t.Texture(i,{width:o,height:n,data:null},e.RGBA);s.bind(e.NEAREST,e.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,o,n);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,o,n]),function(e,i,r,o){if("globe"===e.transform.projection.name)return;const n=e.context,s=n.gl;n.clear({depth:1});const a=e.useProgram("terrainDepth"),l=new t.DepthMode(s.LESS,t.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of o){const o=r.getTile(e),c=_i(e.projMatrix,0);i.setupElevationDraw(o,a),a.draw(n,s.TRIANGLES,l,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(e,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof zt)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;e(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,i)=>{const r=e.wrap+e.canonical.x/(1<s+l.max.x||o+na+l.max.y};for(let t=0;tt.key===i.tileID.key));if(t)return t}if(i.tileID.key!==e.key){const r=e.canonical.z-i.tileID.canonical.z;let n,s,a;o=t.create();const l=i.tileID.wrap-e.wrap<0?(n=t.EXTENT>>r,s=n*((i.tileID.canonical.x<=o){const r=e.canonical.z-o;i.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,i.transform.tileZoom),s=new t.OverscaledTileID(a,e.wrap,o,e.canonical.x>>r,e.canonical.y>>r)):0!==r&&(a=o,s=new t.OverscaledTileID(a,e.wrap,o,e.canonical.x>>r,e.canonical.y>>r))}s.key!==e.key&&(c.push(s.key),r=i.getTile(s))}const u=t=>{c.forEach((e=>{o[e]=t})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&u(r.tileID.key);const t=s.calculateScaledKey(a);if(r=i.getTileByID(t),r&&r.hasData())break;const e=o[t];if(null===e)break;void 0===e?c.push(t):r=i.getTileByID(e)}return u(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let i=0;const r=new t.StructArrayLayout2ui4,o=131;for(let t=1;t<129;t++){for(let e=1;e<129;e++)i=t*o+e,r.emplaceBack(i,i+1),r.emplaceBack(i,i+o),r.emplaceBack(i+1,i+o),128===t&&r.emplaceBack(i+o,i+o+1);r.emplaceBack(i+1,i+1+o)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function Ai(t){const e=[];for(let i=0;i`#define ${t}`)));const _=m.concat(e.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ai):ai,ai,si,ni.fragmentSource,oi.fragmentSource,r.fragmentSource).join("\n"),g=m.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",si,ni.vertexSource,oi.vertexSource,ri.vertexSource,r.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,_),a.compileShader(y),a.attachShader(this.program,y);const x=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(x,g),a.compileShader(x),a.attachShader(this.program,x),this.attributes={};const v={};this.numAttributes=u.length;for(let t=0;t({u_dem:new t.Uniform1i(e,i.u_dem),u_dem_prev:new t.Uniform1i(e,i.u_dem_prev),u_dem_unpack:new t.Uniform4f(e,i.u_dem_unpack),u_dem_tl:new t.Uniform2f(e,i.u_dem_tl),u_dem_scale:new t.Uniform1f(e,i.u_dem_scale),u_dem_tl_prev:new t.Uniform2f(e,i.u_dem_tl_prev),u_dem_scale_prev:new t.Uniform1f(e,i.u_dem_scale_prev),u_dem_size:new t.Uniform1f(e,i.u_dem_size),u_dem_lerp:new t.Uniform1f(e,i.u_dem_lerp),u_exaggeration:new t.Uniform1f(e,i.u_exaggeration),u_depth:new t.Uniform1i(e,i.u_depth),u_depth_size_inv:new t.Uniform2f(e,i.u_depth_size_inv),u_meter_to_dem:new t.Uniform1f(e,i.u_meter_to_dem),u_label_plane_matrix_inv:new t.UniformMatrix4f(e,i.u_label_plane_matrix_inv),u_tile_tl_up:new t.Uniform3f(e,i.u_tile_tl_up),u_tile_tr_up:new t.Uniform3f(e,i.u_tile_tr_up),u_tile_br_up:new t.Uniform3f(e,i.u_tile_br_up),u_tile_bl_up:new t.Uniform3f(e,i.u_tile_bl_up),u_tile_up_scale:new t.Uniform1f(e,i.u_tile_up_scale)}))(e,v)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((e,i)=>({u_fog_matrix:new t.UniformMatrix4f(e,i.u_fog_matrix),u_fog_range:new t.Uniform2f(e,i.u_fog_range),u_fog_color:new t.Uniform4f(e,i.u_fog_color),u_fog_horizon_blend:new t.Uniform1f(e,i.u_fog_horizon_blend),u_fog_temporal_offset:new t.Uniform1f(e,i.u_fog_temporal_offset),u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_globe_pos:new t.Uniform3f(e,i.u_globe_pos),u_globe_radius:new t.Uniform1f(e,i.u_globe_radius),u_globe_transition:new t.Uniform1f(e,i.u_globe_transition),u_is_globe:new t.Uniform1i(e,i.u_is_globe),u_viewport:new t.Uniform2f(e,i.u_viewport)}))(e,v))}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].location&&i[t].set(e[t])}}draw(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_){const g=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(o),t.setCullFace(n);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(s[t]);d&&d.setUniforms(t,this.binderUniforms,h,{zoom:p});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[e];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new ui)).bind(t,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m,_),g.drawElements(e,i.primitiveLength*y,g.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function zi(t,e,i){const r=1/D(i,1,e.transform.tileZoom),o=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,e.transform.tileZoom)/o,s=n*(i.tileID.canonical.x+i.tileID.wrap*o),a=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const ki=t.create(),Pi=(e,i,r,o,n,s,a,l,c)=>{const u=i.style.light,h=u.properties.get("position"),p=[h.x,h.y,h.z],d=t.create$1();"viewport"===u.properties.get("anchor")&&(t.fromRotation(d,-i.transform.angle),t.transformMat3(p,p,d));const f=u.properties.get("color"),m=i.transform,_={u_matrix:e,u_lightpos:p,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[f.r,f.g,f.b],u_vertical_gradient:+r,u_opacity:o,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ki,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===m.projection.name&&(_.u_tile_id=[n.canonical.x,n.canonical.y,1<{const p=Pi(e,i,r,o,n,l,c,u,h),d={u_height_factor:-Math.pow(2,n.overscaledZ)/a.tileSize/8};return t.extend(p,zi(s,i,a),d)},Li=t=>({u_matrix:t}),Bi=(e,i,r,o)=>t.extend(Li(e),zi(r,i,o)),Ri=(t,e)=>({u_matrix:t,u_world:e}),Fi=(e,i,r,o,n)=>t.extend(Bi(e,i,r,o),{u_world:n}),Oi=t.create(),Ui=(e,i,r,o,n,s)=>{const a=e.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const e=t.globePixelsToTileUnits(a.zoom,i.canonical)*a._projectionScaler;c=Float32Array.from([e,0,0,e])}else c=a.calculatePixelsToTileUnitsMatrix(r);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(i.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Oi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=o,u.u_merc_center=n,u.u_tile_id=[i.canonical.x,i.canonical.y,1<{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},ji=(e,i,r,o)=>{const n=t.EXTENT/r.tileSize;return{u_matrix:e,u_camera_to_center_distance:i.getCameraToCenterDistance(o),u_extrude_scale:[i.pixelsToGLUnits[0]/n,i.pixelsToGLUnits[1]/n]}},Ni=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),Gi=t.create(),Zi=(e,i,r,o,n,s,a)=>{const l=e.transform,c="globe"===l.projection.name,u=c?t.globePixelsToTileUnits(l.zoom,i.canonical)*l._projectionScaler:D(r,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Gi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=o,h.u_merc_center=n,h.u_tile_id=[i.canonical.x,i.canonical.y,1<{const l=t.transform,c=l.calculatePixelsToTileUnitsMatrix(e),u={u_matrix:Wi(t,e,i,o),u_pixels_to_tile_units:c,u_device_pixel_ratio:s,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:a};if(Hi(i)){const i=Xi(e,t.transform);u.u_texsize=e.lineAtlasTexture.size,u.u_scale=[i,r.fromScale,r.toScale],u.u_mix=r.t}return u},qi=(t,e,i,r,o,n)=>{const s=t.transform,a=Xi(e,s);return{u_matrix:Wi(t,e,i,o),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:n,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Xi(t,e){return 1/D(t,1,e.tileZoom)}function Wi(t,e,i,r){return t.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function Hi(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const Yi=(t,e,i,r,o,n)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(a=o.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=o.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Ki(o.paint.get("raster-hue-rotate")),u_perspective_transform:n};var s,a};function Ki(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Ji=t.create(),Qi=(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_)=>{const g=n.transform,y={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_rotate_symbol:+r,u_aspect_ratio:g.width/g.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+o,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ji,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ji,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<t.extend(Qi(e,i,r,o,n,s,a,l,c,u,p,d,f,m,_,g),{u_gamma_scale:o?n.transform.cameraToCenterDistance*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+h}),er=(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_)=>t.extend(tr(e,i,r,o,n,s,a,l,!0,c,!0,h,p,d,f,m,_),{u_texsize_icon:u,u_texture_icon:1}),ir=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),rr=(e,i,r,o,n,s)=>t.extend(function(t,e,i,r){const o=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(r.tileID.canonical.x+r.tileID.wrap*l),h=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[s,a],u_mix:e.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/D(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(o,s,r,n),{u_matrix:e,u_opacity:i}),or={fillExtrusion:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_opacity:new t.Uniform1f(e,i.u_opacity),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_up_dir:new t.Uniform3f(e,i.u_up_dir),u_height_lift:new t.Uniform1f(e,i.u_height_lift)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,i.u_height_factor),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_up_dir:new t.Uniform3f(e,i.u_up_dir),u_height_lift:new t.Uniform1f(e,i.u_height_lift),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.UniformMatrix2f(e,i.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_up_dir:new t.Uniform3f(e,i.u_up_dir)}),collisionBox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale)}),collisionCircle:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,i.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.UniformColor(e,i.u_color),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_overlay:new t.Uniform1i(e,i.u_overlay),u_overlay_scale:new t.Uniform1f(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.Uniform1f(e,i.u_extrude_scale),u_intensity:new t.Uniform1f(e,i.u_intensity),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_up_dir:new t.Uniform3f(e,i.u_up_dir)}),heatmapTexture:(e,i)=>({u_image:new t.Uniform1i(e,i.u_image),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_opacity:new t.Uniform1f(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_latrange:new t.Uniform2f(e,i.u_latrange),u_light:new t.Uniform2f(e,i.u_light),u_shadow:new t.UniformColor(e,i.u_shadow),u_highlight:new t.UniformColor(e,i.u_highlight),u_accent:new t.UniformColor(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_dimension:new t.Uniform2f(e,i.u_dimension),u_zoom:new t.Uniform1f(e,i.u_zoom),u_unpack:new t.Uniform4f(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_pixels_to_tile_units:new t.UniformMatrix2f(e,i.u_pixels_to_tile_units),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_dash_image:new t.Uniform1i(e,i.u_dash_image),u_gradient_image:new t.Uniform1i(e,i.u_gradient_image),u_image_height:new t.Uniform1f(e,i.u_image_height),u_texsize:new t.Uniform2f(e,i.u_texsize),u_scale:new t.Uniform3f(e,i.u_scale),u_mix:new t.Uniform1f(e,i.u_mix),u_alpha_discard_threshold:new t.Uniform1f(e,i.u_alpha_discard_threshold),u_trim_offset:new t.Uniform2f(e,i.u_trim_offset)}),linePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixels_to_tile_units:new t.UniformMatrix2f(e,i.u_pixels_to_tile_units),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_image:new t.Uniform1i(e,i.u_image),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_alpha_discard_threshold:new t.Uniform1f(e,i.u_alpha_discard_threshold)}),raster:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_tl_parent:new t.Uniform2f(e,i.u_tl_parent),u_scale_parent:new t.Uniform1f(e,i.u_scale_parent),u_fade_t:new t.Uniform1f(e,i.u_fade_t),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image0:new t.Uniform1i(e,i.u_image0),u_image1:new t.Uniform1i(e,i.u_image1),u_brightness_low:new t.Uniform1f(e,i.u_brightness_low),u_brightness_high:new t.Uniform1f(e,i.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,i.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,i.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,i.u_spin_weights),u_perspective_transform:new t.Uniform2f(e,i.u_perspective_transform)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_camera_forward:new t.Uniform3f(e,i.u_camera_forward),u_tile_matrix:new t.UniformMatrix4f(e,i.u_tile_matrix),u_up_vector:new t.Uniform3f(e,i.u_up_vector),u_ecef_origin:new t.Uniform3f(e,i.u_ecef_origin),u_texture:new t.Uniform1i(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_camera_forward:new t.Uniform3f(e,i.u_camera_forward),u_tile_matrix:new t.UniformMatrix4f(e,i.u_tile_matrix),u_up_vector:new t.Uniform3f(e,i.u_up_vector),u_ecef_origin:new t.Uniform3f(e,i.u_ecef_origin),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texsize_icon:new t.Uniform2f(e,i.u_texsize_icon),u_texture:new t.Uniform1i(e,i.u_texture),u_texture_icon:new t.Uniform1i(e,i.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_color:new t.UniformColor(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image:new t.Uniform1i(e,i.u_image),u_pattern_tl_a:new t.Uniform2f(e,i.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,i.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,i.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,i.u_pattern_br_b),u_texsize:new t.Uniform2f(e,i.u_texsize),u_mix:new t.Uniform1f(e,i.u_mix),u_pattern_size_a:new t.Uniform2f(e,i.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,i.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,i.u_scale_a),u_scale_b:new t.Uniform1f(e,i.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,i.u_tile_units_to_pixels)}),terrainRaster:mi,terrainDepth:mi,skybox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_cubemap:new t.Uniform1i(e,i.u_cubemap),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_center_direction:new t.Uniform3f(e,i.u_center_direction),u_radius:new t.Uniform1f(e,i.u_radius),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxCapture:(e,i)=>({u_matrix_3f:new t.UniformMatrix3f(e,i.u_matrix_3f),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_sun_intensity:new t.Uniform1f(e,i.u_sun_intensity),u_color_tint_r:new t.Uniform4f(e,i.u_color_tint_r),u_color_tint_m:new t.Uniform4f(e,i.u_color_tint_m),u_luminance:new t.Uniform1f(e,i.u_luminance)}),globeRaster:(e,i)=>({u_proj_matrix:new t.UniformMatrix4f(e,i.u_proj_matrix),u_globe_matrix:new t.UniformMatrix4f(e,i.u_globe_matrix),u_normalize_matrix:new t.UniformMatrix4f(e,i.u_normalize_matrix),u_merc_matrix:new t.UniformMatrix4f(e,i.u_merc_matrix),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_image0:new t.Uniform1i(e,i.u_image0),u_grid_matrix:new t.UniformMatrix3f(e,i.u_grid_matrix),u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_globe_pos:new t.Uniform3f(e,i.u_globe_pos),u_globe_radius:new t.Uniform1f(e,i.u_globe_radius),u_viewport:new t.Uniform2f(e,i.u_viewport)}),globeAtmosphere:(e,i)=>({u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_horizon:new t.Uniform1f(e,i.u_horizon),u_transition:new t.Uniform1f(e,i.u_transition),u_fadeout_range:new t.Uniform1f(e,i.u_fadeout_range),u_color:new t.Uniform4f(e,i.u_color),u_high_color:new t.Uniform4f(e,i.u_high_color),u_space_color:new t.Uniform4f(e,i.u_space_color),u_star_intensity:new t.Uniform1f(e,i.u_star_intensity),u_star_density:new t.Uniform1f(e,i.u_star_density),u_star_size:new t.Uniform1f(e,i.u_star_size),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset),u_horizon_angle:new t.Uniform1f(e,i.u_horizon_angle),u_rotation_matrix:new t.UniformMatrix4f(e,i.u_rotation_matrix)})};let nr;function sr(e,i,r,o,n,s,a){const l=e.context,c=l.gl,u=e.transform,h=e.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m0){const e=t.create(),i=v;t.mul(e,y.placementInvProjMatrix,u.glCoordMatrix),t.mul(e,e,y.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:i,invTransform:e,projection:y.getProjection()}),d+=w.length/4,f=d}b&&(e.terrain&&e.terrain.setupElevationDraw(g,h),h.draw(l,c.LINES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,ji(v,u,g,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!a||!p.length)return;const m=e.useProgram("collisionCircle"),_=new t.StructArrayLayout2f1f2i16;_.resize(4*d),_._trim();let g=0;for(const t of p)for(let e=0;e=0&&(m[x.associatedIconIndex]={shiftedAnchor:z,angle:k})}else _e(x.numGlyphs,d)}if(h){f.clear();const i=e.icon.placedSymbolArray;for(let e=0;e[0,0,0],r=ie(V,o.tileID.canonical,g,_,m,c.getProjection(),j);le(c,V,e,n,r,Z,g,u,i,l)}const X=y||n&&E||q,W=e.translatePosMatrix(V,o,s,a),H=X?ar:N,Y=e.translatePosMatrix(Z,o,s,a,!0),K=c.getProjection().createInversionMatrix(m,l.canonical),J=[];e.terrain&&g&&J.push("PITCH_WITH_MAP_TERRAIN"),F&&J.push("PROJECTION_GLOBE_VIEW"),X&&J.push("PROJECTED_POS_ON_VIEWPORT");const Q=d&&0!==r.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let tt;tt=d?c.iconsInText?er(w.kind,z,x,g,e,W,H,Y,k,B,l,U,T,K,O,c.getProjection()):tr(w.kind,z,x,g,e,W,H,Y,n,k,!0,l,U,T,K,O,c.getProjection()):Qi(w.kind,z,x,g,e,W,H,Y,n,k,l,U,T,K,O,c.getProjection());const et={program:e.useProgram(ur(d,n,c),p,J),buffers:h,uniformValues:tt,atlasTexture:P,atlasTextureIcon:R,atlasInterpolation:D,atlasInterpolationIcon:L,isSDF:d,hasHalo:Q,tile:o,labelPlaneMatrixInv:G};if(v&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)C.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:et})}else C.push({segments:h.segments,sortKey:0,state:et})}b&&C.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of C){const i=t.state;if(e.terrain&&e.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,pr(i.buffers,t.segments,r,e,i.program,w,h,p,o)),o.u_is_halo=0}pr(i.buffers,t.segments,r,e,i.program,w,h,p,i.uniformValues)}}function pr(e,i,r,o,n,s,a,l,c){const u=o.context;n.draw(u,u.gl.TRIANGLES,s,a,l,t.CullFaceMode.disabled,c,r.id,e.layoutVertexBuffer,e.indexBuffer,i,r.paint,o.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer)}function dr(e,i,r,o,n,s,a){const l=e.context.gl,c=r.paint.get("fill-pattern"),u=c&&c.constantOr(1),h=r.getCrossfadeParameters();let p,d,f,m,_;a?(d=u&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(d=u?"fillPattern":"fill",p=l.TRIANGLES);for(const g of o){const o=i.getTile(g);if(u&&!o.patternsLoaded())continue;const y=o.getBucket(r);if(!y)continue;e.prepareDrawTile();const x=y.programConfigurations.get(r.id),v=e.useProgram(d,x);u&&(e.context.activeTexture.set(l.TEXTURE0),o.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),x.updatePaintBuffers(h));const b=c.constantOr(null);if(b&&o.imageAtlas){const t=o.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const w=e.translatePosMatrix(g.projMatrix,o,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,_=y.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&u?Fi(w,e,h,o,t):Ri(w,t)}else m=y.indexBuffer,_=y.segments,f=u?Bi(w,e,h,o):Li(w);e.prepareDrawProgram(e.context,v,g.toUnwrapped()),v.draw(e.context,p,n,e.stencilModeForClipping(g),s,t.CullFaceMode.disabled,f,r.id,y.layoutVertexBuffer,m,_,r.paint,e.transform.zoom,x)}}function fr(e,i,r,o,n,s,a){const l=e.context,c=l.gl,u=e.transform,h=r.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),m="globe"===u.projection.name?t.fillExtrusionHeightLift():0,_="globe"===u.projection.name,g=_?t.globeToMercatorTransition(u.zoom):0,y=[t.mercatorXfromLng(u.center.lng),t.mercatorYfromLat(u.center.lat)],x=[];_&&x.push("PROJECTION_GLOBE_VIEW");for(const v of o){const o=i.getTile(v),b=o.getBucket(r);if(!b||b.projection.name!==u.projection.name)continue;const w=b.programConfigurations.get(r.id),T=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",w,x);if(e.terrain){const t=e.terrain;if(e.style.terrainSetForDrapingOnly())t.setupElevationDraw(o,T,{useMeterToDem:!0});else{if(!b.enableTerrain)continue;if(t.setupElevationDraw(o,T,{useMeterToDem:!0}),mr(l,i,v,b,r,t),!b.centroidVertexBuffer){const t=T.attributes.a_centroid_pos;void 0!==t&&c.vertexAttrib2f(t,0,0)}}}p&&(e.context.activeTexture.set(c.TEXTURE0),o.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),w.updatePaintBuffers(d));const E=h.constantOr(null);if(E&&o.imageAtlas){const t=o.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const S=e.translatePosMatrix(v.projMatrix,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),C=u.projection.createInversionMatrix(u,v.canonical),M=r.paint.get("fill-extrusion-vertical-gradient"),A=p?Di(S,e,M,f,v,d,o,m,g,y,C):Pi(S,e,M,f,v,m,g,y,C);e.prepareDrawProgram(l,T,v.toUnwrapped()),T.draw(l,l.gl.TRIANGLES,n,s,a,t.CullFaceMode.backCCW,A,r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,r.paint,e.transform.zoom,w,e.terrain?b.centroidVertexBuffer:null,_?b.layoutVertexExtBuffer:null)}}function mr(e,i,r,o,n,s){const a=[e=>{let i=e.canonical.x-1,r=e.wrap;return i<0&&(i=(1<{let i=e.canonical.x+1,r=e.wrap;return i===1<new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<{const e=i.getSource().minzoom,r=t=>{const e=i.getTileByID(t);if(e&&e.hasData())return e.getBucket(n)},o=[0,-1,1];for(const i of o){if(t.overscaledZ+i(c[0]=Math.min(e.min.y,i.min.y),c[1]=Math.max(e.max.y,i.max.y),c[2]=t.EXTENT-i.min.x>e.max.x?i.min.x-t.EXTENT:e.max.x,c),h=(e,i)=>(c[0]=Math.min(e.min.x,i.min.x),c[1]=Math.max(e.max.x,i.max.x),c[2]=t.EXTENT-i.min.y>e.max.y?i.min.y-t.EXTENT:e.max.y,c),p=[(t,e)=>u(t,e),(t,e)=>u(e,t),(t,e)=>h(t,e),(t,e)=>h(e,t)],d=new t.pointGeometry(0,0);let f,m,_;const g=(e,i,o,n,a)=>{const l=[[n?o:e,n?e:o,0],[n?o:i,n?i:o,0]],c=a<0?t.EXTENT+a:a,u=[n?c:(e+i)/2,n?(e+i)/2:c,0];return 0===o&&a<0||0!==o&&a>0?s.getForTilePoints(_,[u],!0,m):l.push(u),s.getForTilePoints(r,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let e=0;e<4;e++){const i=(e<2?1:5)-e,n=o.borders[e];if(0===n.length)continue;const c=_=a[e](r),u=l(c);if(!(u&&u instanceof t.FillExtrusionBucket&&u.enableTerrain))continue;if(o.borderDoneWithNeighborZ[e]===u.canonical.z&&u.borderDoneWithNeighborZ[i]===o.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(r);if(!t||!t.dem)return;f=t}const h=u.borders[i];let y=0;const x=u.borderDoneWithNeighborZ[i]!==o.canonical.z;if(o.canonical.z===u.canonical.z){for(let r=0;ra[0]+3));)x&&u.encodeCentroid(void 0,l,!1),y++;if(l&&ya[1]-3)&&(n++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[r]],s.intersectsCount()>1||l.intersectsCount()>1||1!==n){1!==n&&(y=r),o.encodeCentroid(void 0,s,!1),x&&u.encodeCentroid(void 0,l,!1);continue}const c=p[e](s,l),f=e%2?t.EXTENT-1:0;d.x=g(c[0],Math.min(t.EXTENT-1,c[1]),f,e<2,c[2]),d.y=0,o.encodeCentroid(d,s,!1),x&&u.encodeCentroid(d,l,!1)}else o.encodeCentroid(void 0,s,!1)}o.borderDoneWithNeighborZ[e]=u.canonical.z,o.needsCentroidUpdate=!0,x&&(u.borderDoneWithNeighborZ[i]=o.canonical.z,u.needsCentroidUpdate=!0)}else{for(const t of n)o.encodeCentroid(void 0,o.featuresOnBorder[t],!1);if(x){for(const t of h)u.encodeCentroid(void 0,u.featuresOnBorder[t],!1);u.borderDoneWithNeighborZ[i]=o.canonical.z,u.needsCentroidUpdate=!0}o.borderDoneWithNeighborZ[e]=u.canonical.z,o.needsCentroidUpdate=!0}}(o.needsCentroidUpdate||!o.centroidVertexBuffer&&0!==o.centroidVertexArray.length)&&o.uploadCentroid(e)}const _r=new t.Color(1,0,0,1),gr=new t.Color(0,1,0,1),yr=new t.Color(0,0,1,1),xr=new t.Color(1,0,1,1),vr=new t.Color(0,1,1,1);function br(t,e,i,r){Tr(t,0,e+i/2,t.transform.width,i,r)}function wr(t,e,i,r){Tr(t,e-i/2,0,i,t.transform.height,r)}function Tr(e,i,r,o,n,s){const a=e.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*t.exported.devicePixelRatio,r*t.exported.devicePixelRatio,o*t.exported.devicePixelRatio,n*t.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Er(e,i,r){const o=e.context,n=o.gl,s="globe"===e.transform.projection.name,a=r.projMatrix,l=e.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),c=i.getTileByID(r.key);e.terrain&&e.terrain.setupElevationDraw(c,l);const u=t.DepthMode.disabled,h=t.StencilMode.disabled,p=e.colorModeForRenderPass(),d="$debug";o.activeTexture.set(n.TEXTURE0),e.emptyTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),s?c._makeGlobeTileDebugBuffers(e.context,e.transform.projection):c._makeDebugTileBoundsBuffers(e.context,e.transform.projection);const f=c._tileDebugBuffer||e.debugBuffer,m=c._tileDebugIndexBuffer||e.debugIndexBuffer,_=c._tileDebugSegments||e.debugSegments;l.draw(o,n.LINE_STRIP,u,h,p,t.CullFaceMode.disabled,Ni(a,t.Color.red),d,f,m,_,null,null,null,c._globeTileDebugBorderBuffer);const g=c.latestRawTileData,y=Math.floor((g&&g.byteLength||0)/1024),x=i.getTile(r).tileSize,v=512/Math.min(x,512)*(r.overscaledZ/e.transform.zoom)*.5;let b=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(b+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,o=t.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(e,5,5),o.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${b} ${y}kb`);const w=c._tileDebugTextBuffer||e.debugBuffer,T=c._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,E=c._tileDebugTextSegments||e.debugSegments;l.draw(o,n.TRIANGLES,u,h,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Ni(a,t.Color.transparent,v),d,w,T,E,null,null,null,c._globeTileDebugTextBuffer)}const Sr=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Cr}=Sr;function Mr(t,e,i,r){t.emplaceBack(e,i,r)}class Ar{constructor(e){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,Mr(this.vertexArray,-1,-1,1),Mr(this.vertexArray,1,-1,1),Mr(this.vertexArray,-1,1,1),Mr(this.vertexArray,1,1,1),Mr(this.vertexArray,-1,-1,-1),Mr(this.vertexArray,1,-1,-1),Mr(this.vertexArray,-1,1,-1),Mr(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Cr),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function Ir(e,i,r,o,n,s){const a=e.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,i,r,o)=>({u_matrix_3f:t,u_sun_direction:e,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[o.r,o.g,o.b,o.a],u_luminance:5e-5}))(t.fromMat4(t.create$1(),o),n,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(e,a.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const zr=t.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class kr{constructor(e){const i=new t.StructArrayLayout5f20;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const r=new t.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(i,zr.members),this.indexBuffer=e.createIndexBuffer(r),this.segments=t.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Pr={symbol:function(e,i,r,o,n){if("translucent"!==e.renderPass)return;const s=t.StencilMode.disabled,a=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,i,r,o,n,s,a){const l=i.transform,c="map"===n,u="map"===s;for(const i of e){const e=o.getTile(i),n=e.getBucket(r);if(!n||!n.text||!n.text.segments.get().length)continue;const s=t.evaluateSizeForZoom(n.textSizeData,l.zoom),h=we(i,n.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(e),d=ee(h,e.tileID.canonical,u,c,l,n.getProjection(),p),f="none"!==r.layout.get("icon-text-fit")&&n.hasIconData();if(s){const r=Math.pow(2,l.zoom-e.tileID.overscaledZ);cr(n,c,u,a,t.symbolSize,l,d,i,r,s,f)}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),n),0!==r.paint.get("icon-opacity").constantOr(1)&&hr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,a),0!==r.paint.get("text-opacity").constantOr(1)&&hr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(sr(e,i,r,o,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),sr(e,i,r,o,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,r,o){if("translucent"!==e.renderPass)return;const n=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=e.context,u=c.gl,h=e.transform,p=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),d=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="globe"===h.projection.name,_=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],g=[];for(let n=0;nt.sortKey-e.sortKey));const y={useDepthForOcclusion:!m};for(const i of g){const{programConfiguration:o,program:n,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:_,tile:g}=i.state,x=i.segments;e.terrain&&e.terrain.setupElevationDraw(g,n,y),e.prepareDrawProgram(c,n,g.tileID.toUnwrapped()),n.draw(c,u.TRIANGLES,p,d,f,t.CullFaceMode.disabled,_,r.id,s,l,x,r.paint,h.zoom,o,m?a:null)}},heatmap:function(e,i,r,o){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,s=n.gl,a=t.StencilMode.disabled,l=new t.ColorMode([s.ONE,s.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i,r){const o=t.gl,n=e.width*r,s=e.height*r;t.activeTexture.set(o.TEXTURE1),t.viewport.set([0,0,n,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==n||a.height!==s)){a&&a.destroy();const e=o.createTexture();o.bindTexture(o.TEXTURE_2D,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),a=i.heatmapFbo=t.createFramebuffer(n,s,!1),function(t,e,i,r,o,n){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o,n,0,s.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,0,e,a,n,s)}else o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)}(n,e,r,"globe"===e.transform.projection.name?.5:.25),n.clear({color:t.Color.transparent});const c=e.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?t.CullFaceMode.frontCCW:t.CullFaceMode.disabled,d=[t.mercatorXfromLng(c.center.lng),t.mercatorYfromLat(c.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,i),i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,r))},line:function(e,i,r,o){if("translucent"!==e.renderPass)return;const n=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===n.constantOr(1)||0===s.constantOr(1))return;const a=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),l=e.colorModeForRenderPass(),c=e.terrain&&e.terrain.renderingToTexture?1:t.exported.devicePixelRatio,u=r.paint.get("line-dasharray"),h=u.constantOr(1),p=r.layout.get("line-cap"),d=r.paint.get("line-pattern"),f=d.constantOr(1),m=r.paint.get("line-gradient"),_=r.getCrossfadeParameters(),g=f?"linePattern":"line",y=e.context,x=y.gl,v=(t=>{const e=[];Hi(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET");const r=t.paint.get("line-pattern").constantOr(1),o=1!==t.paint.get("line-opacity").constantOr(1);return!r&&o&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(r);let b=v.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const n of o){const o=i.getTile(n);if(f&&!o.patternsLoaded())continue;const s=o.getBucket(r);if(!s)continue;e.prepareDrawTile();const w=s.programConfigurations.get(r.id),T=e.useProgram(g,w,v),E=d.constantOr(null);if(E&&o.imageAtlas){const t=o.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const S=u.constantOr(null),C=p.constantOr(null);if(!f&&S&&C&&o.lineAtlas){const t=o.lineAtlas,e=t.getDash(S.to,C),i=t.getDash(S.from,C);e&&i&&w.setConstantPatternPositions(e,i)}let[M,A]=r.paint.get("line-trim-offset");if("round"===C||"square"===C){const t=1;M!==A&&(0===M&&(M-=t),1===A&&(A+=t))}const I=e.terrain?n.projMatrix:null,z=f?qi(e,o,r,_,I,c):$i(e,o,r,_,I,s.lineClipsArray.length,c,[M,A]);if(m){const o=s.gradients[r.id];let a=o.texture;if(r.gradientVersion!==o.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,o=n.canonical.z===r?Math.ceil(1<{T.draw(y,x.TRIANGLES,a,i,l,t.CullFaceMode.disabled,z,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,e.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const i=e.stencilModeForClipping(n).ref;0===i&&e.terrain&&y.clear({stencil:0});const r={func:x.EQUAL,mask:255};z.u_alpha_discard_threshold=.8,k(new t.StencilMode(r,i,255,x.KEEP,x.KEEP,x.INVERT)),z.u_alpha_discard_threshold=0,k(new t.StencilMode(r,i,255,x.KEEP,x.KEEP,x.KEEP))}else k(e.stencilModeForClipping(n))}b&&(e.resetStencilClippingMasks(),e.terrain&&y.clear({stencil:0}))},fill:function(e,i,r,o){const n=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=e.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(t.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);dr(e,i,r,o,n,a,!1)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){const n=e.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);dr(e,i,r,o,n,a,!0)}},"fill-extrusion":function(e,i,r,o){const n=r.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===e.renderPass){const s=new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==n||r.paint.get("fill-extrusion-pattern").constantOr(1))fr(e,i,r,o,s,t.StencilMode.disabled,t.ColorMode.disabled),fr(e,i,r,o,s,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const n=e.colorModeForRenderPass();fr(e,i,r,o,s,t.StencilMode.disabled,n)}}},hillshade:function(e,i,r,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const n=e.context,s=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),a=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture,[c,u]="translucent"!==e.renderPass||l?[{},o]:e.stencilConfigForOverlap(o);for(const o of u){const n=i.getTile(o);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)fi(e,n,r,s,t.StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=l&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):c[o.overscaledZ];pi(e,o,n,r,s,t,a)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,i,r,o,n,s){if("translucent"!==e.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!o.length)return;const a=e.context,l=a.gl,c=i.getSource(),u=e.useProgram("raster"),h=e.colorModeForRenderPass(),p=e.terrain&&e.terrain.renderingToTexture,[d,f]=c instanceof zt||p?[{},o]:e.stencilConfigForOverlap(o),m=f[f.length-1].overscaledZ,_=!e.options.moving;for(const o of f){const n=p?t.DepthMode.disabled:e.depthModeForSublayer(o.overscaledZ-m,1===r.paint.get("raster-opacity")?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,l.LESS),f=o.toUnwrapped(),g=i.getTile(o);if(p&&(!g||!g.hasData()))continue;const y=p?o.projMatrix:e.transform.calculateProjMatrix(f,_),x=e.terrain&&p?e.terrain.stencilModeForRTTOverlap(o):d[o.overscaledZ],v=s?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(v);const b=i.findLoadedParent(o,0),w=Ti(g,b,i,e.transform,v);let T,E;e.terrain&&e.terrain.prepareDrawTile();const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),E=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(S,l.CLAMP_TO_EDGE);const C=Yi(y,E||[0,0],T||1,w,r,c instanceof zt?c.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,u,f),c instanceof zt)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,n,t.StencilMode.disabled,h,t.CullFaceMode.disabled,C,r.id,c.boundsBuffer,e.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:o,tileBoundsSegments:s}=e.getTileBoundsBuffers(g);u.draw(a,l.TRIANGLES,n,x,h,t.CullFaceMode.disabled,C,r.id,i,o,s)}}e.resetStencilClippingMasks()},background:function(e,i,r,o){const n=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(0===s)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=r.paint.get("background-pattern");if(e.isPatternMissing(h))return;const p=!h&&1===n.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==p)return;const d=t.StencilMode.disabled,f=e.depthModeForSublayer(0,"opaque"===p?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),m=e.colorModeForRenderPass(),_=e.useProgram(h?"backgroundPattern":"background");let g,y=o;y||(g=e.getBackgroundTiles(),y=Object.values(g).map((t=>t.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));const x=r.getCrossfadeParameters();for(const p of y){const y=p.toUnwrapped(),v=o?p.projMatrix:e.transform.calculateProjMatrix(y);e.prepareDrawTile();const b=i?i.getTile(p):g?g[p.key]:new t.Tile(p,u,c.zoom,e),w=h?rr(v,s,e,h,{tileID:p,tileSize:u},x):ir(v,s,n);e.prepareDrawProgram(a,_,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:E,tileBoundsSegments:S}=e.getTileBoundsBuffers(b);_.draw(a,l.TRIANGLES,f,d,m,t.CullFaceMode.disabled,w,r.id,T,E,S)}},sky:function(e,i,r){const o=e.transform,n="mercator"===o.projection.name||"globe"===o.projection.name?1:t.smoothstep(7,8,o.zoom),s=r.paint.get("sky-opacity")*n;if(0===s)return;const a=e.context,l=r.paint.get("sky-type"),c=new t.DepthMode(a.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===e.renderPass?r.needsSkyboxCapture(e)&&(function(e,i,r,o){const n=e.context,s=n.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=n.createFramebuffer(32,32,!1),i.skyboxGeometry=new Ar(n),i.skyboxTexture=n.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(a.framebuffer),n.viewport.set([0,0,32,32]);const l=i.getCenter(e,!0),c=e.useProgram("skyboxCapture"),u=new Float64Array(16);t.identity(u),t.rotateY(u,u,.5*-Math.PI),Ir(n,i,c,u,l,0),t.identity(u),t.rotateY(u,u,.5*Math.PI),Ir(n,i,c,u,l,1),t.identity(u),t.rotateX(u,u,.5*-Math.PI),Ir(n,i,c,u,l,2),t.identity(u),t.rotateX(u,u,.5*Math.PI),Ir(n,i,c,u,l,3),t.identity(u),Ir(n,i,c,u,l,4),t.identity(u),t.rotateY(u,u,Math.PI),Ir(n,i,c,u,l,5),n.viewport.set([0,0,e.width,e.height])}(e,r),r.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,i,r,o,n){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((t,e,i,r,o)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(e,!1),0,o,n);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,c,s,u):"gradient"===l&&"sky"===e.renderPass&&function(e,i,r,o,n){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ar(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new t.Texture(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,i,r,o,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:i,u_radius:t.degToRad(r),u_opacity:o,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(e,!1),i.paint.get("sky-gradient-radius"),o,n);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,c,s,u)},debug:function(t,e,i){for(let r=0;rr)return void(this.transform.fogCullDistSq=null);const o=i+.78*(r-i);this.transform.fogCullDistSq=o*o}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,i){if(this.width=e*t.exported.devicePixelRatio,this.height=i*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const e=this.context,i=new t.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(i,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const r=new t.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(r,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const o=new t.StructArrayLayout2i4;o.emplaceBack(-1,-1),o.emplaceBack(1,-1),o.emplaceBack(-1,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const n=new t.StructArrayLayout4i8;n.emplaceBack(0,0,0,0),n.emplaceBack(t.EXTENT,0,t.EXTENT,0),n.emplaceBack(0,t.EXTENT,0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.mercatorBoundsBuffer=e.createVertexBuffer(n,t.boundsAttributes.members),this.mercatorBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new t.StructArrayLayout1ui2;for(const t of[0,1,3,2,0])a.emplaceBack(t);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new t.Texture(e,new t.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=t.create();const l=this.context.gl;this.stencilClearMode=new t.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.window.performance.now()),this.atmosphereBuffer=new kr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,i.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,wi(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,i,r){if(!i||this.currentStencilSource===i.id||!e.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let t=!1;for(const e of r)if(void 0===this._tileClippingMaskIDs[e.key]){t=!0;break}if(!t)return}this.currentStencilSource=i.id;const o=this.context,n=o.gl;this.nextStencilID+r.length>256&&this.clearStencil(),o.setColorMode(t.ColorMode.disabled),o.setDepthMode(t.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of r){const r=i.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(r);s.draw(o,n.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:n.ALWAYS,mask:0},a,255,n.KEEP,n.KEEP,n.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,wi(e.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,i=this.context.gl;return new t.StencilMode({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const i=this.context.gl;return new t.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(e){const i=this.context.gl,r=e.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),o=r[r.length-1].overscaledZ,n=r[0].overscaledZ-o+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let r=0;r=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky())continue;const o=i?s[i.id]:void 0;this._renderTileClippingMasks(t,i,o),this.renderLayer(this,i,t,o)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,i){const r=e.context,o=r.gl,n=e.transform,s=new t.DepthMode(o.LEQUAL,t.DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=t.globeToMercatorTransition(n.zoom),c=i.properties.get("color").toArray01(),u=i.properties.get("high-color").toArray01(),h=i.properties.get("space-color").toArray01PremultipliedAlpha(),p=t.identity$1([]);t.rotateY$1(p,p,-t.degToRad(n._center.lng)),t.rotateX$1(p,p,t.degToRad(n._center.lat)),t.rotateZ$1(p,p,n.angle),t.rotateX$1(p,p,-n._pitch);const d=t.fromQuat(new Float32Array(16),p),f=t.mapValue(i.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=t.mapValue(i.properties.get("horizon-blend"),0,1,m,.25),g=t.globeUseCustomAntiAliasing(e,r,n)&&_===m?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,y=e.frameCounter/1e3%1,x=t.length(n.globeCenterInViewSpace),v=Math.sqrt(Math.pow(x,2)-Math.pow(g,2)),b=Math.acos(v/x),w=((e,i,r,o,n,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:e,u_frustum_tr:i,u_frustum_br:r,u_frustum_bl:o,u_horizon:n,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*t.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,l,_,c,u,h,f,y,b,d);e.prepareDrawProgram(r,a);const T=e.atmosphereBuffer;T&&a.draw(r,o.TRIANGLES,s,t.StencilMode.disabled,t.ColorMode.alphaBlended,t.CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(t.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const r=e._getLayerSourceCache(t);r&&!t.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),e&&!t&&0!==e.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,i){this.cache=this.cache||{};const r=i||[],o=this.currentGlobalDefines().concat(r),n=Ii.cacheKey(t,o,e);return this.cache[n]||(this.cache[n]=new Ii(this.context,t,li[t],e,or[t],o)),this.cache[n]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,i,r){if(this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const n=o.getOpacity(this.transform.pitch),s=((e,i,r,o,n,s,a,l,c,u,h)=>{const p=e.transform,d=i.properties.get("color").toArray01();d[3]=o;const f=e.frameCounter/1e3%1;return{u_fog_matrix:r?p.calculateFogTileMatrix(r):e.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:n,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:t.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,o,r,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*t.exported.devicePixelRatio,this.transform.height*t.exported.devicePixelRatio]);i.setFogUniformValues(e,s)}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,i=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const o of r)i[o.key]=e[o.key]||new t.Tile(o,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Lr{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.clamp((this.left+e-this.right)/2,0,e),o=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.pointGeometry(r,o)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Lr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Br(e,i){const r=t.getColumn(e,3);t.fromQuat(e,i),t.setColumn(e,3,r)}function Rr(e,i){const r=t.identity$1([]);return t.rotateZ$1(r,r,-i),t.rotateX$1(r,r,-e),r}function Fr(e,i){const r=[e[0],e[1],0],o=[i[0],i[1],0];if(t.length(r)>=1e-15){const e=t.normalize([],r);t.scale$2(o,e,t.dot(o,e)),i[0]=o[0],i[1]=o[1]}const n=t.cross([],i,e);if(t.len(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return Rr(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),s)}class Or{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(e){if(e){const i=e instanceof t.MercatorCoordinate?e:new t.MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(i.x=t.wrap(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(e,i){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(e)):0,o=this.position,n=t.MercatorCoordinate.fromLngLat(e,r),s=[n.x-o.x,n.y-o.y,n.z-o.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Fr(s,i)}setPitchBearing(e,i){this.orientation=Rr(t.degToRad(e),t.degToRad(-i))}}class Ur{constructor(e,i){this._transform=t.identity([]),this.orientation=i,this.position=e}get mercatorPosition(){const e=this.position;return new t.MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=t.getColumn(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var i;e&&t.setColumn(this._transform,3,[(i=e)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||t.identity$1([]),e&&Br(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=Rr(t,e),Br(this._transform,this._orientation)}forward(){const e=t.getColumn(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=t.getColumn(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=t.getColumn(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,i){const r=new Float64Array(16);return t.invert(r,this.getWorldToCamera(e,i)),r}getWorldToCameraPosition(e,i,r){const o=this.position;t.scale$2(o,o,-e);const n=new Float64Array(16);return t.fromScaling(n,[r,r,r]),t.translate(n,n,o),n[10]*=i,n}getWorldToCamera(e,i){const r=new Float64Array(16),o=new Float64Array(4),n=this.position;return t.conjugate(o,this._orientation),t.scale$2(n,n,-e),t.fromQuat(r,o),t.translate(r,r,n),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(e,i,r,o){const n=new Float64Array(16);return t.perspective(n,e,i,r,o),n}getDistanceToElevation(e){const i=0===e?0:t.mercatorZfromAltitude(e,this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new Ur([...this.position],[...this.orientation])}}function Vr(e,i){const r=Nr(e.projection,e.zoom,e.width,e.height),o=function(e,i,r,o,n){const s=new t.LngLat(r.lng-180*Gr,r.lat),a=new t.LngLat(r.lng+180*Gr,r.lat),l=e.project(s.lng,s.lat),c=e.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=t.MercatorCoordinate.fromLngLat(r);h.y=t.clamp(h.y,-.999975,.999975);const p=h.toLngLat(),d=e.project(p.lng,p.lat),f=t.MercatorCoordinate.fromLngLat(p);f.x+=Gr;const m=f.toLngLat(),_=e.project(m.lng,m.lat),g=$r(_.x-d.x,_.y-d.y,u),y=t.MercatorCoordinate.fromLngLat(p);y.y+=Gr;const x=y.toLngLat(),v=e.project(x.lng,x.lat),b=$r(v.x-d.x,v.y-d.y,u),w=Math.abs(g.x)/Math.abs(b.y),T=t.identity([]);t.rotateZ(T,T,-u*(1-(n?0:o)));const E=t.identity([]);return t.scale(E,E,[1,1-(1-w)*o,1]),E[4]=-b.x/b.y*o,t.rotateZ(E,E,u),t.multiply(E,T,E),E}(e.projection,0,e.center,r,i),n=jr(e);return t.scale(o,o,[n,n,1]),o}function jr(e){const i=e.projection,r=Nr(e.projection,e.zoom,e.width,e.height),o=Zr(i,e.center),n=Zr(i,t.LngLat.convert(i.center));return Math.pow(2,o*r+(1-r)*n)}function Nr(e,i,r,o,n=1/0){const s=e.range;if(!s)return 0;const a=Math.min(n,Math.max(r,o)),l=Math.log(a/1024)/Math.LN2;return t.smoothstep(s[0]+l,s[1]+l,i)}const Gr=1/4e4;function Zr(e,i){const r=t.clamp(i.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),o=new t.LngLat(i.lng-180*Gr,r),n=new t.LngLat(i.lng+180*Gr,r),s=e.project(o.lng,r),a=e.project(n.lng,r),l=t.MercatorCoordinate.fromLngLat(o),c=t.MercatorCoordinate.fromLngLat(n),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function $r(t,e,i){const r=Math.cos(i),o=Math.sin(i);return{x:t*r-e*o,y:t*o+e*r}}class qr{constructor(e,i,r,o,n,s,a){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==o?60:o,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Lr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Ur,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const t=new qr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t){const e=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||e)&&this._updateCameraOnTerrain(),(t||e)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return t.pick(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=t.getProjection(this.projectionOptions);const o=!e(r,this.getProjection());return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.pointGeometry(this.width,this.height)}get bearing(){return t.wrap(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const i=-e*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(t,e,i){var r=e[0],o=e[1],n=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*a,t[1]=o*l+s*a,t[2]=r*-a+n*l,t[3]=o*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const t=this._elevation;this._centerAltitude=t.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=t.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let o=0,n=0;for(let s=0;se.maxzoom&&(i=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<{const i=1/4e4,r=new t.MercatorCoordinate(e.x+i,e.y,e.z),o=new t.MercatorCoordinate(e.x,e.y+i,e.z),n=e.toLngLat(),s=r.toLngLat(),a=o.toLngLat(),l=this.locationCoordinate(n),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/i},T=e=>{const i=x,r=v;return{aabb:t.tileAABB(this,l,0,0,0,e,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:e,fullyVisible:!1}},E=[];let S=[];const C=i,M=e.reparseOverscaled?r:i,A=t=>t*t,I=A((m-this._centerAltitude)*f),z=t=>{if(!this._elevation||!t.tileID||!n)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=k(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},k=e=>{if(e.zoom=.9)return!0}else if(o&&(s=A(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,e.zoom),r=w(new t.MercatorCoordinate((e.x+.5)/i,(e.y+.5)/i));l=r>.85?1:r}const c=i*i+n*n+s;return c{if(e*A(.707)0;){const r=E.pop(),s=r.x,a=r.y;let h=r.fullyVisible;if(!h){const t=r.aabb.intersects(p);if(0===t)continue;h=2===t}if(r.zoom!==C&&k(r))for(let e=0;e<4;e++){const i=(s<<1)+e%2,c=(a<<1)+(e>>1),p={aabb:n?r.aabb.quadrant(e):t.tileAABB(this,l,r.zoom+1,i,c,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:c,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!u&&(p.tileID=new t.OverscaledTileID(r.zoom+1===C?M:r.zoom+1,r.wrap,r.zoom+1,i,c),z(p)),E.push(p)}else{const o=r.zoom===C?M:r.zoom;if(e.minzoom&&e.minzoom>o)continue;const n=c[0]-(.5+s+(r.wrap<{const n=[0,0,0,1],s=[t.EXTENT,t.EXTENT,0,1],a=this.calculateFogTileMatrix(o.tileID.toUnwrapped());t.transformMat4$1(n,n,a),t.transformMat4$1(s,s,a);const l=t.getAABBPointSquareDist(n,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>i&&0!==r){const i=this.calculateProjMatrix(o.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=u.getMinMaxForTile(o.tileID)),n||(n={min:v,max:x});const s=t.furthestTileCorner(this.rotation),a=[s[0]*t.EXTENT,s[1]*t.EXTENT,n.max];t.transformMat4(a,a,i),c=(1-a[1])*this.height*.5t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.clamp(e.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),r=this.projection.project(e.lng,i);return new t.pointGeometry(r.x*this.worldSize,r.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,i){let r,o;const n=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;r=(i.x-n.x)/t,o=(i.y-n.y)/t}else{const t=this.pointCoordinate(i),e=this.pointCoordinate(n);r=t.x-e.x,o=t.y-e.y}const s=this.locationCoordinate(e);this.setLocation(new t.MercatorCoordinate(s.x-r,s.y-o))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this.projection.locationPoint(this,t,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(e,i){const r=i?t.mercatorZfromAltitude(i,e.lat):void 0,o=this.projection.project(e.lng,e.lat);return new t.MercatorCoordinate(o.x,o.y,r)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(e,i){const r=null!=i?i:this._centerAltitude,o=[e.x,e.y,0,1],n=[e.x,e.y,1,1];t.transformMat4$1(o,o,this.pixelMatrixInverse),t.transformMat4$1(n,n,this.pixelMatrixInverse);const s=n[3];t.scale$1(o,o,1/o[3]),t.scale$1(n,n,1/s);const a=o[2],l=n[2];return{p0:o,p1:n,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(e){const i=[e.x,e.y,0,1],r=[e.x,e.y,1,1];return t.transformMat4$1(i,i,this.pixelMatrixInverse),t.transformMat4$1(r,r,this.pixelMatrixInverse),t.scale$1(i,i,1/i[3]),t.scale$1(r,r,1/r[3]),i[2]=t.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,r[2]=t.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,t.scale$1(i,i,1/this.worldSize),t.scale$1(r,r,1/this.worldSize),new t.Ray([i[0],i[1],i[2]],t.normalize([],t.sub([],r,i)))}rayIntersectionCoordinate(e){const{p0:i,p1:r,t:o}=e,n=t.mercatorZfromAltitude(i[2],this._center.lat),s=t.mercatorZfromAltitude(r[2],this._center.lat);return new t.MercatorCoordinate(t.number(i[0],r[0],o)/this.worldSize,t.number(i[1],r[1],o)/this.worldSize,t.number(n,s,o))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let i=this.projection.pointCoordinate3D(this,e.x,e.y);if(i)return new t.MercatorCoordinate(i[0],i[1],i[2]);let r=0,o=this.horizonLineFromTop();if(e.y>o)return this.pointCoordinate(e);const n=.02*o,s=e.clone();for(let e=0;e<10&&o-r>n;e++){s.y=t.number(r,o,.66);const e=this.projection.pointCoordinate3D(this,s.x,s.y);e?(o=s.y,i=e):r=s.y}return i?new t.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(e)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}_coordinatePoint(e,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,o=[e.x*this.worldSize,e.y*this.worldSize,r+e.toAltitude(),1];return t.transformMat4$1(o,o,this.pixelMatrix),o[3]>0?new t.pointGeometry(o[0]/o[3],o[1]/o[3]):new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(e,i){const r=new t.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),o=new t.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),n=new t.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new t.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(r,e),l=this.pointCoordinate(o,e);const c=this.pointCoordinate(n,i),u=this.pointCoordinate(s,i),h=(t,e)=>(e.y-t.y)/(e.x-t.x);return a.y>1&&l.y>=0?a=new t.MercatorCoordinate((1-u.y)/h(u,a)+u.x,1):a.y<0&&l.y<=1&&(a=new t.MercatorCoordinate(-u.y/h(u,a)+u.x,0)),l.y>1&&a.y>=0?l=new t.MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new t.MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new t.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const t=this.elevation;if(!t.visibleDemTiles.length)return this._getBounds(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBounds(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-t.MAX_MERCATOR_LATITUDE,this.maxLat=t.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLngu&&(s=u-l),u-ce&&(n=e-a),e-t.5?x-1:x,v>.5?v-1:v,0]),this.alignedProjMatrix=b,s=t.create(),t.scale(s,s,[this.width/2,-this.height/2,1]),t.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=t.create(),t.scale(s,s,[1,-1,1]),t.translate(s,s,[-1,-1,0]),t.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=t.invert(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=s,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=t.calculateGlobeMatrix(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=t.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,i=this.cameraPixelsPerMeter,r=this._camera.position,o=1/this.height/this._projectionScaler,n=[e,e,i];t.scale$2(n,n,o),t.scale$2(r,r,-1),t.multiply$2(r,r,n);const s=t.create();t.translate(s,s,r),t.scale(s,s,n),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,i,o)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,o=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*o,r.y/this.worldSize-i[1]*o,t/this.worldSize*this._centerAltitude-i[2]*o]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=e[2];let o=1;r>0&&(o=Math.min((i-this._camera.position[2])/r,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,e,o),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const e=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:o}=this._camera.getPitchBearing(),n=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),a=Math.max((e[2]-n)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);t.scaleAndAdd(e,e,i,a),this._pitch=t.clamp(r,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(o,-Math.PI,Math.PI),this._setZoom(t.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new t.MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(t.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,i){const r=Math.min(e.x,i.x),o=Math.max(e.x,i.x),n=Math.min(e.y,i.y),s=Math.max(e.y,i.y);if(nc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new t.pointGeometry(0,0),new t.pointGeometry(this.width,this.height))}zoomDeltaToMovement(e,i){const r=t.length(t.sub([],this._camera.position,e)),o=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(o)}getCameraPoint(){if("globe"===this.projection.name){const e=function(e,i){const r=[e[0],e[1],e[2],1];t.transformMat4$1(r,r,i);const o=Math.max(r[3],1e-6);return[r[0]/o,r[1]/o,r[2]/o,o]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new t.pointGeometry(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.pointGeometry(0,e))}}getCameraToCenterDistance(t){const e=Nr(t,this.zoom,this.width,this.height,1024),i=t.pixelSpaceConversion(this.center.lat,this.worldSize,e);return.5/Math.tan(.5*this._fov)*this.height*i}}function Xr(t,e){let i=!1,r=null;const o=()=>{r=null,i&&(t(),r=setTimeout(o,e),i=!1)};return()=>(i=!0,r||o(),r)}class Wr{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Xr(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(e){const i=this._map;if(!i)return"";const r=i.getCenter(),o=Math.round(100*i.getZoom())/100,n=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,n),a=Math.round(r.lng*s)/s,l=Math.round(r.lat*s)/s,c=i.getBearing(),u=i.getPitch();let h="";if(h+=e?`/${a}/${l}/${o}`:`${o}/${l}/${a}`,(c||u)&&(h+="/"+Math.round(10*c)/10),u&&(h+=`/${Math.round(u)}`),this._hashName){const e=this._hashName;let i=!1;const r=t.window.location.hash.slice(1).split("&").map((t=>{const r=t.split("=")[0];return r===e?(i=!0,`${r}=${h}`):t})).filter((t=>t));return i||r.push(`${e}=${h}`),`#${r.join("&")}`}return`#${h}`}_getCurrentHash(){const e=t.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((t=>t.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const i=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:i,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,e)}}const Hr={linearity:.3,easing:t.bezier(0,0,.3,1)},Yr=t.extend({deceleration:2500,maxSpeed:1400},Hr),Kr=t.extend({deceleration:20,maxSpeed:1400},Hr),Jr=t.extend({deceleration:1e3,maxSpeed:360},Hr),Qr=t.extend({deceleration:1e3,maxSpeed:90},Hr);class to{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const n=io(i.pan.mag(),r,t.extend({},Yr,e||{}));o.offset=i.pan.mult(n.amount/i.pan.mag()),o.center=this._map.transform.center,eo(o,n)}if(i.zoom){const t=io(i.zoom,r,Kr);o.zoom=this._map.transform.zoom+t.amount,eo(o,t)}if(i.bearing){const e=io(i.bearing,r,Jr);o.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),eo(o,e)}if(i.pitch){const t=io(i.pitch,r,Qr);o.pitch=this._map.transform.pitch+t.amount,eo(o,t)}if(o.zoom||o.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;o.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),o.noMoveStart=!0,o}}function eo(t,e){(!t.duration||t.durationi.unproject(t))),a=n.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new t.pointGeometry(0,0));super(e,{points:n,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class no extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class so{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new no(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ro(t.type,this._map,t))}mouseup(t){this._map.fire(new ro(t.type,this._map,t))}preclick(e){const i=t.extend({},e);i.type="preclick",this._map.fire(new ro(i.type,this._map,i))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new ro(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new ro(t.type,this._map,t))}mouseover(t){this._map.fire(new ro(t.type,this._map,t))}mouseout(t){this._map.fire(new ro(t.type,this._map,t))}touchstart(t){return this._firePreventable(new oo(t.type,this._map,t))}touchmove(t){this._map.fire(new oo(t.type,this._map,t))}touchend(t){this._map.fire(new oo(t.type,this._map,t))}touchcancel(t){this._map.fire(new oo(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ao{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new ro(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ro("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new ro(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lo{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(u(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const r=this._startPos,o=i;if(this.reset(),d(),r.x!==o.x||r.y!==o.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(r,o,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function co(t,e){const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.pointGeometry(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=co(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=co(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class ho{constructor(t){this.singleTap=new uo(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class po{constructor(){this._zoomIn=new ho({numTouches:1,numTaps:2}),this._zoomOut=new ho({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),o=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):o?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(o)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fo={0:1,2:2};class mo{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=_(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const i=fo[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)0&&(this._active=!0);const o=co(r,i),n=new t.pointGeometry(0,0),s=new t.pointGeometry(0,0);let a=0;for(const t in o){const e=o[t],i=this._touches[t];i&&(n._add(e),s._add(e.sub(i)),a++,o[t]=e)}if(this._touches=o,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class vo{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){const r=this._firstTwoTouches;if(!r)return;t.preventDefault();const[o,n]=r,s=bo(i,e,o),a=bo(i,e,n);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,o]=this._firstTwoTouches,n=bo(i,e,r),s=bo(i,e,o);n&&s||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function bo(t,e,i){for(let r=0;rMath.abs(t.x)}class Mo extends vo{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Co(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=this._lastPoints;if(!r)return;const o=t[0].sub(r[0]),n=t[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(o,n,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+n.y)/2*-.5})}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,o=e.mag()>=2;if(!r&&!o)return;if(!r||!o)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=t.y>0==e.y>0;return Co(t)&&Co(e)&&n}}const Ao={panStep:100,bearingStep:15,pitchStep:10};class Io{constructor(){const t=Ao;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,o=0,n=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),o=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),o=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:zo,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-o*this._panStep,-n*this._panStep],center:s.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function zo(t){return t*(2-t)}const ko=4.000244140625;class Po{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=t.exported.now(),o=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%ko==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const e=f(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform,i=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>ko?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==r&&(r=1/r);const o=i(),n=Math.pow(2,o),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):n;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),o=this._startZoom,n=this._easing;let s,a=!1;if("wheel"===this._type&&o&&n){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),i=n(e);s=t.number(o,r,i),e<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,r=(t.exported.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),n=.27/Math.sqrt(o*o+1e-4)*.01,s=Math.sqrt(.0729-n*n);i=t.bezier(n,s,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=n("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!t.window.document.fullscreenElement||!!t.window.document.webkitFullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class Do{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Lo{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Bo{constructor(){this._tap=new ho({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ro{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Fo{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Oo{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Uo=t=>t.zoom||t.drag||t.pitch||t.rotate;class Vo extends t.Event{}class jo{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,i){const r=t.sub([],i,e);this.radius=t.length(r[2]<0?t.div([],r,this.constants):[r[0],r[1],0])}projectRay(e){t.div(e,e,this.constants),t.normalize(e,e),t.mul$1(e,e,this.constants);const i=t.scale$2([],e,this.radius);if(i[2]>0){const e=t.scale$2([],[0,0,1],t.dot(i,[0,0,1])),r=t.scale$2([],t.normalize([],[i[0],i[1],0]),this.radius),o=t.add([],i,t.scale$2([],t.sub([],t.add([],r,e),i),2));i[0]=o[0],i[1]=o[1]}return i}}function No(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Go{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new to(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jo,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[e,i,r]of this._listeners)e.addEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[e,i,r]of this._listeners)e.removeEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new so(e,t));const r=e.boxZoom=new lo(e,t);this._add("boxZoom",r);const o=new po,n=new Lo;e.doubleClickZoom=new Do(n,o),this._add("tapZoom",o),this._add("clickZoom",n);const s=new Bo;this._add("tapDragZoom",s);const a=e.touchPitch=new Mo(e);this._add("touchPitch",a);const l=new go(t),c=new yo(t);e.dragRotate=new Fo(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new _o(t),h=new xo(e,t);e.dragPan=new Ro(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new So,d=new To;e.touchZoomRotate=new Oo(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ao(e));const f=e.scrollZoom=new Po(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new Io;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Uo(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){this._updatingCamera=!0;const i="renderFrame"===t.type,r=i?void 0:t,o={needsRenderFrame:!1},n={},s={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?m(this._el,a):i?void 0:f(this._el,t);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[e||t.type]&&(h=c[e||t.type](t,l,a),this.mergeHandlerResult(o,n,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const t in this._previousActiveHandlers)s[t]||(c[t]=r);this._previousActiveHandlers=s,(Object.keys(c).length||No(o))&&(this._changes.push([o,n,c]),this._triggerRenderFrame()),(Object.keys(s).length||No(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=o;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,r,o,n){if(!r)return;t.extend(e,r);const s={handlerName:o,originalEvent:r.originalEvent||n};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},r={};for(const[o,n,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.pointGeometry(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.aroundCoord&&(e.aroundCoord=o.aroundCoord),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.extend(i,n),t.extend(r,s);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,i,r){const o=this._map,n=o.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!No(e)){const t=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",t!==n.zoom&&this._map._update(!0)}if(!No(e))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=e;void 0!==d&&(h=d),(t=>i.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(n.pointCoordinate3D(h)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",o._stop(!0),h=h||o.transform.centerPoint,c&&(n.bearing+=c),u&&(n.pitch+=u),n._updateCameraState();const f=[0,0,0];if(a){const e=n.pointCoordinate(h);if("globe"===n.projection.name){const i=t.latFromMercatorY(e.y),r=n.center.lat,o=Math.min(t.mercatorZfromAltitude(1,i)/t.mercatorZfromAltitude(1,r),2);a=a.rotate(-n.angle),f[0]=-a.x/n.worldSize*o,f[1]=-a.y/n.worldSize*o}else{const t=n.pointCoordinate(h.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const m=n.zoom,_=[0,0,0];if(l){const e=s(p||n.pointCoordinate3D(h)),i={dir:t.normalize([],t.sub([],e,n._camera.position))};if(i.dir[2]<0){const r=n.zoomDeltaToMovement(e,l);t.scale$2(_,i.dir,r)}}const g=t.add(f,f,_);n._translateCameraConstrained(g),l&&Math.abs(n.zoom-m)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,r,!0)}_fireEvents(e,i,r){const o=Uo(this._eventsInProgress),n=Uo(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!o&&n&&this._fireEvent("movestart",n.originalEvent);for(const t in s)this._fireEvent(t,s[t]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||r,a[`${t}end`]=l)}for(const t in a)this._fireEvent(t,a[t]);const c=Uo(this._eventsInProgress);if(r&&(o||n)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Vo("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Zo="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class $o extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,r){return e=t.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.extend({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,r){return this.easeTo(t.extend({zoom:e},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,r){return this.easeTo(t.extend({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())T=>{if(x&&(r.zoom=t.number(o,l,T)),v&&(r.bearing=t.number(n,c,T)),b&&(r.pitch=t.number(s,u,T)),w&&(r.interpolatePadding(a,h,T),d=r.centerPoint.add(p)),g)r.setLocationAtPoint(g,y);else{const t=r.zoomScale(r.zoom-o),e=l>o?Math.min(2,_):Math.max(.5,_),i=Math.pow(e,1-T),n=r.unproject(f.add(m.mult(T*i)).mult(t));r.setLocationAtPoint(r.renderWorldCopies?n.wrap():n,d)}return e.preloadOnly||this._fireMoveEvents(i),r};if(e.preloadOnly){const t=this._emulate(T,e.duration,r);return this._preloadTiles(t),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,E),this._ease(T(r),(t=>{r.recenterOnTerrain(),this._afterEase(i,t)}),e),this}_prepareEase(e,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,o=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),o&&this.fire(new t.Event("rotateend",e)),n&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(!e.essential&&t.exported.prefersReducedMotion){const r=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const r=this.transform,o=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,r.minZoom,r.maxZoom):o,c="bearing"in e?this._normalizeBearing(e.bearing,n):n,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:r.padding,p=r.zoomScale(l-o),d=t.pointGeometry.convert(e.offset);let f=r.centerPoint.add(d);const m=r.pointLocation(f),_=t.LngLat.convert(e.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=e.curve;const v=Math.max(r.width,r.height),b=v/p,w=y.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,o,l),r.minZoom,r.maxZoom),n=v/r.zoomScale(i-o);x=Math.sqrt(n/w*2)}const T=x*x;function E(t){const e=(b*b-v*v+(t?-1:1)*T*T*w*w)/(2*(t?b:v)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function C(t){return(Math.exp(t)+Math.exp(-t))/2}const M=E(0);let A=function(t){return C(M)/C(M+x*t)},I=function(t){return v*((C(M)*(S(e=M+x*t)/C(e))-S(M))/T)/w;var e},z=(E(1)-M)/x;if(Math.abs(w)<1e-6||!isFinite(z)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,i);const t=be.maxDuration&&(e.duration=0);const k=n!==c,P=u!==s,D=!r.isPaddingEqual(h),L=r=>p=>{const m=p*z,x=1/A(m);r.zoom=1===p?l:o+r.scaleZoom(x),k&&(r.bearing=t.number(n,c,p)),P&&(r.pitch=t.number(s,u,p)),D&&(r.interpolatePadding(a,h,p),f=r.centerPoint.add(d));const v=1===p?_:r.unproject(g.add(y.mult(I(m))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(i),r};if(e.preloadOnly){const t=this._emulate(L,e.duration,r);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=k,this._pitching=P,this._padding=D,this._prepareEase(i,!1),this._ease(L(r),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,r){!1===r.animate||0===r.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)180?-360:i<-180?360:0}_emulate(t,e,i){const r=Math.ceil(15*e/1e3),o=[],n=t(i.clone());for(let t=0;t<=r;t++){const e=n(t/r);o.push(e.clone())}return o}}class qo{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=n("button","mapboxgl-ctrl-attrib-button",this._container),n("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",i),t.removeAttribute("title"),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){const r=i.reduce(((t,e,r)=>(e.value&&(t+=`${e.key}=${e.value}${rt.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Xo{constructor(){t.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=n("div","mapboxgl-ctrl");const e=n("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class Wo{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ho(e,i,r){if(e=new t.LngLat(e.lng,e.lat),i){const o=new t.LngLat(e.lng-360,e.lat),n=new t.LngLat(e.lng+360,e.lat),s=360*Math.ceil(Math.abs(e.lng-r.center.lng)/360),a=r.locationPoint(e).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(o).distSqr(i)180;){const t=r.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}const Yo={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Ko extends t.Evented{constructor(e,i){if(super(),(e instanceof t.window.HTMLElement||i)&&(e=t.extend({element:e},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),e&&e.element)this._element=e.element,this._offset=t.pointGeometry.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=n("div");const i=41,r=27,o=s("svg",{display:"block",height:i*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},o));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},o),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},o),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),this._offset=t.pointGeometry.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const r=this._element.classList;for(const t in Yo)r.remove(`mapboxgl-marker-anchor-${t}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,t._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const t=this._map;if(!t)return!1;const e=t.unproject(this._pos),i=t.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(e)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const i=this._pos;if(!i||i.x<0||i.x>e.transform.width||i.y<0||i.y>e.transform.height)return void this._clearFadeTimer();const r=e.unproject(i);let o;e._usingGlobe()&&t.isLngLatBehindGlobe(e.transform,this._lngLat)?o=0:(o=1-e._queryFogOpacity(r),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(o*=.2)),this._element.style.opacity=`${o}`,this._element.style.pointerEvents=o>0?"auto":"none",this._popup&&this._popup._setOpacity(o),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t||!this._map)return;const e=this._calculateXYTransform()+this._calculateZTransform(),i=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${t.x}px,${t.y}px) ${Yo[this._anchor]}\n ${e}\n translate(${i.x}px,${i.y}px)\n `}_calculateXYTransform(){const e=this._pos,i=this._map;if("map"!==this.getPitchAlignment()||!i||!e)return"";if(!i._usingGlobe()){const t=i.getPitch();return t?`rotateX(${t}deg)`:""}const r=t.radToDeg(t.globeTiltAtLngLat(i.transform,this._lngLat)),o=e.sub(t.globeCenterToScreenPoint(i.transform)),n=r/(Math.abs(o.x)+Math.abs(o.y)),s=o.x*n,a=-o.y*n;return a||s?`rotateX(${a}deg) rotateY(${s}deg)`:""}_calculateZTransform(){const t=this._calculateRotation();return t?`rotateZ(${t}deg)`:""}_calculateRotation(){if("viewport"===this._rotationAlignment||"auto"===this._rotationAlignment)return this._rotation;if(this._map&&"map"===this._rotationAlignment){const e=this._map;if(this._pos&&e&&e._usingGlobe()){const i=e.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=e.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(i);return this._rotation+t.radToDeg(Math.atan2(r.y,r.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(e){t.window.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=Ho(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===e?this._updateFrameId=t.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._usingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=t.pointGeometry.convert(e),this._update(),this}_onMove(e){const i=this._map;if(i){if(!this._isDragging){const t=this._clickTolerance||i._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(t){const e=this._map;e&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos),this._pointerdownPos=t.point,this._state="pending",e.on("mousemove",this._onMove),e.on("touchmove",this._onMove),e.once("mouseup",this._onUp),e.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const e=this._map;return e&&(t?(e.on("mousedown",this._addDragHandler),e.on("touchstart",this._addDragHandler)):(e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class Jo{constructor(t){this.jumpTo(t)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const i=t.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const Qo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},tn={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function en(t){t.parentNode&&t.parentNode.removeChild(t)}const rn={showCompass:!0,showZoom:!0,visualizePitch:!1};class on{constructor(e,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new go({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,r&&(this.mousePitch=new yo({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),u()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e),o=r&&r.bearingDelta;if(o&&i.setBearing(i.getBearing()+o),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e),o=r&&r.pitchDelta;o&&i.setPitch(i.getPitch()+o)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),t.window.removeEventListener("mousemove",this.mousemove),t.window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),f(this.element,e)),t.window.addEventListener("mousemove",this.mousemove),t.window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,f(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=m(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._container.style.width=t*o+"px",this._container.innerHTML=`${r} ${n}`}))}function ln(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}const cn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},un=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function hn(e=new t.pointGeometry(0,0),i="bottom"){if("number"==typeof e){const r=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(i){case"top":return new t.pointGeometry(0,e);case"top-left":return new t.pointGeometry(r,r);case"top-right":return new t.pointGeometry(-r,r);case"bottom":return new t.pointGeometry(0,-e);case"bottom-left":return new t.pointGeometry(r,-r);case"bottom-right":return new t.pointGeometry(-r,-r);case"left":return new t.pointGeometry(e,0);case"right":return new t.pointGeometry(-e,0)}return new t.pointGeometry(0,0)}return e instanceof t.pointGeometry||Array.isArray(e)?t.pointGeometry.convert(e):t.pointGeometry.convert(e[i]||[0,0])}const pn={version:t.version,supported:i,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends $o{constructor(e){if(null!=(e=t.extend({},tn,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&t.isSafariWithAntialiasingBug(t.window)&&(e.antialias=!1,t.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new qr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._language="auto"===e.language?t.window.navigator.language:e.language,this._worldview=e.worldview,this._renderTaskQueue=new Wo,this._domRenderTaskQueue=new Wo,this._controls=[],this._markers=[],this._mapId=t.uniqueId(),this._locale=t.extend({},Qo,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Jo(0),this._explicitProjection=null,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof t.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&t.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1),t.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new Go(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),this._hash=e.hash&&new Wr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),e.attributionControl&&this.addControl(new qo({customAttribution:e.customAttribution})),this._logoControl=new Xo,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new t.Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return-1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)),this.fire(new t.Event("resize",e)),i&&this.fire(new t.Event("moveend",e)),this}getBounds(){return"globe"===this.transform.projection.name&&t.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getLanguage(){return this._language}setLanguage(e){if(this._language="auto"===e?t.window.navigator.language:e,this.style)for(const t in this.style._sourceCaches){const e=this.style._sourceCaches[t]._source;e._setLanguage&&e._setLanguage(this._language)}for(const t of this._controls)t._setLanguage&&t._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(t){if(this._worldview=t,this.style)for(const e in this.style._sourceCaches){const i=this.style._sourceCaches[e]._source;i._setWorldview&&i._setWorldview(t)}return this}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}_usingGlobe(){return"globe"===this.transform.projection.name}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._updateProjection(t)}_updateProjection(e){const i=this.getProjection();null===e&&(this._explicitProjection=null);const r=e||this.getProjection();let o;if(r&&"globe"===r.name&&this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?(o=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(o=this.transform.setProjection(r),this.transform.mercatorFromTransition=!1),e&&(this._explicitProjection="globe"===e.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),o){if("globe"===i.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles()}this._update(!0)}return this}project(e){return this.transform.locationPoint3D(t.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(t.pointGeometry.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const o=o=>{const n=e.filter((t=>this.getLayer(t))),s=n.length?this.queryRenderedFeatures(o.point,{layers:n}):[];s.length?r||(r=!0,i.call(this,new ro(t,this,o.originalEvent,{features:s}))):r=!1},n=()=>{r=!1};return{layers:new Set(e),listener:i,delegates:{mousemove:o,mouseout:n}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const o=o=>{const n=e.filter((t=>this.getLayer(t)));(n.length?this.queryRenderedFeatures(o.point,{layers:n}):[]).length?r=!0:r&&(r=!1,i.call(this,new ro(t,this,o.originalEvent)))},n=e=>{r&&(r=!1,i.call(this,new ro(t,this,e.originalEvent)))};return{layers:new Set(e),listener:i,delegates:{mousemove:o,mouseout:n}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),o=r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];o.length&&(t.features=o,i.call(this,t),delete t.features)};return{layers:new Set(e),listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){if(void 0===i)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const r=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},o=this._delegatedListeners?this._delegatedListeners[t]:void 0;return o&&(t=>{for(let o=0;o{e?this.fire(new t.ErrorEvent(e)):r&&this._updateDiff(r,i)}))}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e)&&this._update(!0)}catch(r){t.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(t.warnOnce("There is no style added to the map."),!1)}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return!!this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,{pixelRatio:r=1,sdf:o=!1,stretchX:n,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap){const{width:l,height:c,data:u}=t.exported.getImageData(i);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},u),pixelRatio:r,stretchX:n,stretchY:s,content:a,sdf:o,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=i,u=i;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:r,stretchX:n,stretchY:s,content:a,sdf:o,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return void this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap?t.exported.getImageData(i):i,{width:n,height:s}=o;void 0!==n&&void 0!==s?n===r.data.width&&s===r.data.height?(r.data.replace(o.data,!(i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new t.ErrorEvent(new Error(`The width and height of the updated image (${n}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,i){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),((e,r)=>{i(e,r instanceof t.window.HTMLImageElement?t.exported.getImageData(r):r)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(e),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,o,n,s=this._container;for(;s&&(!o||!n);){const e=t.window.getComputedStyle(s).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(o=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(n=r[3])),s=s.parentElement}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=n?Math.abs(i/n):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&t.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=n("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=n("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=n("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=n("div","mapboxgl-control-container",t),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{r[t]=n("div",`mapboxgl-ctrl-${t}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,i){const r=t.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(e),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${i}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_setupPainter(){const e=t.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);r?(t.storeAuthState(r,!0),this.painter=new Dr(r,this.transform),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(e){let i;const r=this.painter.context.extTimerQuery,o=t.exported.now();if(this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let n=!1;const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=this.transform.pitch,r=t.exported.now();this.style.zoomHistory.update(e,r);const o=new t.EvaluationParameters(e,{now:r,fadeDuration:s,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=o.crossFadingFactor();1===a&&a===this._crossFadingFactor||(n=!0,this._crossFadingFactor=a),this.style.update(o)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(o),this.style._updateSources(this.transform),this._forceMarkerUpdate()):a=this._updateAverageElevation(o),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const e=t.exported.now()-o;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout((()=>{const n=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:n})),t.window.performance.mark("frame-gpu",{startTime:o,detail:{gpuTime:n}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(e);this.fire(new t.Event("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(a=this._updateAverageElevation(o,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const t of this._markers)t._update()}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),o=!1;this.transform.elevation&&(o=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=t;const n=Math.abs(e-r);if(n>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,t,300)}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===t.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;t.storeAuthState(e,!1),this._logoControl instanceof Xo&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function o(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(o(t),e.canvasCopies.map(o),e.timeStamps)}_canvasPixelComparison(t,e,i){let r=i[1]-i[0];const o=t.length/4;for(let n=0;n{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(e){const i=this.style?Object.values(this.style._sourceCaches):[];return t.asyncAll(i,((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(e,i){t.setCacheLimits(e,i)}get version(){return t.version}},NavigationControl:class{constructor(e){this.options=t.extend({},rn,e),this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),n("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),n("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=n("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),i=e===t.getMaxZoom(),r=e===t.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new on(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const i=n("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",i),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({geolocation:t.window.navigator.geolocation},nn,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Xr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(t){return this._map=t,this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((t=>{this._supportsGeolocation="denied"!==t.state,e(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.options.geolocation,e(this._supportsGeolocation))}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return!!e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),n=t.extend({bearing:o},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),n,{geolocateSource:!0})}_updateMarker(e){if(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,i=t.mercatorZfromAltitude(1,e._center.lat)*e.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=n("button","mapboxgl-ctrl-geolocate",this._container),n("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n("div","mapboxgl-user-location"),this._dotElement.appendChild(n("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(n("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ko({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=n("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ko({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{t.window.addEventListener("ondeviceorientationabsolute"in t.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==t.window.DeviceMotionEvent&&"function"==typeof t.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.window.removeEventListener("deviceorientation",this._onDeviceOrientation),t.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:qo,ScaleControl:class{constructor(e){this.options=t.extend({},sn,e),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(t){return!1}}()||(this._setScale=an.bind(this)),t.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const t=this.options.maxWidth||100,e=this._map,i=e._containerHeight/2,r=e._containerWidth/2-t/2,o=e.unproject([r,i]),n=e.unproject([r+t,i]),s=o.distanceTo(n);if("imperial"===this.options.unit){const e=3.2808*s;e>5280?this._setScale(t,e/5280,"mile"):this._setScale(t,e,"foot")}else"nautical"===this.options.unit?this._setScale(t,s/1852,"nautical-mile"):s>=1e3?this._setScale(t,s/1e3,"kilometer"):this._setScale(t,s,"meter")}_setScale(t,e,i){const r=ln(e),o=r/e;this._map._requestDomTask((()=>{this._container.style.width=t*o+"px",this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:i}).format(r):`${r} nm`}))}onAdd(t){return this._map=t,this._language=t.getLanguage(),this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(t){this._language=t,this._update()}setUnit(t){this.options.unit=t,this._update()}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=n("button","mapboxgl-ctrl-fullscreen",this._controlContainer);n("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(cn),e),t.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.window.document.createTextNode(e))}setHTML(e){const i=t.window.document.createDocumentFragment(),r=t.window.document.createElement("body");let o;for(r.innerHTML=e;o=r.firstChild,o;)i.appendChild(o);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=n("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=n("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="×",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,i=this._container,r=this._pos;if(!e||!i||!r)return"bottom";const o=i.offsetWidth,n=i.offsetHeight,s=r.xe.transform.width-o/2;if(r.y+te.transform.height-n){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(e){const i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let o=this._container;if(o||(o=this._container=n("div","mapboxgl-popup",i.getContainer()),this._tip=n("div","mapboxgl-popup-tip",o),o.appendChild(r)),this.options.maxWidth&&o.style.maxWidth!==this.options.maxWidth&&(o.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ho(this._lngLat,this._pos,i.transform)),!this._trackPointer||e){const t=this._pos=this._trackPointer&&e?e:i.project(this._lngLat),r=hn(this.options.offset),o=this._anchor=this._getAnchor(r.y),n=hn(this.options.offset,o),s=t.add(n).round();i._requestDomTask((()=>{this._container&&o&&(this._container.style.transform=`${Yo[o]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._usingGlobe()){const e=t.isLngLatBehindGlobe(i.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(un);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._container&&(this._container.style.opacity=`${t}`),this._content&&(this._content.style.pointerEvents=t?"auto":"none")}},Marker:Ko,Style:ti,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.pointGeometry,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:Or,Evented:t.Evented,config:t.config,prewarm:function(){jt().acquire(Ot)},clearPrewarmedResources:function(){const t=Vt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Ot),Vt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Ut.workerCount},set workerCount(t){Ut.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return pn})),i}()},155:t=>{var e,i,r=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===o||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(i){try{return e.call(null,t,0)}catch(i){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:o}catch(t){e=o}try{i="function"==typeof clearTimeout?clearTimeout:n}catch(t){i=n}}();var a,l=[],c=!1,u=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):u=-1,l.length&&p())}function p(){if(!c){var t=s(h);c=!0;for(var e=l.length;e;){for(a=l,l=[];++u1)for(var i=1;i{"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},n=function(){var t={};return function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}t[e]=i}return t[e]}}(),s=[];function a(t){for(var e=-1,i=0;i{"use strict";e.Z=(t,e)=>{const i=t.__vccOpts||t;for(const[t,r]of e)i[t]=r;return i}}},e={};function i(r){var o=e[r];if(void 0!==o)return o.exports;var n=e[r]={id:r,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.nc=void 0,(()=>{"use strict";const t=Vue;var e=function(e){return(0,t.pushScopeId)("data-v-16283323"),e=e(),(0,t.popScopeId)(),e}((function(){return(0,t.createElementVNode)("div",{id:"mapContainer",class:"basemap"},null,-1)}));var r=i(158),o=i.n(r);const n={props:["index","resource","resourceName","resourceId","field"],data:function(){return{map:null,draw:null,geoJsonSource:{type:"geojson",data:{type:"Feature",geometry:this.field.geoJson}}}},mounted:function(){var t=this;o().accessToken=this.field.accessToken;var e=this.field.longitude,i=this.field.latitude,r={container:"mapContainer",style:"mapbox://styles/mapbox/streets-v11",center:[e,i],zoom:this.field.zoom||10};this.map=new(o().Map)(r),this.map.addControl(new(o().NavigationControl)({showCompass:!1}),"top-left"),this.map.on("load",(function(){t.map.addSource("layer",t.geoJsonSource),t.map.addLayer({id:"layer",type:"fill",source:"layer",layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5}}),(new(o().Marker)).setLngLat([e,i]).addTo(t.map)}))}};var s=i(379),a=i.n(s),l=i(309),c={insert:"head",singleton:!1};a()(l.Z,c);l.Z.locals;const u=(0,i(744).Z)(n,[["render",function(i,r,o,n,s,a){var l=(0,t.resolveComponent)("PanelItem");return(0,t.openBlock)(),(0,t.createBlock)(l,{index:o.index,field:o.field},{value:(0,t.withCtx)((function(){return[e]})),_:1},8,["index","field"])}],["__scopeId","data-v-16283323"]]);Nova.booting((function(t,e){t.component("detail-nova-mapbox-marker-field",u)}))})()})(); \ No newline at end of file +(()=>{var t={562:(t,e,i)=>{"use strict";i.d(e,{Z:()=>n});var r=i(645),o=i.n(r)()((function(t){return t[1]}));o.push([t.id,".mapboxgl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.mapboxgl-canvas{position:absolute;left:0;top:0}.mapboxgl-map:-webkit-full-screen{width:100%;height:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{position:absolute;pointer-events:none;z-index:2}.mapboxgl-ctrl-top-left{top:0;left:0}.mapboxgl-ctrl-top-right{top:0;right:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{right:0;bottom:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:10px 0 0 10px;float:left}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{margin:10px 10px 0 0;float:right}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{margin:0 0 10px 10px;float:left}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{margin:0 10px 10px 0;float:right}.mapboxgl-ctrl-group{border-radius:4px;background:#fff}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgb(0 0 0/10%)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{width:29px;height:29px;display:block;padding:0;outline:none;border:0;box-sizing:border-box;background-color:transparent;cursor:pointer;overflow:hidden}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{display:block;width:100%;height:100%;background-repeat:no-repeat;background-position:50%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px rgb(0 150 255/100%)}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px rgb(0 150 255/100%)}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E %3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg'%3E %3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E %3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E %3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E %3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E %3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E %3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='red'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='red'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E %3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%3E %3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E %3Ccircle id='dot' cx='10' cy='10' r='2'/%3E %3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='red'/%3E %3C/svg%3E\")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{width:88px;height:23px;margin:0 0 -4px -4px;display:block;background-repeat:no-repeat;cursor:pointer;overflow:hidden;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='88' height='23' viewBox='0 0 88 23' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd'%3E %3Cdefs%3E %3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E %3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E %3C/defs%3E %3Cmask id='clip'%3E %3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/mask%3E %3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E %3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E %3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E %3C/g%3E %3Cg id='fill' opacity='0.9' fill='%23fff'%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/g%3E %3C/svg%3E\")}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='88' height='23' viewBox='0 0 88 23' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd'%3E %3Cdefs%3E %3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E %3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E %3C/defs%3E %3Cmask id='clip'%3E %3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/mask%3E %3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E %3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E %3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E %3C/g%3E %3Cg id='fill' opacity='1' fill='%23fff'%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/g%3E %3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='88' height='23' viewBox='0 0 88 23' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd'%3E %3Cdefs%3E %3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E %3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E %3C/defs%3E %3Cmask id='clip'%3E %3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/mask%3E %3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E %3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E %3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E %3C/g%3E %3Cg id='fill' opacity='1' fill='%23000'%3E %3Cuse xlink:href='%23logo'/%3E %3Cuse xlink:href='%23text'/%3E %3C/g%3E %3C/svg%3E\")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{padding:0 5px;background-color:rgb(255 255 255/50%);margin:0}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{min-height:20px;padding:2px 24px 2px 0;margin:10px;position:relative;background-color:#fff;border-radius:12px}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 8px 2px 28px;border-radius:12px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{display:none;cursor:pointer;position:absolute;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E %3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E %3C/svg%3E\");background-color:rgb(255 255 255/50%);width:24px;height:24px;box-sizing:border-box;border-radius:12px;outline:none;top:0;right:0;border:0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner,.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{top:0;right:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{top:0;left:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%3E %3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E %3C/svg%3E\")}}@media screen and (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='24' height='24' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E %3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E %3C/svg%3E\")}}.mapboxgl-ctrl-attrib a{color:rgb(0 0 0/75%);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:rgb(255 255 255/75%);font-size:10px;border:2px solid #333;border-top:#333;padding:0 5px;color:#333;box-sizing:border-box;white-space:nowrap}.mapboxgl-popup{position:absolute;top:0;left:0;display:flex;will-change:transform;pointer-events:none}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{width:0;height:0;border:10px solid transparent;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-top:none;border-bottom-color:#fff}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-top:none;border-left:none;border-bottom-color:#fff}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-top:none;border-right:none;border-bottom-color:#fff}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-right:none;border-left-color:#fff}.mapboxgl-popup-close-button{position:absolute;right:0;top:0;border:0;border-radius:0 3px 0 0;cursor:pointer;background-color:transparent}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{position:relative;background:#fff;border-radius:3px;box-shadow:0 1px 2px rgb(0 0 0/10%);padding:10px 10px 15px;pointer-events:auto}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{position:absolute;top:0;left:0;will-change:transform;opacity:1;transition:opacity .2s}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;width:15px;height:15px;border-radius:50%}.mapboxgl-user-location-dot:before{content:\"\";position:absolute;animation:mapboxgl-user-location-dot-pulse 2s infinite}.mapboxgl-user-location-dot:after{border-radius:50%;border:2px solid #fff;content:\"\";height:19px;left:-2px;position:absolute;top:-2px;width:19px;box-sizing:border-box;box-shadow:0 0 3px rgb(0 0 0/35%)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{width:0;height:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{content:\"\";border-bottom:7.5px solid #4aa1eb;position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{transform:scale(1);opacity:1}70%{transform:scale(3);opacity:0}to{transform:scale(1);opacity:0}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:rgba(29,161,242,.2);width:1px;height:1px;border-radius:100%}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{position:absolute;top:0;left:0;width:0;height:0;background:#fff;border:2px dotted #202020;opacity:.5}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{color:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;justify-content:center;text-align:center;position:absolute;display:flex;align-items:center;top:0;left:0;width:100%;height:100%;background:rgb(0 0 0/70%);opacity:0;pointer-events:none;transition:opacity .75s ease-in-out;transition-delay:1s}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y}",""]);const n=o},349:(t,e,i)=>{"use strict";i.d(e,{Z:()=>a});var r=i(645),o=i.n(r),n=i(562),s=o()((function(t){return t[1]}));s.i(n.Z),s.push([t.id,"#mapContainer[data-v-2055c4ea]{height:450px}",""]);const a=s},645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i=t(e);return e[2]?"@media ".concat(e[2]," {").concat(i,"}"):i})).join("")},e.i=function(t,i,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var n=0;n(r=1))return r;for(;in?i=o:r=o,o=.5*(r-i)+i}return o},o.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var n=s;function s(t,e){this.x=t,this.y=e}s.prototype={clone:function(){return new s(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),o=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},s.convert=function(t){return t instanceof s?t:Array.isArray(t)?new s(t[0],t[1]):t};const a=Math.PI/180,l=180/Math.PI;function c(t){return t*a}function u(t){return t*l}const h=[[0,0],[1,0],[1,1],[0,1]];function p(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function d(t,e,r,o){const n=new i(t,e,r,o);return function(t){return n.solve(t)}}const f=d(.25,.1,.25,1);function m(t,e,i){return Math.min(i,Math.max(e,t))}function _(t,e,i){return(i=m((i-t)/(e-t),0,1))*i*(3-2*i)}function g(t,e,i){const r=i-e,o=((t-e)%r+r)%r+e;return o===e?i:o}function y(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const o=new Array(t.length);let n=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(n=t),o[s]=e,0==--r&&i(n,o)}))}))}function x(t){const e=[];for(const i in t)e.push(t[i]);return e}function v(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let b=1;function w(){return b++}function T(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function E(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function S(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function C(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function M(t,e){return-1!==t.indexOf(e,t.length-e.length)}function A(t,e,i){const r={};for(const o in t)r[o]=e.call(i||this,t[o],o,t);return r}function I(t,e,i){const r={};for(const o in t)e.call(i||this,t[o],o,t)&&(r[o]=t[o]);return r}function z(t){return Array.isArray(t)?t.map(z):"object"==typeof t&&t?A(t,z):t}const k={};function P(t){k[t]||("undefined"!=typeof console&&console.warn(t),k[t]=!0)}function D(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function L(t){let e=0;for(let i,r,o=0,n=t.length,s=n-1;o@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,o)=>{const n=r||o;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let F=null;function O(t){if(null==F){const e=t.navigator?t.navigator.userAgent:null;F=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return F}function U(t){try{const i=e[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function V(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const j=e.performance;function N(t){const e=t?t.url.toString():void 0;return j.getEntriesByName(e)}var G="2.9.2";let Z,$,q,X;const W={now:()=>void 0!==q?q:e.performance.now(),setNow(t){q=t},restoreNow(){q=void 0},frame(t){const i=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(i)}},getImageData(t,i=0){const{width:r,height:o}=t;X||(X=e.document.createElement("canvas"));const n=X.getContext("2d");if(!n)throw new Error("failed to create canvas 2d context");return(r>X.width||o>X.height)&&(X.width=r,X.height=o),n.clearRect(-i,-i,r+2*i,o+2*i),n.drawImage(t,0,0,r,o),n.getImageData(-i,-i,r+2*i,o+2*i)},resolveURL:t=>(Z||(Z=e.document.createElement("a")),Z.href=t,Z.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==$&&($=e.matchMedia("(prefers-reduced-motion: reduce)")),$.matches)}};let H;const Y={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==H){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{H=null!=r.env.API_URL_REGEX?new RegExp(r.env.API_URL_REGEX):t}catch(e){H=t}}return H},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},K={supported:!1,testSupport:function(t){!tt&&Q&&(et?it(t):J=t)}};let J,Q,tt=!1,et=!1;function it(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Q),t.isContextLost())return;K.supported=!0}catch(t){}t.deleteTexture(e),tt=!0}e.document&&(Q=e.document.createElement("img"),Q.onload=function(){J&&it(J),J=null,et=!0},Q.onerror=function(){tt=!0,J=null},Q.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const rt="01",ot="NO_ACCESS_TOKEN";function nt(t){return 0===t.indexOf("mapbox:")}function st(t){return Y.API_URL_REGEX.test(t)}const at=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function lt(t){const e=t.match(at);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function ct(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}function ut(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(i[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class ht{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=ut(Y.ACCESS_TOKEN);let r="";return r=i&&i.u?e.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):Y.ACCESS_TOKEN||"",t?`mapbox.eventData.${t}:${r}`:`mapbox.eventData:${r}`}fetchEventData(){const t=U("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));const o=e.localStorage.getItem(r);o&&(this.anonId=o)}catch(t){P("Unable to read from LocalStorage")}}saveEventData(){const t=U("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(t){P("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,r){if(!Y.EVENTS_URL)return;const o=lt(Y.EVENTS_URL);o.params.push(`access_token=${r||Y.ACCESS_TOKEN||""}`);const n={event:this.type,created:new Date(t).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:G,skuId:rt,userId:this.anonId},s=e?v(n,e):n,a={url:ct(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=Dt(a,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const pt=new class extends ht{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){Y.EVENTS_URL&&Y.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>nt(t)||st(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=ut(Y.ACCESS_TOKEN),i=e?e.u:Y.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;S(this.anonId)||(this.anonId=T(),r=!0);const o=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(o),i=(o-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||t.getDate()!==e.getDate()}else r=!0;r?this.postEvent(o,{"enabled.telemetry":!1},(t=>{t||(this.eventData.lastSuccess=o,this.eventData.tokenU=i)}),t):this.processRequests()}},dt=pt.postTurnstileEvent.bind(pt),ft=new class extends ht{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,r){this.skuToken=e,this.errorCb=r,Y.EVENTS_URL&&(i||Y.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(ot)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),S(this.anonId)||(this.anonId=T()),this.postEvent(i,{skuToken:this.skuToken},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},mt=ft.postMapLoadEvent.bind(ft),_t=new class extends ht{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,r){if(!Y.API_URL||!Y.SESSION_PATH)return;const o=lt(Y.API_URL+Y.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${r||Y.ACCESS_TOKEN||""}`);const n={url:ct(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=Lt(n,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(r)}))}getSessionAPI(t,e,i,r){this.skuToken=e,this.errorCb=r,Y.SESSION_PATH&&Y.API_URL&&(i||Y.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(ot)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},gt=_t.getSessionAPI.bind(_t),yt=new Set;let xt,vt=500,bt=50,wt={};function Tt(t){const e=St(t);let i,r;e&&e.forEach((t=>{const e=t.split("=");"language"===e[0]?i=e[1]:"worldview"===e[0]&&(r=e[1])}));let o="mapbox-tiles";return i&&(o+=`-${i}`),r&&(o+=`-${r}`),o}function Et(t){e.caches&&!wt[t]&&(wt[t]=e.caches.open(t))}function St(t){const e=t.indexOf("?");return e>0?t.slice(e+1).split("&"):[]}function Ct(t){const e=t.indexOf("?");if(e<0)return t;const i=St(t).filter((t=>{const e=t.split("=");return"language"===e[0]||"worldview"===e[0]}));return i.length?`${t.slice(0,e)}?${i.join("&")}`:t.slice(0,e)}let Mt=1/0;const At={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(At);class It extends Error{constructor(t,e,i){401===e&&st(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const zt=B()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href,kt=function(t,i){if(!(/^file:/.test(r=t.url)||/^file:/.test(zt())&&!/^\w+:/.test(r))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,i){const r=new e.AbortController,o=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:zt(),signal:r.signal});let n=!1,s=!1;const a=(l=o.url).indexOf("sku=")>0&&st(l);var l;"json"===t.type&&o.headers.set("Accept","application/json");const c=(r,n,l)=>{if(s)return;if(r&&"SecurityError"!==r.message&&P(r),n&&l)return u(n);const c=Date.now();e.fetch(o).then((e=>{if(e.ok){const t=a?e.clone():null;return u(e,t,c)}return i(new It(e.statusText,e.status,t.url))})).catch((t=>{20!==t.code&&i(new Error(t.message))}))},u=(r,a,l)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{s||(a&&l&&function(t,i,r){const o=Tt(t.url);if(Et(o),!wt[o])return;const n={status:i.status,statusText:i.statusText,headers:new e.Headers};i.headers.forEach(((t,e)=>n.headers.set(e,t)));const s=R(i.headers.get("Cache-Control")||"");if(s["no-store"])return;s["max-age"]&&n.headers.set("Expires",new Date(r+1e3*s["max-age"]).toUTCString());const a=n.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(t,e){if(void 0===xt)try{new Response(new ReadableStream),xt=!0}catch(t){xt=!1}xt?e(t.body):t.blob().then(e)}(i,(i=>{const r=new e.Response(i,n);Et(o),wt[o]&&wt[o].then((e=>e.put(Ct(t.url),r))).catch((t=>P(t.message)))})))}(o,a,l),n=!0,i(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((t=>{s||i(new Error(t.message))}))};return a?function(t,e){const i=Tt(t.url);if(Et(i),!wt[i])return e(null);const r=Ct(t.url);wt[i].then((t=>{t.match(r).then((i=>{const o=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=R(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(i);t.delete(r),o&&t.put(r,i.clone()),e(null,i,o)})).catch(e)})).catch(e)}(o,c):c(null,null),{cancel:()=>{s=!0,n||r.abort()}}}(t,i);if(B()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,i,void 0,!0)}var r;return function(t,i){const r=new e.XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{i(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(t){return i(t)}i(null,e,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else i(new It(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(t,i)},Pt=function(t,e){return kt(v(t,{type:"arrayBuffer"}),e)},Dt=function(t,e){return kt(v(t,{method:"POST"}),e)},Lt=function(t,e){return kt(v(t,{method:"GET"}),e)};function Bt(t){const i=e.document.createElement("a");return i.href=t,i.protocol===e.document.location.protocol&&i.host===e.document.location.host}const Rt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ft,Ot;Ft=[],Ot=0;const Ut=function(t,i){if(K.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),Ot>=Y.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return Ft.push(e),e}Ot++;let r=!1;const o=()=>{if(!r)for(r=!0,Ot--;Ft.length&&Ot{o(),t?i(t):r&&(e.createImageBitmap?function(t,i){const r=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(r).then((t=>{i(null,t)})).catch((t=>{i(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(r,((t,e)=>i(t,e,n,s))):function(t,i){const r=new e.Image,o=e.URL;r.onload=()=>{i(null,r),o.revokeObjectURL(r.src),r.onload=null,e.requestAnimationFrame((()=>{r.src=Rt}))},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new e.Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?o.createObjectURL(n):Rt}(r,((t,e)=>i(t,e,n,s))))}));return{cancel:()=>{n.cancel(),o()}}};function Vt(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function jt(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class Nt{constructor(t,e={}){v(this,e),this.type=t}}class Gt extends Nt{constructor(t,e={}){super("error",v({error:t},e))}}class Zt{on(t,e){return this._listeners=this._listeners||{},Vt(t,e,this._listeners),this}off(t,e){return jt(t,e,this._listeners),jt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Vt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Nt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)jt(i,e,this._oneTimeListeners),e.call(this,t);const o=this._eventedParent;o&&(v(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),o.fire(t))}else t instanceof Gt&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var $t=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function qt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function Xt(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Wt(t){if(Array.isArray(t))return t.map(Wt);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Wt(t[i]);return e}return Xt(t)}class Ht extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var Yt=Ht;class Kt{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Kt(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var Jt=Kt;const Qt={kind:"null"},te={kind:"number"},ee={kind:"string"},ie={kind:"boolean"},re={kind:"color"},oe={kind:"object"},ne={kind:"value"},se={kind:"collator"},ae={kind:"formatted"},le={kind:"resolvedImage"};function ce(t,e){return{kind:"array",itemType:t,N:e}}function ue(t){if("array"===t.kind){const e=ue(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const he=[Qt,te,ee,ie,re,ae,oe,ce(ne),le];function pe(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!pe(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of he)if(!pe(t,e))return null}return`Expected ${ue(t)} but found ${ue(e)} instead.`}function de(t,e){return e.some((e=>e.kind===t.kind))}function fe(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function me(t){var e={exports:{}};return t(e,e.exports),e.exports}var _e=me((function(t,e){var i={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function r(t){return(t=Math.round(t))<0?0:t>255?255:t}function o(t){return r("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function s(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{e.parseCSSColor=function(t){var e,a=t.replace(/ /g,"").toLowerCase();if(a in i)return i[a].slice();if("#"===a[0])return 4===a.length?(e=parseInt(a.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===a.length&&(e=parseInt(a.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=n(h.pop());case"rgb":return 3!==h.length?null:[o(h[0]),o(h[1]),o(h[2]),p];case"hsla":if(4!==h.length)return null;p=n(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*s(g,_,d+1/3)),r(255*s(g,_,d)),r(255*s(g,_,d-1/3)),p];default:return null}}return null}}catch(t){}}));class ge{constructor(t,e,i,r=1){this.r=t,this.g=e,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof ge)return t;if("string"!=typeof t)return;const e=_e.parseCSSColor(t);return e?new ge(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${r})`}toArray(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*i/r,r]}toArray01(){const{r:t,g:e,b:i,a:r}=this;return 0===r?[0,0,0,0]:[t/r,e/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:r}=this;return[t,e,i,r]}}ge.black=new ge(0,0,0,1),ge.white=new ge(1,1,1,1),ge.transparent=new ge(0,0,0,0),ge.red=new ge(1,0,0,1),ge.blue=new ge(0,0,1,1);var ye=ge;class xe{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ve{constructor(t,e,i,r,o){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=o}}class be{constructor(t){this.sections=t}static fromString(t){return new be([new ve(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof be?t:be.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class we{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new we({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Te(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ee(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof ye)return!0;if(t instanceof xe)return!0;if(t instanceof be)return!0;if(t instanceof we)return!0;if(Array.isArray(t)){for(const e of t)if(!Ee(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Ee(t[e]))return!1;return!0}return!1}function Se(t){if(null===t)return Qt;if("string"==typeof t)return ee;if("boolean"==typeof t)return ie;if("number"==typeof t)return te;if(t instanceof ye)return re;if(t instanceof xe)return se;if(t instanceof be)return ae;if(t instanceof we)return le;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Se(e);if(i){if(i===t)continue;i=ne;break}i=t}return ce(i||ne,e)}return oe}function Ce(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ye||t instanceof be||t instanceof we?t.toString():JSON.stringify(t)}class Me{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ee(t[1]))return e.error("invalid value");const i=t[1];let r=Se(i);const o=e.expectedType;return"array"!==r.kind||0!==r.N||!o||"array"!==o.kind||"number"==typeof o.N&&0!==o.N||(r=o),new Me(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ye?["rgba"].concat(this.value.toArray()):this.value instanceof be?this.value.serialize():this.value}}var Ae=Me,Ie=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const ze={string:ee,number:te,boolean:ie,object:oe};class ke{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,r=1;const o=t[0];if("array"===o){let o,n;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in ze)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);o=ze[i],r++}else o=ne;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);n=t[2],r++}i=ce(o,n)}else i=ze[o];const n=[];for(;rt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}var Pe=ke;class De{constructor(t){this.type=ae,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let o=!1;for(let i=1;i<=t.length-1;++i){const n=t[i];if(o&&"object"==typeof n&&!Array.isArray(n)){o=!1;let t=null;if(n["font-scale"]&&(t=e.parse(n["font-scale"],1,te),!t))return null;let i=null;if(n["text-font"]&&(i=e.parse(n["text-font"],1,ce(ee)),!i))return null;let s=null;if(n["text-color"]&&(s=e.parse(n["text-color"],1,re),!s))return null;const a=r[r.length-1];a.scale=t,a.font=i,a.textColor=s}else{const n=e.parse(t[i],1,ne);if(!n)return null;const s=n.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");o=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new De(r)}evaluate(t){return new be(this.sections.map((e=>{const i=e.content.evaluate(t);return Se(i)===le?new ve("",i,null,null,null):new ve(Ce(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class Le{constructor(t){this.type=le,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ee);return i?new Le(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=we.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Be={"to-boolean":ie,"to-color":re,"to-number":te,"to-string":ee};class Re{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=Be[i],o=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Te(e[0],e[1],e[2],e[3]),!i))return new ye(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ie(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new Ie(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?be.fromString(Ce(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?we.fromString(Ce(this.args[0].evaluate(t))):Ce(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new De([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Le(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Fe=Re;const Oe=["Unknown","Point","LineString","Polygon"];var Ue=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Oe[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ye.parse(t)),e}};class Ve{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],r=Ve.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const o=Array.isArray(r)?r[0]:r.type,n=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=n.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[r,n]of s){a=new di(e.registry,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(ue).join(", ")})`:`(${ue(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i=e[2]||t[1]<=e[1]||t[3]>=e[3])}function qe(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,o=Math.pow(2,e.z);return[Math.round(i*o*Ge),Math.round(r*o*Ge)]}function Xe(t,e,i){const r=t[0]-e[0],o=t[1]-e[1],n=t[0]-i[0],s=t[1]-i[1];return r*s-n*o==0&&r*n<=0&&o*s<=0}function We(t,e){let i=!1;for(let s=0,a=e.length;s(r=t)[1]!=(n=a[e+1])[1]>r[1]&&r[0]<(n[0]-o[0])*(r[1]-o[1])/(n[1]-o[1])+o[0]&&(i=!i)}}var r,o,n;return i}function He(t,e){for(let i=0;i0&&a<0||s<0&&a>0}function Ke(t,e,i){for(const c of i)for(let i=0;ii[2]){const e=.5*r;let o=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===o&&(o=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=o}Ze(e,t)}function ri(t,e,i,r){const o=Math.pow(2,r.z)*Ge,n=[r.x*Ge,r.y*Ge],s=[];if(!t)return s;for(const r of t)for(const t of r){const r=[t.x+n[0],t.y+n[1]];ii(r,e,i,o),s.push(r)}return s}function oi(t,e,i,r){const o=Math.pow(2,r.z)*Ge,n=[r.x*Ge,r.y*Ge],s=[];if(!t)return s;for(const i of t){const t=[];for(const r of i){const i=[r.x+n[0],r.y+n[1]];Ze(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]<=o/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const r of t)ii(r,e,i,o)}var a;return s}class ni{constructor(t,e){this.type=ie,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ee(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t{e&&!ai(t)&&(e=!1)})),e}function li(t){if(t instanceof je&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!li(t)&&(e=!1)})),e}function ci(t,e){if(t instanceof je&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!ci(t,e)&&(i=!1)})),i}class ui{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ui(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var hi=ui;class pi{constructor(t,e=[],i,r=new Jt,o=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=o,this.expectedType=i}parse(t,e,i,r,o={}){return e?this.concat(e,i,r)._parse(t,o):this._parse(t,o)}_parse(t,e){function i(t,e,i){return"assert"===i?new Pe(e,[t]):"coerce"===i?new Fe(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const o=this.registry[r];if(o){let r=o.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,o=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==o.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(t,o))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof Ae)&&"resolvedImage"!==r.type.kind&&fi(r)){const e=new Ue;try{r=new Ae(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const r="number"==typeof t?this.path.concat(t):this.path,o=i?this.scope.concat(i):this.scope;return new pi(this.registry,r,e||null,o,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Yt(i,t))}checkSubtype(t,e){const i=pe(t,e);return i&&this.error(i),i}}var di=pi;function fi(t){if(t instanceof hi)return fi(t.boundExpression);if(t instanceof je&&"error"===t.name)return!1;if(t instanceof Ne)return!1;if(t instanceof si)return!1;const e=t instanceof Fe||t instanceof Pe;let i=!0;return t.eachChild((t=>{i=e?i&&fi(t):i&&t instanceof Ae})),!!i&&ai(t)&&ci(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function mi(t,e){const i=t.length-1;let r,o,n=0,s=i,a=0;for(;n<=s;)if(a=Math.floor((n+s)/2),r=t[a],o=t[a+1],r<=e){if(a===i||ee))throw new Ie("Input is not a number.");s=a-1}return 0}class _i{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,te);if(!i)return null;const r=[];let o=null;e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let i=1;i=n)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,o);if(!c)return null;o=o||c.type,r.push([n,c])}return new _i(o,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const o=e.length;return r>=e[o-1]?i[o-1].evaluate(t):i[mi(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var gi=_i;function yi(t,e,i){return t*(1-i)+e*i}var xi=Object.freeze({__proto__:null,number:yi,color:function(t,e,i){return new ye(yi(t.r,e.r,i),yi(t.g,e.g,i),yi(t.b,e.b,i),yi(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,r)=>yi(t,e[r],i)))}});const vi=.95047,bi=1.08883,wi=4/29,Ti=6/29,Ei=3*Ti*Ti,Si=Math.PI/180,Ci=180/Math.PI;function Mi(t){return t>.008856451679035631?Math.pow(t,1/3):t/Ei+wi}function Ai(t){return t>Ti?t*t*t:Ei*(t-wi)}function Ii(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function zi(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function ki(t){const e=zi(t.r),i=zi(t.g),r=zi(t.b),o=Mi((.4124564*e+.3575761*i+.1804375*r)/vi),n=Mi((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*n-16,a:500*(o-n),b:200*(n-Mi((.0193339*e+.119192*i+.9503041*r)/bi)),alpha:t.a}}function Pi(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*Ai(e),i=vi*Ai(i),r=bi*Ai(r),new ye(Ii(3.2404542*i-1.5371385*e-.4985314*r),Ii(-.969266*i+1.8760108*e+.041556*r),Ii(.0556434*i-.2040259*e+1.0572252*r),t.alpha)}function Di(t,e,i){const r=e-t;return t+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Li={forward:ki,reverse:Pi,interpolate:function(t,e,i){return{l:yi(t.l,e.l,i),a:yi(t.a,e.a,i),b:yi(t.b,e.b,i),alpha:yi(t.alpha,e.alpha,i)}}},Bi={forward:function(t){const{l:e,a:i,b:r}=ki(t),o=Math.atan2(r,i)*Ci;return{h:o<0?o+360:o,c:Math.sqrt(i*i+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Si,i=t.c;return Pi({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Di(t.h,e.h,i),c:yi(t.c,e.c,i),l:yi(t.l,e.l,i),alpha:yi(t.alpha,e.alpha,i)}}};var Ri=Object.freeze({__proto__:null,lab:Li,hcl:Bi});class Fi{constructor(t,e,i,r,o){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of o)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,r,o){let n=0;if("exponential"===t.name)n=Oi(e,t.base,r,o);else if("linear"===t.name)n=Oi(e,1,r,o);else if("cubic-bezier"===t.name){const s=t.controlPoints;n=new i(s[0],s[1],s[2],s[3]).solve(Oi(e,1,r,o))}return n}static parse(t,e){let[i,r,o,...n]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(o=e.parse(o,2,te),!o)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=re:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const c=e.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Fi(a,i,r,o,s):e.error(`Type ${ue(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const o=e.length;if(r>=e[o-1])return i[o-1].evaluate(t);const n=mi(e,r),s=Fi.interpolationFactor(this.interpolation,r,e[n],e[n+1]),a=i[n].evaluate(t),l=i[n+1].evaluate(t);return"interpolate"===this.operator?xi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Bi.reverse(Bi.interpolate(Bi.forward(a),Bi.forward(l),s)):Li.reverse(Li.interpolate(Li.forward(a),Li.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tpe(r,t.type)));return new Vi(n?ne:i,o)}evaluate(t){let e,i=null,r=0;for(const o of this.args){if(r++,i=o.evaluate(t),i&&i instanceof we&&!i.available&&(e||(e=i),i=null,r===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var ji=Vi;class Ni{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new Ie(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Ie(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var $i=Zi;class qi{constructor(t,e){this.type=ie,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,ne);return i&&r?de(i.type,[ie,ee,te,Qt,ne])?new qi(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ue(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!fe(e,["boolean","string","number","null"]))throw new Ie(`Expected first argument to be of type boolean, string, number or null, but found ${ue(Se(e))} instead.`);if(!fe(i,["string","array"]))throw new Ie(`Expected second argument to be of type array or string, but found ${ue(Se(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Xi=qi;class Wi{constructor(t,e,i){this.type=te,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,ne);if(!i||!r)return null;if(!de(i.type,[ie,ee,te,Qt,ne]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${ue(i.type)} instead`);if(4===t.length){const o=e.parse(t[3],3,te);return o?new Wi(i,r,o):null}return new Wi(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!fe(e,["boolean","string","number","null"]))throw new Ie(`Expected first argument to be of type boolean, string, number or null, but found ${ue(Se(e))} instead.`);if(!fe(i,["string","array"]))throw new Ie(`Expected second argument to be of type array or string, but found ${ue(Se(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Hi=Wi;class Yi{constructor(t,e,i,r,o,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=o,this.otherwise=n}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const o={},n=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Se(t)))return null}else i=Se(t);if(void 0!==o[String(t)])return c.error("Branch labels must be unique.");o[String(t)]=n.length}const u=e.parse(l,s,r);if(!u)return null;r=r||u.type,n.push(u)}const s=e.parse(t[1],1,ne);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,r);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new Yi(i,r,s,o,n,a):null}evaluate(t){const e=this.input.evaluate(t);return(Se(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const o=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of i)t.push(1===r.length?o(r[0]):r.map(o)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var Ki=Yi;class Ji{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let o=1;oe.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Qi=Ji;class tr{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,ne),r=e.parse(t[2],2,te);if(!i||!r)return null;if(!de(i.type,[ce(ne),ee,ne]))return e.error(`Expected first argument to be of type array or string, but found ${ue(i.type)} instead`);if(4===t.length){const o=e.parse(t[3],3,te);return o?new tr(i.type,i,r,o):null}return new tr(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!fe(e,["string","array"]))throw new Ie(`Expected first argument to be of type array or string, but found ${ue(Se(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var er=tr;function ir(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function rr(t,e,i,r){return 0===r.compare(e,i)}function or(t,e,i){const r="=="!==t&&"!="!==t;return class o{constructor(t,e,i){this.type=ie,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let n=e.parse(t[1],1,ne);if(!n)return null;if(!ir(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${ue(n.type)}'.`);let s=e.parse(t[2],2,ne);if(!s)return null;if(!ir(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${ue(s.type)}'.`);if(n.type.kind!==s.type.kind&&"value"!==n.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${ue(n.type)}' and '${ue(s.type)}'.`);r&&("value"===n.type.kind&&"value"!==s.type.kind?n=new Pe(s.type,[n]):"value"!==n.type.kind&&"value"===s.type.kind&&(s=new Pe(n.type,[s])));let a=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==s.type.kind&&"value"!==n.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,se),!a)return null}return new o(n,s,a)}evaluate(o){const n=this.lhs.evaluate(o),s=this.rhs.evaluate(o);if(r&&this.hasUntypedArgument){const e=Se(n),i=Se(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ie(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=Se(n),i=Se(s);if("string"!==t.kind||"string"!==i.kind)return e(o,n,s)}return this.collator?i(o,n,s,this.collator.evaluate(o)):e(o,n,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const nr=or("==",(function(t,e,i){return e===i}),rr),sr=or("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!rr(0,e,i,r)})),ar=or("<",(function(t,e,i){return e",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),cr=or("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),ur=or(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class hr{constructor(t,e,i,r,o){this.type=ee,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,te);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let o=null;if(r.locale&&(o=e.parse(r.locale,1,ee),!o))return null;let n=null;if(r.currency&&(n=e.parse(r.currency,1,ee),!n))return null;let s=null;if(r["min-fraction-digits"]&&(s=e.parse(r["min-fraction-digits"],1,te),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=e.parse(r["max-fraction-digits"],1,te),!a)?null:new hr(i,o,n,s,a)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class pr{constructor(t){this.type=te,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${ue(i.type)} instead.`):new pr(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Ie(`Expected value to be of type string or array, but found ${ue(Se(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const dr={"==":nr,"!=":sr,">":lr,"<":ar,">=":ur,"<=":cr,array:Pe,at:$i,boolean:Pe,case:Qi,coalesce:ji,collator:Ne,format:De,image:Le,in:Xi,"index-of":Hi,interpolate:Ui,"interpolate-hcl":Ui,"interpolate-lab":Ui,length:pr,let:Gi,literal:Ae,match:Ki,number:Pe,"number-format":hr,object:Pe,slice:er,step:gi,string:Pe,"to-boolean":Fe,"to-color":Fe,"to-number":Fe,"to-string":Fe,var:hi,within:si};function fr(t,[e,i,r,o]){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);const n=o?o.evaluate(t):1,s=Te(e,i,r,n);if(s)throw new Ie(s);return new ye(e/255*n,i/255*n,r/255*n,n)}function mr(t,e){return t in e}function _r(t,e){const i=e[t];return void 0===i?null:i}function gr(t){return{type:t}}je.register(dr,{error:[{kind:"error"},[ee],(t,[e])=>{throw new Ie(e.evaluate(t))}],typeof:[ee,[ne],(t,[e])=>ue(Se(e.evaluate(t)))],"to-rgba":[ce(te,4),[re],(t,[e])=>e.evaluate(t).toArray()],rgb:[re,[te,te,te],fr],rgba:[re,[te,te,te,te],fr],has:{type:ie,overloads:[[[ee],(t,[e])=>mr(e.evaluate(t),t.properties())],[[ee,oe],(t,[e,i])=>mr(e.evaluate(t),i.evaluate(t))]]},get:{type:ne,overloads:[[[ee],(t,[e])=>_r(e.evaluate(t),t.properties())],[[ee,oe],(t,[e,i])=>_r(e.evaluate(t),i.evaluate(t))]]},"feature-state":[ne,[ee],(t,[e])=>_r(e.evaluate(t),t.featureState||{})],properties:[oe,[],t=>t.properties()],"geometry-type":[ee,[],t=>t.geometryType()],id:[ne,[],t=>t.id()],zoom:[te,[],t=>t.globals.zoom],pitch:[te,[],t=>t.globals.pitch||0],"distance-from-center":[te,[],t=>t.distanceFromCenter()],"heatmap-density":[te,[],t=>t.globals.heatmapDensity||0],"line-progress":[te,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[te,[],t=>t.globals.skyRadialProgress||0],accumulated:[ne,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[te,gr(te),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[te,gr(te),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:te,overloads:[[[te,te],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[te],(t,[e])=>-e.evaluate(t)]]},"/":[te,[te,te],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[te,[te,te],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[te,[],()=>Math.LN2],pi:[te,[],()=>Math.PI],e:[te,[],()=>Math.E],"^":[te,[te,te],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[te,[te],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[te,[te],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[te,[te],(t,[e])=>Math.log(e.evaluate(t))],log2:[te,[te],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[te,[te],(t,[e])=>Math.sin(e.evaluate(t))],cos:[te,[te],(t,[e])=>Math.cos(e.evaluate(t))],tan:[te,[te],(t,[e])=>Math.tan(e.evaluate(t))],asin:[te,[te],(t,[e])=>Math.asin(e.evaluate(t))],acos:[te,[te],(t,[e])=>Math.acos(e.evaluate(t))],atan:[te,[te],(t,[e])=>Math.atan(e.evaluate(t))],min:[te,gr(te),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[te,gr(te),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[te,[te],(t,[e])=>Math.abs(e.evaluate(t))],round:[te,[te],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[te,[te],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[te,[te],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ie,[ee,ne],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ie,[ne],(t,[e])=>t.id()===e.value],"filter-type-==":[ie,[ee],(t,[e])=>t.geometryType()===e.value],"filter-<":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r{const i=t.id(),r=e.value;return typeof i==typeof r&&i":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r>o}],"filter-id->":[ie,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r<=o}],"filter-id-<=":[ie,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ie,[ee,ne],(t,[e,i])=>{const r=t.properties()[e.value],o=i.value;return typeof r==typeof o&&r>=o}],"filter-id->=":[ie,[ne],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ie,[ne],(t,[e])=>e.value in t.properties()],"filter-has-id":[ie,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ie,[ce(ee)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ie,[ce(ne)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ie,[ee,ce(ne)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ie,[ee,ce(ne)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const o=i+r>>1;if(e[o]===t)return!0;e[o]>t?r=o-1:i=o+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ie,overloads:[[[ie,ie],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[gr(ie),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ie,overloads:[[[ie,ie],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[gr(ie),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ie,[ie],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ie,[ee],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ee,[ee],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ee,[ee],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ee,gr(ne),(t,e)=>e.map((e=>Ce(e.evaluate(t)))).join("")],"resolved-locale":[ee,[se],(t,[e])=>e.evaluate(t).resolvedLocale()]});var yr=dr;function xr(t){return{result:"success",value:t}}function vr(t){return{result:"error",value:t}}function br(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function wr(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Tr(t){return!!t.expression&&t.expression.interpolated}function Er(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Sr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Cr(t){return t}function Mr(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],o=r||!(r||void 0!==t.property),n=t.type||(Tr(e)?"exponential":"interval");if(i&&((t=qt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],ye.parse(t[1])]))),t.default=ye.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Ri[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===n)s=kr;else if("interval"===n)s=zr;else if("categorical"===n){s=Ir,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==n)throw new Error(`Unknown function type "${n}"`);s=Pr}if(r){const i={},r=[];for(let e=0;et[0])),evaluate:({zoom:i},r)=>kr({stops:o,base:t.base},e,i).evaluate(i,r)}}if(o){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Ui.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,r){const o=r&&r.properties?r.properties[t.property]:void 0;return void 0===o?Ar(t.default,e.default):s(t,e,o,a,l)}}}function Ar(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Ir(t,e,i,r,o){return Ar(typeof i===o?r[i]:void 0,t.default,e.default)}function zr(t,e,i){if("number"!==Er(i))return Ar(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const o=mi(t.stops.map((t=>t[0])),i);return t.stops[o][1]}function kr(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==Er(i))return Ar(t.default,e.default);const o=t.stops.length;if(1===o)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[o-1][0])return t.stops[o-1][1];const n=mi(t.stops.map((t=>t[0])),i),s=function(t,e,i,r){const o=r-i,n=t-i;return 0===o?0:1===e?n/o:(Math.pow(e,n)-1)/(Math.pow(e,o)-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),a=t.stops[n][1],l=t.stops[n+1][1];let c=xi[e.type]||Cr;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Ri[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function Pr(t,e,i){return"color"===e.type?i=ye.parse(i):"formatted"===e.type?i=be.fromString(i.toString()):"resolvedImage"===e.type?i=we.fromString(i.toString()):Er(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),Ar(i,t.default,e.default)}class Dr{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Ue,this._defaultValue=e?function(t){return"color"===t.type&&(Sr(t.default)||Array.isArray(t.default))?new ye(0,0,0,0):"color"===t.type?ye.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,o,n,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=n,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,o,n,s,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=o||null,this._evaluator.formattedSection=n||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ie(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Lr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in yr}function Br(t,e){const i=new di(yr,[],e?function(t){const e={color:re,string:ee,number:te,enum:ee,boolean:ie,formatted:ae,resolvedImage:le};return"array"===t.type?ce(e[t.value]||ne,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?xr(new Dr(r,e)):vr(i.errors)}class Rr{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!li(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,o,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,o,n)}evaluate(t,e,i,r,o,n){return this._styleExpression.evaluate(t,e,i,r,o,n)}}class Fr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!li(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,o,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,o,n)}evaluate(t,e,i,r,o,n){return this._styleExpression.evaluate(t,e,i,r,o,n)}interpolationFactor(t,e,i){return this.interpolationType?Ui.interpolationFactor(this.interpolationType,t,e,i):0}}function Or(t,e){if("error"===(t=Br(t,e)).result)return t;const i=t.value.expression,r=ai(i);if(!r&&!br(e))return vr([new Yt("","data expressions not supported")]);const o=ci(i,["zoom","pitch","distance-from-center"]);if(!o&&!wr(e))return vr([new Yt("","zoom expressions not supported")]);const n=Vr(i);return n||o?n instanceof Yt?vr([n]):n instanceof Ui&&!Tr(e)?vr([new Yt("",'"interpolate" expressions cannot be used with this property')]):xr(n?new Fr(r?"camera":"composite",t.value,n.labels,n instanceof Ui?n.interpolation:void 0):new Rr(r?"constant":"source",t.value)):vr([new Yt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Ur{constructor(t,e){this._parameters=t,this._specification=e,qt(this,Mr(this._parameters,this._specification))}static deserialize(t){return new Ur(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Vr(t){let e=null;if(t instanceof Gi)e=Vr(t.result);else if(t instanceof ji){for(const i of t.args)if(e=Vr(i),e)break}else(t instanceof gi||t instanceof Ui)&&t.input instanceof je&&"zoom"===t.input.name&&(e=t);return e instanceof Yt||t.eachChild((t=>{const i=Vr(t);i instanceof Yt?e=i:!e&&i?e=new Yt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Yt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class jr{constructor(t,e,i,r){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),null!=e&&e.__line__&&(this.line=e.__line__)}}function Nr(t){const e=t.key,i=t.value,r=t.valueSpec||{},o=t.objectElementValidators||{},n=t.style,s=t.styleSpec;let a=[];const l=Er(i);if("object"!==l)return[new jr(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=r[l]||r["*"];let u;o[l]?u=o[l]:r[l]?u=wo:o["*"]?u=o["*"]:r["*"]&&(u=wo),u?a=a.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:n,styleSpec:s,object:i,objectKey:t},i)):a.push(new jr(e,i[t],`unknown property "${t}"`))}for(const t in r)o[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&a.push(new jr(e,i,`missing required property "${t}"`));return a}function Gr(t){const e=t.value,i=t.valueSpec,r=t.style,o=t.styleSpec,n=t.key,s=t.arrayElementValidator||wo;if("array"!==Er(e))return[new jr(n,e,`array expected, ${Er(e)} found`)];if(i.length&&e.length!==i.length)return[new jr(n,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.lengtho)return[new jr(e,i,`${i} is greater than the maximum value ${o}`)]}return[]}function $r(t){const e=t.valueSpec,i=Xt(t.value.type);let r,o,n,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Er(t.value.stops)&&"array"===Er(t.value.stops[0])&&"object"===Er(t.value.stops[0][0]),u=Nr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new jr(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Gr({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Er(r)&&0===r.length&&e.push(new jr(t.key,r,"array must have at least one stop")),e},default:function(t){return wo({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&u.push(new jr(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||u.push(new jr(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Tr(t.valueSpec)&&u.push(new jr(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!br(t.valueSpec)?u.push(new jr(t.key,t.value,"property functions not supported")):a&&!wr(t.valueSpec)&&u.push(new jr(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||u.push(new jr(t.key,t.value,'"property" property is required')),u;function h(t){let i=[];const r=t.value,a=t.key;if("array"!==Er(r))return[new jr(a,r,`array expected, ${Er(r)} found`)];if(2!==r.length)return[new jr(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Er(r[0]))return[new jr(a,r,`object expected, ${Er(r[0])} found`)];if(void 0===r[0].zoom)return[new jr(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new jr(a,r,"object stop key must have value")];const e=Xt(r[0].zoom);if("number"!=typeof e)return[new jr(a,r[0].zoom,"stop zoom values must be numbers")];if(n&&n>e)return[new jr(a,r[0].zoom,"stop zoom values must appear in ascending order")];e!==n&&(n=e,o=void 0,s={}),i=i.concat(Nr({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Zr,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return Lr(Wt(r[1]))?i.concat([new jr(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(wo({key:`${a}[1]`,value:r[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,n){const a=Er(t.value),l=Xt(t.value),c=null!==t.value?t.value:n;if(r){if(a!==r)return[new jr(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new jr(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return br(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new jr(t.key,c,r)]}return"categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof o&&void 0!==o&&lnew jr(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new jr(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!li(i))return[new jr(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Xr(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!ci(i,["zoom","feature-state"]))return[new jr(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!ai(i))return[new jr(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Xr(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const t of e.valueSpec.expression.parameters)i.delete(t);if(0===i.size)return[];const r=[];return t instanceof je&&i.has(t.name)?[new jr(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{r.push(...Xr(t,e))})),r)}function Wr(t){const e=t.key,i=t.value,r=t.valueSpec,o=[];return Array.isArray(r.values)?-1===r.values.indexOf(Xt(i))&&o.push(new jr(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Xt(i))&&o.push(new jr(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function Hr(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Hr(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Yr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Hr(t)||(t=ro(t));const i=t;let r=!0;try{r=function(t){if(!Qr(t))return t;let e=Wt(t);return Jr(e),e=Kr(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const o=$t[`filter_${e}`],n=Br(r,o);let s=null;if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>n.value.evaluate(t,e,{},i);let a=null,l=null;if(r!==i){const t=Br(i,o);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,r,o,n)=>t.value.evaluate(e,i,{},r,void 0,void 0,o,n),l=!ai(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:io(r),needFeature:!!l}}function Kr(t){if(!Array.isArray(t))return t;const e=function(t){if(to.has(t[0]))for(let e=1;eKr(t)))}function Jr(t){let e=!1;const i=[];if("case"===t[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function eo(t,e){return te?1:0}function io(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?oo(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(ro))):"all"===e?["all"].concat(t.slice(1).map(ro)):"none"===e?["all"].concat(t.slice(1).map(ro).map(ao)):"in"===e?no(t[1],t.slice(2)):"!in"===e?ao(no(t[1],t.slice(2))):"has"===e?so(t[1]):"!has"===e?ao(so(t[1])):"within"!==e||t;var i}function oo(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function no(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(eo)]]:["filter-in-small",t,["literal",e]]}}function so(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ao(t){return["!",t]}function lo(t){return Hr(Wt(t.value))?qr(qt({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):co(t)}function co(t){const e=t.value,i=t.key;if("array"!==Er(e))return[new jr(i,e,`array expected, ${Er(e)} found`)];const r=t.styleSpec;let o,n=[];if(e.length<1)return[new jr(i,e,"filter array must have at least 1 element")];switch(n=n.concat(Wr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),Xt(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Xt(e[1])&&n.push(new jr(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new jr(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(o=Er(e[1]),"string"!==o&&n.push(new jr(`${i}[1]`,e[1],`string expected, ${o} found`)));for(let s=2;s{t in i&&e.push(new jr(r,i[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((e=>{Xt(e.id)===a&&(t=e)})),t?t.ref?e.push(new jr(r,i.ref,"ref cannot reference another ref layer")):s=Xt(t.type):"string"==typeof a&&e.push(new jr(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const t=o.sources&&o.sources[i.source],n=t&&Xt(t.type);t?"vector"===n&&"raster"===s?e.push(new jr(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===n&&"raster"!==s?e.push(new jr(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==s?e.push(new jr(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===n&&t.lineMetrics||e.push(new jr(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new jr(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new jr(r,i.source,`source "${i.source}" not found`))}else e.push(new jr(r,i,'missing required property "source"'));return e=e.concat(Nr({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>wo({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>lo(qt({layerType:s},t)),layout:t=>Nr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>po(qt({layerType:s},t))}}),paint:t=>Nr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>ho(qt({layerType:s},t))}})}})),e}function mo(t){const e=t.value,i=t.key,r=Er(e);return"string"!==r?[new jr(i,e,`string expected, ${r} found`)]:[]}const _o={promoteId:function({key:t,value:e}){if("string"===Er(e))return mo({key:t,value:e});{const i=[];for(const r in e)i.push(...mo({key:`${t}.${r}`,value:e[r]}));return i}}};function go(t){const e=t.value,i=t.key,r=t.styleSpec,o=t.style;if(!e.type)return[new jr(i,e,'"type" is required')];const n=Xt(e.type);let s;switch(n){case"vector":case"raster":case"raster-dem":return s=Nr({key:i,value:e,valueSpec:r[`source_${n.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:_o}),s;case"geojson":if(s=Nr({key:i,value:e,valueSpec:r.source_geojson,style:o,styleSpec:r,objectElementValidators:_o}),e.cluster)for(const t in e.clusterProperties){const[r,o]=e.clusterProperties[t],n="string"==typeof r?[r,["accumulated"],["get",t]]:r;s.push(...qr({key:`${i}.${t}.map`,value:o,expressionContext:"cluster-map"})),s.push(...qr({key:`${i}.${t}.reduce`,value:n,expressionContext:"cluster-reduce"}))}return s;case"video":return Nr({key:i,value:e,valueSpec:r.source_video,style:o,styleSpec:r});case"image":return Nr({key:i,value:e,valueSpec:r.source_image,style:o,styleSpec:r});case"canvas":return[new jr(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Wr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:o,styleSpec:r})}}function yo(t){const e=t.value,i=t.styleSpec,r=i.light,o=t.style;let n=[];const s=Er(e);if(void 0===e)return n;if("object"!==s)return n=n.concat([new jr("light",e,`object expected, ${s} found`)]),n;for(const t in e){const s=t.match(/^(.*)-transition$/);n=n.concat(s&&r[s[1]]&&r[s[1]].transition?wo({key:t,value:e[t],valueSpec:i.transition,style:o,styleSpec:i}):r[t]?wo({key:t,value:e[t],valueSpec:r[t],style:o,styleSpec:i}):[new jr(t,e[t],`unknown property "${t}"`)])}return n}function xo(t){const e=t.value,i=t.key,r=t.style,o=t.styleSpec,n=o.terrain;let s=[];const a=Er(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new jr("terrain",e,`object expected, ${a} found`)]),s;for(const t in e){const i=t.match(/^(.*)-transition$/);s=s.concat(i&&n[i[1]]&&n[i[1]].transition?wo({key:t,value:e[t],valueSpec:o.transition,style:r,styleSpec:o}):n[t]?wo({key:t,value:e[t],valueSpec:n[t],style:r,styleSpec:o}):[new jr(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=r.sources&&r.sources[e.source],o=t&&Xt(t.type);t?"raster-dem"!==o&&s.push(new jr(i,e.source,`terrain cannot be used with a source of type ${String(o)}, it only be used with a "raster-dem" source type`)):s.push(new jr(i,e.source,`source "${e.source}" not found`))}else s.push(new jr(i,e,'terrain is missing required property "source"'));return s}function vo(t){const e=t.value,i=t.style,r=t.styleSpec,o=r.fog;let n=[];const s=Er(e);if(void 0===e)return n;if("object"!==s)return n=n.concat([new jr("fog",e,`object expected, ${s} found`)]),n;for(const t in e){const s=t.match(/^(.*)-transition$/);n=n.concat(s&&o[s[1]]&&o[s[1]].transition?wo({key:t,value:e[t],valueSpec:r.transition,style:i,styleSpec:r}):o[t]?wo({key:t,value:e[t],valueSpec:o[t],style:i,styleSpec:r}):[new jr(t,e[t],`unknown property "${t}"`)])}return n}const bo={"*":()=>[],array:Gr,boolean:function(t){const e=t.value,i=t.key,r=Er(e);return"boolean"!==r?[new jr(i,e,`boolean expected, ${r} found`)]:[]},number:Zr,color:function(t){const e=t.key,i=t.value,r=Er(i);return"string"!==r?[new jr(e,i,`color expected, ${r} found`)]:null===_e.parseCSSColor(i)?[new jr(e,i,`color expected, "${i}" found`)]:[]},enum:Wr,filter:lo,function:$r,layer:fo,object:Nr,source:go,light:yo,terrain:xo,fog:vo,string:mo,formatted:function(t){return 0===mo(t).length?[]:qr(t)},resolvedImage:function(t){return 0===mo(t).length?[]:qr(t)},projection:function(t){const e=t.value,i=t.styleSpec,r=i.projection,o=t.style;let n=[];const s=Er(e);if("object"===s)for(const t in e)n=n.concat(wo({key:t,value:e[t],valueSpec:r[t],style:o,styleSpec:i}));else"string"!==s&&(n=n.concat([new jr("projection",e,`object or string expected, ${s} found`)]));return n}};function wo(t){const e=t.value,i=t.valueSpec,r=t.styleSpec;return i.expression&&Sr(Xt(e))?$r(t):i.expression&&Lr(Wt(e))?qr(t):i.type&&bo[i.type]?bo[i.type](t):Nr(qt({},t,{valueSpec:i.type?r[i.type]:i}))}function To(t){const e=t.value,i=t.key,r=mo(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new jr(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new jr(i,e,'"glyphs" url must include a "{range}" token'))),r}function Eo(t,e=$t){return Mo(wo({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:To,"*":()=>[]}}))}const So=t=>Mo(ho(t)),Co=t=>Mo(po(t));function Mo(t){return t.slice().sort(((t,e)=>t.line&&e.line?t.line-e.line:0))}function Ao(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new Gt(new Error(r.message))),i=!0;return i}var Io=zo;function zo(t,e,i){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(e=o[1])+2*(i=o[2]);for(var n=0;n=u[d+0]&&r>=u[d+1])?(s[p]=!0,n.push(c[p])):s[p]=!1}}},zo.prototype._forEachCell=function(t,e,i,r,o,n,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&o.call(this,t,e,i,r,f,n,s,a))return}},zo.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},zo.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},zo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=3+this.cells.length+1+1,i=0,r=0;r=0||(o[e]=Bo(t[e],i)));t instanceof Error&&(o.message=t.message)}if(o.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(o.$name=r),o}throw new Error("can't serialize object of type "+typeof t)}function Ro(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Do(t)||Lo(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map(Ro);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=ko[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(r[e]=Ro(t[e]));return r}throw new Error("can't deserialize object of type "+typeof t)}class Fo{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=1536&&t<=1791,Uo=t=>t>=1872&&t<=1919,Vo=t=>t>=2208&&t<=2303,jo=t=>t>=11904&&t<=12031,No=t=>t>=12032&&t<=12255,Go=t=>t>=12272&&t<=12287,Zo=t=>t>=12288&&t<=12351,$o=t=>t>=12352&&t<=12447,qo=t=>t>=12448&&t<=12543,Xo=t=>t>=12544&&t<=12591,Wo=t=>t>=12704&&t<=12735,Ho=t=>t>=12736&&t<=12783,Yo=t=>t>=12784&&t<=12799,Ko=t=>t>=12800&&t<=13055,Jo=t=>t>=13056&&t<=13311,Qo=t=>t>=13312&&t<=19903,tn=t=>t>=19968&&t<=40959,en=t=>t>=40960&&t<=42127,rn=t=>t>=42128&&t<=42191,on=t=>t>=44032&&t<=55215,nn=t=>t>=63744&&t<=64255,sn=t=>t>=64336&&t<=65023,an=t=>t>=65040&&t<=65055,ln=t=>t>=65072&&t<=65103,cn=t=>t>=65104&&t<=65135,un=t=>t>=65136&&t<=65279,hn=t=>t>=65280&&t<=65519;function pn(t){for(const e of t)if(mn(e.charCodeAt(0)))return!0;return!1}function dn(t){for(const e of t)if(!fn(e.charCodeAt(0)))return!1;return!0}function fn(t){return!(Oo(t)||Uo(t)||Vo(t)||sn(t)||un(t))}function mn(t){return!(746!==t&&747!==t&&(t<4352||!(Wo(t)||Xo(t)||ln(t)&&!(t>=65097&&t<=65103)||nn(t)||Jo(t)||jo(t)||Ho(t)||!(!Zo(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Qo(t)||tn(t)||Ko(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||on(t)||$o(t)||Go(t)||(t=>t>=12688&&t<=12703)(t)||No(t)||Yo(t)||qo(t)&&12540!==t||!(!hn(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!cn(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||an(t)||(t=>t>=19904&&t<=19967)(t)||en(t)||rn(t))))}function _n(t){return!(mn(t)||function(t){return!!((t=>t>=128&&t<=255)(t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||(t=>t>=8192&&t<=8303)(t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||(t=>t>=8448&&t<=8527)(t)||(t=>t>=8528&&t<=8591)(t)||(t=>t>=8960&&t<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||(t=>t>=9216&&t<=9279)(t)&&9251!==t||(t=>t>=9280&&t<=9311)(t)||(t=>t>=9312&&t<=9471)(t)||(t=>t>=9632&&t<=9727)(t)||(t=>t>=9728&&t<=9983)(t)&&!(t>=9754&&t<=9759)||(t=>t>=11008&&t<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Zo(t)||qo(t)||(t=>t>=57344&&t<=63743)(t)||ln(t)||cn(t)||hn(t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function gn(t){return t>=1424&&t<=2303||sn(t)||un(t)}function yn(t,e){return!(!e&&gn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||(t=>t>=6016&&t<=6143)(t))}function xn(t){for(const e of t)if(gn(e.charCodeAt(0)))return!0;return!1}const vn="deferred",bn="loading",wn="loaded";let Tn=null,En="unavailable",Sn=null;const Cn=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(En="error"),Tn&&Tn(t)};function Mn(){An.fire(new Nt("pluginStateChange",{pluginStatus:En,pluginURL:Sn}))}const An=new Zt,In=function(){return En},zn=function(){if(En!==vn||!Sn)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");En=bn,Mn(),Sn&&Pt({url:Sn},(t=>{t?Cn(t):(En=wn,Mn())}))},kn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>En===wn||null!=kn.applyArabicShaping,isLoading:()=>En===bn,setState(t){En=t.pluginStatus,Sn=t.pluginURL},isParsed:()=>null!=kn.applyArabicShaping&&null!=kn.processBidirectionalText&&null!=kn.processStyledBidirectionalText,getPluginURL:()=>Sn};class Pn{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Fo,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!yn(i.charCodeAt(0),e))return!1;return!0}(t,kn.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class Dn{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Sr(t))return new Ur(t,e);if(Lr(t)){const i=Or(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=ye.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Ln{constructor(t){this.property=t,this.value=new Dn(t,void 0)}transitioned(t,e){return new Rn(this.property,this.value,e,v({},t.transition,this.transition),t.now)}untransitioned(){return new Rn(this.property,this.value,null,{},0)}}class Bn{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return z(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ln(this._values[t].property)),this._values[t].value=new Dn(this._values[t].property,null===e?void 0:z(e))}getTransition(t){return z(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ln(this._values[t].property)),this._values[t].transition=z(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new Fn(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new Fn(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Rn{constructor(t,e,i,r,o){const n=r.delay||0,s=r.duration||0;o=o||0,this.property=t,this.value=e,this.begin=o+n,this.end=this.begin+s,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,o=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(n){if(r>this.end)return this.prior=null,o;if(this.value.isDataDriven())return this.prior=null,o;if(rr.zoomHistory.lastIntegerZoom?{from:t,to:e,other:i}:{from:i,to:e,other:t}}interpolate(t){return t}}class Zn{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const o=t.expression.evaluate(e,null,{},i,r);return this._calculate(o,o,o,e)}return this._calculate(t.expression.evaluate(new Pn(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Pn(Math.floor(e.zoom),e)),t.expression.evaluate(new Pn(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class $n{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class qn{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const e=new Pn(0,{});for(const i in t){const r=t[i];r.specification.overridable&&this.overridableProperties.push(i);const o=this.defaultPropertyValues[i]=new Dn(r,void 0),n=this.defaultTransitionablePropertyValues[i]=new Ln(r);this.defaultTransitioningPropertyValues[i]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=o.possiblyEvaluate(e)}}}function Xn(t,e){return 256*(t=m(Math.floor(t),0,255))+m(Math.floor(e),0,255)}Po(Nn,"DataDrivenProperty"),Po(jn,"DataConstantProperty"),Po(Gn,"CrossFadedDataDrivenProperty"),Po(Zn,"CrossFadedProperty"),Po($n,"ColorRampProperty");const Wn={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Hn{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Yn{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Kn(t,e=1){let i=0,r=0;return{members:t.map((t=>{const o=Wn[t.type].BYTES_PER_ELEMENT,n=i=Jn(i,Math.max(e,o)),s=t.components||1;return r=Math.max(r,o),i+=o*s,{name:t.name,type:t.type,components:s,offset:n}})),size:Jn(i,Math.max(r,e)),alignment:e}}function Jn(t,e){return Math.ceil(t/e)*e}class Qn extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}Qn.prototype.bytesPerElement=4,Po(Qn,"StructArrayLayout2i4");class ts extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const o=3*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,t}}ts.prototype.bytesPerElement=6,Po(ts,"StructArrayLayout3i6");class es extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=o,t}}es.prototype.bytesPerElement=8,Po(es,"StructArrayLayout4i8");class is extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,o,n,s)}emplace(t,e,i,r,o,n,s,a){const l=6*t,c=12*t,u=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=o,this.uint8[c+6]=n,this.uint8[c+7]=s,this.float32[u+2]=a,t}}is.prototype.bytesPerElement=12,Po(is,"StructArrayLayout2i4ub1f12");class rs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=o,t}}rs.prototype.bytesPerElement=16,Po(rs,"StructArrayLayout4f16");class os extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,i,r,o,n,s,a,l,c)}emplace(t,e,i,r,o,n,s,a,l,c,u){const h=10*t;return this.uint16[h+0]=e,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=o,this.uint16[h+4]=n,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,t}}os.prototype.bytesPerElement=20,Po(os,"StructArrayLayout10ui20");class ns extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,o,n,s,a)}emplace(t,e,i,r,o,n,s,a,l){const c=8*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=o,this.uint16[c+4]=n,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,t}}ns.prototype.bytesPerElement=16,Po(ns,"StructArrayLayout8ui16");class ss extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,o,n)}emplace(t,e,i,r,o,n,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=o,this.int16[a+4]=n,this.int16[a+5]=s,t}}ss.prototype.bytesPerElement=12,Po(ss,"StructArrayLayout6i12");class as extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,o,n,s,a,l,c,u,h)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=o,this.uint16[d+4]=n,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,t}}as.prototype.bytesPerElement=24,Po(as,"StructArrayLayout4i4ui4i24");class ls extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,o,n)}emplace(t,e,i,r,o,n,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=o,this.float32[l+3]=n,this.float32[l+4]=s,t}}ls.prototype.bytesPerElement=20,Po(ls,"StructArrayLayout3i3f20");class cs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}cs.prototype.bytesPerElement=4,Po(cs,"StructArrayLayout1ul4");class us extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,o,n,s,a,l,c,u,h,p)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p,d){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=o,this.int16[f+4]=n,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}us.prototype.bytesPerElement=40,Po(us,"StructArrayLayout5i4f1i1ul2ui40");class hs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,o,n,s)}emplace(t,e,i,r,o,n,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=o,this.int16[l+5]=n,this.int16[l+6]=s,this.int16[l+7]=a,t}}hs.prototype.bytesPerElement=16,Po(hs,"StructArrayLayout3i2i2i16");class ps extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,o)}emplace(t,e,i,r,o,n){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=o,this.int16[a+7]=n,t}}ps.prototype.bytesPerElement=16,Po(ps,"StructArrayLayout2f1f2i16");class ds extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=12*t,s=3*t;return this.uint8[n+0]=e,this.uint8[n+1]=i,this.float32[s+1]=r,this.float32[s+2]=o,t}}ds.prototype.bytesPerElement=12,Po(ds,"StructArrayLayout2ub2f12");class fs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const o=3*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,t}}fs.prototype.bytesPerElement=12,Po(fs,"StructArrayLayout3f12");class ms extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const o=3*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=r,t}}ms.prototype.bytesPerElement=6,Po(ms,"StructArrayLayout3ui6");class _s extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b){const w=30*t,T=15*t,E=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=o,this.float32[T+3]=n,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,t}}_s.prototype.bytesPerElement=60,Po(_s,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class gs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,C,M,A,I){const z=this.length;return this.resize(z+1),this.emplace(z,t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,C,M,A,I)}emplace(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E,S,C,M,A,I,z){const k=38*t,P=19*t;return this.int16[k+0]=e,this.int16[k+1]=i,this.int16[k+2]=r,this.float32[P+2]=o,this.float32[P+3]=n,this.int16[k+8]=s,this.int16[k+9]=a,this.int16[k+10]=l,this.int16[k+11]=c,this.int16[k+12]=u,this.int16[k+13]=h,this.uint16[k+14]=p,this.uint16[k+15]=d,this.uint16[k+16]=f,this.uint16[k+17]=m,this.uint16[k+18]=_,this.uint16[k+19]=g,this.uint16[k+20]=y,this.uint16[k+21]=x,this.uint16[k+22]=v,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=S,this.uint16[k+28]=C,this.uint32[P+15]=M,this.float32[P+16]=A,this.float32[P+17]=I,this.float32[P+18]=z,t}}gs.prototype.bytesPerElement=76,Po(gs,"StructArrayLayout3i2f6i15ui1ul3f76");class ys extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ys.prototype.bytesPerElement=4,Po(ys,"StructArrayLayout1f4");class xs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,o,n,s)}emplace(t,e,i,r,o,n,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=n,this.float32[l+5]=s,this.float32[l+6]=a,t}}xs.prototype.bytesPerElement=28,Po(xs,"StructArrayLayout7f28");class vs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,o){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,o)}emplace(t,e,i,r,o,n){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=o,this.float32[s+4]=n,t}}vs.prototype.bytesPerElement=20,Po(vs,"StructArrayLayout5f20");class bs extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r)}emplace(t,e,i,r,o){const n=6*t;return this.uint32[3*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,this.uint16[n+4]=o,t}}bs.prototype.bytesPerElement=12,Po(bs,"StructArrayLayout1ul3ui12");class ws extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}ws.prototype.bytesPerElement=4,Po(ws,"StructArrayLayout2ui4");class Ts extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Ts.prototype.bytesPerElement=2,Po(Ts,"StructArrayLayout1ui2");class Es extends Yn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}Es.prototype.bytesPerElement=8,Po(Es,"StructArrayLayout2f8");class Ss extends Hn{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Ss.prototype.size=12;class Cs extends ss{get(t){return new Ss(this,t)}}Po(Cs,"FillExtrusionExtArray");class Ms extends Hn{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Ms.prototype.size=40;class As extends us{get(t){return new Ms(this,t)}}Po(As,"CollisionBoxArray");class Is extends Hn{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}Is.prototype.size=60;class zs extends _s{get(t){return new Is(this,t)}}Po(zs,"PlacedSymbolArray");class ks extends Hn{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}ks.prototype.size=76;class Ps extends gs{get(t){return new ks(this,t)}}Po(Ps,"SymbolInstanceArray");class Ds extends ys{getoffsetX(t){return this.float32[1*t+0]}}Po(Ds,"GlyphOffsetArray");class Ls extends ts{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Po(Ls,"SymbolLineVertexArray");class Bs extends Hn{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Bs.prototype.size=12;class Rs extends bs{get(t){return new Bs(this,t)}}Po(Rs,"FeatureIndexArray");class Fs extends Hn{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Fs.prototype.size=4;class Os extends ws{get(t){return new Fs(this,t)}}Po(Os,"FillExtrusionCentroidArray");class Us extends Hn{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Us.prototype.size=12;class Vs extends ss{get(t){return new Us(this,t)}}Po(Vs,"CircleGlobeExtArray");const js=Kn([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),Ns=Kn([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Gs=me((function(t){t.exports=function(t,e){var i,r,o,n,s,a,l,c;for(r=t.length-(i=3&t.length),o=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:o^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return o^=t.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0}})),Zs=me((function(t){t.exports=function(t,e){for(var i,r=t.length,o=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:o^=(255&t.charCodeAt(n+2))<<16;case 2:o^=(255&t.charCodeAt(n+1))<<8;case 1:o=1540483477*(65535&(o^=255&t.charCodeAt(n)))+((1540483477*(o>>>16)&65535)<<16)}return o=1540483477*(65535&(o^=o>>>13))+((1540483477*(o>>>16)&65535)<<16),(o^=o>>>15)>>>0}})),$s=Gs,qs=Zs;$s.murmur3=Gs,$s.murmur2=qs;class Xs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Ws(t)),this.positions.push(e,i,r)}getPositions(t){const e=Ws(t);let i=0,r=this.ids.length-1;for(;i>1;this.ids[t]>=e?r=t:i=t+1}const o=[];for(;this.ids[i]===e;)o.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return o}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Hs(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new Xs;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Ws(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:$s(String(t))}function Hs(t,e,i,r){for(;i>1];let n=i-1,s=r+1;for(;;){do{n++}while(t[n]o);if(n>=s)break;Ys(t,n,s),Ys(e,3*n,3*s),Ys(e,3*n+1,3*s+1),Ys(e,3*n+2,3*s+2)}s-i`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new ta(t,e):new Js(t,e)}}class sa{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio||1,this.pixelRatioTo=t.pixelRatio||1,this.patternFrom=e.tl.concat(e.br),this.patternTo=t.tl.concat(t.br)}setUniform(t,e,i,r){const o="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;o&&t.set(o)}getBinding(t,e,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Qs(t,e):new Js(t,e)}}class aa{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,o,n){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Pn(0),e,{},o,r,n);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a)}updatePaintArray(t,e,i,r,o){const n=this.expression.evaluate({zoom:0},i,r,void 0,o);this._setPaintValue(t,e,n)}_setPaintValue(t,e,i){if("color"===this.type){const r=oa(i);for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=o,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,r,o,n){const s=this.expression.evaluate(new Pn(this.zoom),e,{},o,r,n),a=this.expression.evaluate(new Pn(this.zoom+1),e,{},o,r,n),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,s,a)}updatePaintArray(t,e,i,r,o){const n=this.expression.evaluate({zoom:this.zoom},i,r,void 0,o),s=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,o);this._setPaintValue(t,e,n,s)}_setPaintValue(t,e,i,r){if("color"===this.type){const o=oa(i),n=oa(r);for(let i=t;i!0)){this.binders={},this._buffers=[];const r=[];for(const o in t.paint._values){if(!i(o))continue;const n=t.paint.get(o);if(!(n instanceof Un&&br(n.property.specification)))continue;const s=da(o,t.type),a=n.value,l=n.property.specification.type,c=n.property.useIntegerZoom,u=n.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(o)&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||h){const i=_a(o,l,"source");this.binders[o]=h?new ca(a,s,l,c,e,i,t.id):new aa(a,s,l,i),r.push(`/a_${o}`)}else{const t=_a(o,l,"composite");this.binders[o]=new la(a,s,l,c,e,t),r.push(`/z_${o}`)}else this.binders[o]=h?new sa(a.value,s):new na(a.value,s,l),r.push(`/u_${o}`)}this.cacheKey=r.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof aa||e instanceof la?e.maxValue:0}populatePaintArrays(t,e,i,r,o,n){for(const s in this.binders){const a=this.binders[s];(a instanceof aa||a instanceof la||a instanceof ca)&&a.populatePaintArray(t,e,i,r,o,n)}}setConstantPatternPositions(t,e){for(const i in this.binders){const r=this.binders[i];r instanceof sa&&r.setConstantPatternPositions(t,e)}}updatePaintArrays(t,e,i,r,o,n){let s=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=i.feature(e.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof aa||c instanceof la||c instanceof ca)&&!0===c.expression.isStateDependent){const u=r.paint.get(i);c.expression=u.value,c.updatePaintArray(e.start,e.end,l,t[a],o,n),s=!0}}}}return s}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof na||i instanceof sa)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof aa||i instanceof la||i instanceof ca)for(let e=0;e!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new ua(r,e,i);this.needsUpload=!1,this._featureMap=new Xs,this._bufferOffset=0}populatePaintArrays(t,e,i,r,o,n,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,o,n,s);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r,o){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r,o)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const pa={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function da(t,e){return pa[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const fa={"line-pattern":{source:os,composite:os},"fill-pattern":{source:os,composite:os},"fill-extrusion-pattern":{source:os,composite:os},"line-dasharray":{source:ns,composite:ns}},ma={color:{source:Es,composite:rs},number:{source:ys,composite:Es}};function _a(t,e,i){const r=fa[t];return r&&r[i]||ma[e][i]}Po(na,"ConstantBinder"),Po(sa,"CrossFadedConstantBinder"),Po(aa,"SourceExpressionBinder"),Po(ca,"CrossFadedCompositeBinder"),Po(la,"CompositeExpressionBinder"),Po(ua,"ProgramConfiguration",{omit:["_buffers"]}),Po(ha,"ProgramConfigurationSet");const ga="-transition";class ya extends Zt{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new On(e.layout)),e.paint)){this._transitionablePaint=new Bn(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Vn(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(Co,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return M(t,ga)?this._transitionablePaint.getTransition(t.slice(0,-ga.length)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(So,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(M(t,ga))return this._transitionablePaint.setTransition(t.slice(0,-ga.length),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],o=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const s=this._transitionablePaint._values[t].value;return s.isDataDriven()||o||r||this._handleOverridablePaintPropertyUpdate(t,n,s)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),I(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,o={}){return(!o||!1!==o.validate)&&Ao(this,t.call(Eo,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:$t,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Un&&br(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Yr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const xa=Kn([{name:"a_pos",components:2,type:"Int16"}],4),va=Kn([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ba{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let o=this.segments[this.segments.length-1];return t>ba.MAX_VERTEX_ARRAY_LENGTH&&P(`Max vertices per segment is ${ba.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!o||o.vertexLength+t>ba.MAX_VERTEX_ARRAY_LENGTH||o.sortKey!==r)&&(o={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(o.sortKey=r),this.segments.push(o)),o}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,r){return new ba([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}ba.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Po(ba,"SegmentVector");var wa=8192;class Ta{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Sa?new Sa(t.lng,t.lat):Sa.convert(t),this}setSouthWest(t){return this._sw=t instanceof Sa?new Sa(t.lng,t.lat):Sa.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,o;if(t instanceof Sa)r=t,o=t;else{if(!(t instanceof Ta))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Ta.convert(t)):this.extend(Sa.convert(t)):this;if(r=t._sw,o=t._ne,!r||!o)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(o.lng,i.lng),i.lat=Math.max(o.lat,i.lat)):(this._sw=new Sa(r.lng,r.lat),this._ne=new Sa(o.lng,o.lat)),this}getCenter(){return new Sa((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Sa(this.getWest(),this.getNorth())}getSouthEast(){return new Sa(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Sa.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return!t||t instanceof Ta?t:new Ta(t)}}const Ea=6371008.8;class Sa{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Sa(g(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,o=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Ea*Math.acos(Math.min(o,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Ta(new Sa(this.lng-i,this.lat-e),new Sa(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Sa)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Sa(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Sa(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Ca=2*Math.PI*Ea;function Ma(t){return Ca*Math.cos(t*Math.PI/180)}function Aa(t){return(180+t)/360}function Ia(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function za(t,e){return t/Ma(e)}function ka(t){return 360*t-180}function Pa(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Da(t,e){return t*Ma(Pa(e))}const La=85.051129;class Ba{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Sa.convert(t);return new Ba(Aa(i.lng),Ia(i.lat),za(e,i.lat))}toLngLat(){return new Sa(ka(this.x),Pa(this.y))}toAltitude(){return Da(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ca*(t=Pa(this.y),1/Math.cos(t*Math.PI/180));var t}}function Ra(t,e,i,r,o,s,a,l,c){const u=(e+r)/2,h=(i+o)/2,p=new n(u,h);l(p),function(t,e,i,r,o,n){const s=i-o,a=r-n;return Math.abs((r-e)*s-(i-t)*a)/Math.hypot(s,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(Ra(t,e,i,u,h,s,p,l,c),Ra(t,u,h,r,o,p,a,l,c)):t.push(a)}function Fa(t,e,i){let r=t[0],o=r.x,n=r.y;e(r);const s=[r];for(let a=1;at.x+1||rt.y+1)&&P("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Ga(t,e,i){const r=t.loadGeometry(),o=t.extent,n=wa/o;if(e&&i&&i.projection.isReprojectedInTileSpace){const n=1<{const i=ka((e.x+t.x/o)/n),r=Pa((e.y+t.y/o)/n),u=c.project(i,r);t.x=(u.x*s-a)*o,t.y=(u.y*s-l)*o};for(let e=0;e=o||i.y<0||i.y>=o||(u(i),t.push(i));r[e]=t}}for(const t of r)for(const e of t)Na(e,n);return r}function Za(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Ga(t):[]}}function $a(t,e,i,r,o){t.emplaceBack(2*e+(r+1)/2,2*i+(o+1)/2)}function qa(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class Xa{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Qn,this.indexArray=new ms,this.segments=new ba,this.programConfigurations=new ha(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){const o=this.layers[0],n=[];let s=null;"circle"===o.type&&(s=o.layout.get("circle-sort-key"));for(const{feature:e,id:o,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Za(e,t);if(!this.layers[0]._featureFilter.filter(new Pn(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:o,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Ga(e,i,r),patterns:{},sortKey:u};n.push(h)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Vs,a=r.projection);for(const r of n){const{geometry:o,index:n,sourceLayerIndex:s}=r,l=t[n].feature;this.addFeature(r,o,n,e.availableImages,i,a),e.featureIndex.insert(l,o,n,s,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,xa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,va.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,r,o,n){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=wa||r<0||r>=wa)continue;if(n){const t=n.projectTilePoint(i,r,o),e=n.upVector(o,i,r),s=this.globeExtVertexArray;qa(s,t,e),qa(s,t,e),qa(s,t,e),qa(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;$a(this.layoutVertexArray,i,r,-1,-1),$a(this.layoutVertexArray,i,r,1,-1),$a(this.layoutVertexArray,i,r,1,1),$a(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r,o)}}function Wa(t,e){for(let i=0;i1){if(Ja(t,e))return!0;for(let r=0;r1?i:i.sub(e)._mult(o)._add(e))}function il(t,e){let i,r,o,n=!1;for(let s=0;se.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(n=!n)}return n}function rl(t,e){let i=!1;for(let r=0,o=t.length-1;re.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(i=!i)}return i}function ol(t,e,i,r,o){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&o>=n.y)return!0;const s=[new n(e,i),new n(e,o),new n(r,o),new n(r,i)];if(t.length>2)for(const e of s)if(rl(t,e))return!0;for(let e=0;eo.x&&e.x>o.x||t.yo.y&&e.y>o.y)return!1;const n=D(t,e,i[0]);return n!==D(t,e,i[1])||n!==D(t,e,i[2])||n!==D(t,e,i[3])}function sl(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function al(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ll(t,e,i,r,o){if(!e[0]&&!e[1])return t;const s=n.convert(e)._mult(o);"viewport"===i&&s._rotate(-r);const a=[];for(let e=0;e0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Bl(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rl(t,e,i){var r=e[0],o=e[1],n=e[2],s=i[0],a=i[1],l=i[2];return t[0]=o*l-n*a,t[1]=n*s-r*l,t[2]=r*a-o*s,t}function Fl(t,e,i){var r=e[0],o=e[1],n=e[2],s=i[3]*r+i[7]*o+i[11]*n+i[15];return t[0]=(i[0]*r+i[4]*o+i[8]*n+i[12])/(s=s||1),t[1]=(i[1]*r+i[5]*o+i[9]*n+i[13])/s,t[2]=(i[2]*r+i[6]*o+i[10]*n+i[14])/s,t}function Ol(t,e,i){var r=i[0],o=i[1],n=i[2],s=e[0],a=e[1],l=e[2],c=o*l-n*a,u=n*s-r*l,h=r*a-o*s,p=o*h-n*u,d=n*c-r*h,f=r*u-o*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,t[0]=s+(c*=m)+(p*=2),t[1]=a+u+d,t[2]=l+h+f,t}var Ul,Vl=Al,jl=Il,Nl=Sl;function Gl(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Zl(t,e,i){var r=e[0],o=e[1],n=e[2],s=e[3];return t[0]=i[0]*r+i[4]*o+i[8]*n+i[12]*s,t[1]=i[1]*r+i[5]*o+i[9]*n+i[13]*s,t[2]=i[2]*r+i[6]*o+i[10]*n+i[14]*s,t[3]=i[3]*r+i[7]*o+i[11]*n+i[15]*s,t}function $l(){var t=new dl(4);return dl!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ql(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Xl(t,e,i){i*=.5;var r=e[0],o=e[1],n=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l+s*a,t[1]=o*l+n*a,t[2]=n*l-o*a,t[3]=s*l-r*a,t}function Wl(t,e,i){i*=.5;var r=e[0],o=e[1],n=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=r*l-n*a,t[1]=o*l+s*a,t[2]=n*l+r*a,t[3]=s*l-o*a,t}Tl(),Ul=new dl(4),dl!=Float32Array&&(Ul[0]=0,Ul[1]=0,Ul[2]=0,Ul[3]=0),Tl(),Cl(1,0,0),Cl(0,1,0),$l(),$l(),fl();class Hl{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,i){const r=Bl(e,this.dir);if(Math.abs(r)<1e-6)return!1;const o=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/r;return i[0]=this.pos[0]+this.dir[0]*o,i[1]=this.pos[1]+this.dir[1]*o,i[2]=this.pos[2]+this.dir[2]*o,!0}closestPointOnSphere(t,e,i){if(function(t,e){var i=t[0],r=t[1],o=t[2],n=e[0],s=e[1],a=e[2];return Math.abs(i-n)<=pl*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-s)<=pl*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-a)<=pl*Math.max(1,Math.abs(o),Math.abs(a))}(this.pos,t)||0===e)return i[0]=i[1]=i[2]=0,!1;const[r,o,n]=this.dir,s=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=r*r+o*o+n*n,u=2*(s*r+a*o+l*n),h=u*u-4*c*(s*s+a*a+l*l-e*e);if(h<0){const t=Math.max(-u/2,0),c=s+r*t,h=a+o*t,p=l+n*t,d=Math.hypot(c,h,p);return i[0]=c*e/d,i[1]=h*e/d,i[2]=p*e/d,!1}{const t=(-u-Math.sqrt(h))/(2*c);if(t<0){const t=Math.hypot(s,a,l);return i[0]=s*e/t,i[1]=a*e/t,i[2]=l*e/t,!1}return i[0]=s+r*t,i[1]=a+o*t,i[2]=l+n*t,!0}}}class Yl{constructor(t,e,i,r,o){this.TL=t,this.TR=e,this.BR=i,this.BL=r,this.horizon=o}static fromInvProjectionMatrix(t,e,i){const r=[-1,1,1],o=[1,1,1],n=[1,-1,1],s=[-1,-1,1],a=Fl(r,r,t),l=Fl(o,o,t),c=Fl(n,n,t),u=Fl(s,s,t);return new Yl(a,l,c,u,e/i)}}class Kl{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i,r){const o=Math.pow(2,i),n=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((i=>{const n=Zl([],i,t),s=1/n[3]/e*o;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(n,n,[s,s,r?1/n[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=Ll([],Rl([],Vl([],n[t[0]],n[t[1]]),Vl([],n[t[2]],n[t[1]]))),i=-Bl(e,n[t[1]]);return e.concat(i)}));return new Kl(n,s)}}class Jl{constructor(t,e){this.min=t,this.max=e,this.center=Pl([],Ml([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],i=El(this.min),r=El(this.max);for(let t=0;t=0;if(0===n)return 0;n!==e.length&&(i=!1)}if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let o=0;othis.max[e]-this.min[e])return 0}return 1}}function Ql(t,e,i,r,o,n,s,a,l){if(n&&t.queryGeometry.isAboveHorizon)return!1;n&&(l*=t.pixelToTileUnitsFactor);const c=t.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(a),p=o&&i.elevation?i.elevation.exaggeration()*o.getElevationAt(h.x,h.y,!0):0,d=i.projection.projectTilePoint(h.x,h.y,c);if(p>0){const t=i.projection.upVector(c,h.x,h.y);d.x+=t[0]*u*p,d.y+=t[1]*u*p,d.z+=t[2]*u*p}const f=n?h:tc(d.x,d.y,d.z,r),m=n?t.tilespaceRays.map((t=>rc(t,p))):t.queryGeometry.screenGeometry,_=Zl([],[d.x,d.y,d.z,1],r);if(!s&&n?l*=_[3]/i.cameraToCenterDistance:s&&!n&&(l*=i.cameraToCenterDistance/_[3]),n){const t=Pa((e.y/wa+c.y)/(1<t.width||o.height>t.height||i.x>t.width-o.width||i.y>t.height-o.height)throw new RangeError("out of range source coordinates for image copy");if(o.width>e.width||o.height>e.height||r.x>e.width-o.width||r.y>e.height-o.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,a=e.data;for(let l=0;l{e[t.evaluationKey]=n;const s=t.expression.evaluate(e);o.data[i+r+0]=Math.floor(255*s.r/s.a),o.data[i+r+1]=Math.floor(255*s.g/s.a),o.data[i+r+2]=Math.floor(255*s.b/s.a),o.data[i+r+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,o=0;e80*i){r=n=t[0],o=s=t[1];for(var f=i;fn&&(n=a),l>s&&(s=l);c=0!==(c=Math.max(n-r,s-o))?1/c:0}return vc(p,d,i,r,o,c),d}function yc(t,e,i,r,o){var n,s;if(o===Nc(t,e,i,r)>0)for(n=e;n=e;n-=r)s=Uc(n,t[n],t[n+1],s);return s&&Dc(s,s.next)&&(Vc(s),s=s.next),s}function xc(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Dc(r,r.next)&&0!==Pc(r.prev,r,r.next))r=r.next;else{if(Vc(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function vc(t,e,i,r,o,n,s){if(t){!s&&n&&function(t,e,i,r){var o=t;do{null===o.z&&(o.z=Ac(o.x,o.y,e,i,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,function(t){var e,i,r,o,n,s,a,l,c=1;do{for(i=t,t=null,n=null,s=0;i;){for(s++,r=i,a=0,e=0;e0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(o=i,i=i.nextZ,a--):(o=r,r=r.nextZ,l--),n?n.nextZ=o:t=o,o.prevZ=n,n=o;i=r}n.nextZ=null,c*=2}while(s>1)}(o)}(t,r,o,n);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,n?wc(t,r,o,n):bc(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),Vc(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?vc(t=Tc(xc(t),e,i),e,i,r,o,n,2):2===s&&Ec(t,e,i,r,o,n):vc(xc(t),e,i,r,o,n,1);break}}}function bc(t){var e=t.prev,i=t,r=t.next;if(Pc(e,i,r)>=0)return!1;for(var o=t.next.next;o!==t.prev;){if(zc(e.x,e.y,i.x,i.y,r.x,r.y,o.x,o.y)&&Pc(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function wc(t,e,i,r){var o=t.prev,n=t,s=t.next;if(Pc(o,n,s)>=0)return!1;for(var a=o.x>n.x?o.x>s.x?o.x:s.x:n.x>s.x?n.x:s.x,l=o.y>n.y?o.y>s.y?o.y:s.y:n.y>s.y?n.y:s.y,c=Ac(o.x=c&&p&&p.z<=u;){if(h!==t.prev&&h!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==t.prev&&p!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=c;){if(h!==t.prev&&h!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,h.x,h.y)&&Pc(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=u;){if(p!==t.prev&&p!==t.next&&zc(o.x,o.y,n.x,n.y,s.x,s.y,p.x,p.y)&&Pc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Tc(t,e,i){var r=t;do{var o=r.prev,n=r.next.next;!Dc(o,n)&&Lc(o,r,r.next,n)&&Fc(o,n)&&Fc(n,o)&&(e.push(o.i/i),e.push(r.i/i),e.push(n.i/i),Vc(r),Vc(r.next),r=t=n),r=r.next}while(r!==t);return xc(r)}function Ec(t,e,i,r,o,n){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&kc(s,a)){var l=Oc(s,a);return s=xc(s,s.next),l=xc(l,l.next),vc(s,e,i,r,o,n),void vc(l,e,i,r,o,n)}a=a.next}s=s.next}while(s!==t)}function Sc(t,e){return t.x-e.x}function Cc(t,e){var i=function(t,e){var i,r=e,o=t.x,n=t.y,s=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=o&&a>s){if(s=a,a===o){if(n===r.y)return r;if(n===r.next.y)return r.next}i=r.x=r.x&&r.x>=u&&o!==r.x&&zc(ni.x||r.x===i.x&&Mc(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Oc(i,t),o=xc(i,i.next);return xc(r,r.next),e===i?o:e}function Mc(t,e){return Pc(t.prev,t,e.prev)<0&&Pc(e.next,t,t.next)<0}function Ac(t,e,i,r,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*o)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*o)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ic(t){var e=t,i=t;do{(e.x=0&&(t-s)*(r-a)-(i-s)*(e-a)>=0&&(i-s)*(n-a)-(o-s)*(r-a)>=0}function kc(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Lc(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Fc(t,e)&&Fc(e,t)&&function(t,e){var i=t,r=!1,o=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&o<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Pc(t.prev,t,e.prev)||Pc(t,e.prev,e))||Dc(t,e)&&Pc(t.prev,t,t.next)>0&&Pc(e.prev,e,e.next)>0)}function Pc(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Dc(t,e){return t.x===e.x&&t.y===e.y}function Lc(t,e,i,r){var o=Rc(Pc(t,e,i)),n=Rc(Pc(t,e,r)),s=Rc(Pc(i,r,t)),a=Rc(Pc(i,r,e));return o!==n&&s!==a||!(0!==o||!Bc(t,i,e))||!(0!==n||!Bc(t,r,e))||!(0!==s||!Bc(i,t,r))||!(0!==a||!Bc(i,e,r))}function Bc(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Rc(t){return t>0?1:t<0?-1:0}function Fc(t,e){return Pc(t.prev,t,t.next)<0?Pc(t,e,t.next)>=0&&Pc(t,t.prev,e)>=0:Pc(t,e,t.prev)<0||Pc(t,t.next,e)<0}function Oc(t,e){var i=new jc(t.i,t.x,t.y),r=new jc(e.i,e.x,e.y),o=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=o,o.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Uc(t,e,i,r){var o=new jc(t,e,i);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Vc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function jc(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Nc(t,e,i,r){for(var o=0,n=e,s=i-r;ni;){if(r-i>600){var n=r-i+1,s=e-i+1,a=Math.log(n),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(n-l)/n)*(s-n/2<0?-1:1);Zc(t,e,Math.max(i,Math.floor(e-s*l/n+c)),Math.min(r,Math.floor(e+(n-s)*l/n+c)),o)}var u=t[e],h=i,p=r;for($c(t,i,e),o(t[r],u)>0&&$c(t,i,r);h0;)p--}0===o(t[i],u)?$c(t,i,p):$c(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function $c(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function qc(t,e){return te?1:0}function Xc(t,e){const i=t.length;if(i<=1)return[t];const r=[];let o,n;for(let e=0;e1)for(let t=0;t0&&i.holes.push(r+=t[o-1].length)}return i},mc.default=_c;class Kc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Qn,this.indexArray=new ms,this.indexArray2=new ws,this.programConfigurations=new ha(t.layers,t.zoom),this.segments=new ba,this.segments2=new ba,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,i,r){this.hasPattern=Hc("fill",this.layers,e);const o=this.layers[0].layout.get("fill-sort-key"),n=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Za(s,t);if(!this.layers[0]._featureFilter.filter(new Pn(this.zoom),u,i))continue;const h=o?o.evaluate(u,{},i,e.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?u.geometry:Ga(s,i,r),patterns:{},sortKey:h};n.push(p)}o&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:o,index:n,sourceLayerIndex:s}=r;if(this.hasPattern){const t=Yc("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,o,n,i,{},e.availableImages);e.featureIndex.insert(t[n].feature,o,n,s,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,o,n=[]){for(const t of Xc(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,o=[],n=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&n.push(o.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),o.push(e[0].x),o.push(e[0].y);for(let t=1;t>3}if(o--,1===r||2===r)s+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&l.push(e),e=[]),e.push(new n(s,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&l.push(e),l},nu.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,o=0,n=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(r--,1===i||2===i)(o+=t.readSVarint())a&&(a=o),(n+=t.readSVarint())c&&(c=n);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},nu.prototype.toGeoJSON=function(t,e,i){var r,o,n=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=nu.types[this.type];function u(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}function hu(t,e,i){if(3===t){var r=new lu(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}cu.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new ou(this._pbf,e,this.extent,this._keys,this._values)};var pu={VectorTile:function(t,e){this.layers=t.readFields(hu,{},e)},VectorTileFeature:ou,VectorTileLayer:lu};function du(t,e,i,r){const o=[],s=0===r?(t,e,i,r,o,s)=>{t.push(new n(s,i+(s-e)/(r-e)*(o-i)))}:(t,e,i,r,o,s)=>{t.push(new n(e+(s-i)/(o-i)*(r-e),s))};for(const n of t){const t=[];for(const o of n){if(o.length<=2)continue;const n=[];for(let t=0;te&&s(n,a,l,c,u,e):h>i?p=e&&s(n,a,l,c,u,e),p>i&&h<=i&&s(n,a,l,c,u,i)}let a=o[o.length-1];const l=0===r?a.x:a.y;l>=e&&l<=i&&n.push(a),n.length&&(a=n[n.length-1],n[0].x===a.x&&n[0].y===a.y||n.push(n[0]),t.push(n))}t.length&&o.push(t)}return o}const fu=pu.VectorTileFeature.types,mu=Math.pow(2,13);function _u(t,e,i,r,o,n,s,a){t.emplaceBack((e<<1)+s,(i<<1)+n,(Math.floor(r*mu)<<1)+o,Math.round(a))}function gu(t,e,i){const r=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*r,i[1]*r,i[2]*r)}class yu{constructor(){this.acc=new n(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new n(t.x,t.y),this.max=new n(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const i=this.min,r=this.max;t.xr.x&&(r.x=t.x),t.yr.y&&(r.y=t.y),((0===t.x||t.x===wa)&&t.x===e.x)!=((0===t.y||t.y===wa)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,yi(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>wa!=t.x>wa&&this.addBorderIntersection(1,yi(e.y,t.y,(wa-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,yi(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>wa!=t.y>wa&&this.addBorderIntersection(3,yi(e.x,t.x,(wa-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new n(0,0)}span(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class xu{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new es,this.centroidVertexArray=new Os,this.indexArray=new ms,this.programConfigurations=new ha(t.layers,t.zoom),this.segments=new ba,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i,r){this.features=[],this.hasPattern=Hc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<=0;t--){const e=p[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=wa))||d.every((t=>t.y<=0))||d.every((t=>t.y>=wa)))&&p.splice(t,1)}var d;let f;if(u)f=wu(p,l,r);else{f=[];for(const t of p)f.push({polygon:t,bounds:l})}for(const e of f){const i=e.polygon;let o=0,n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let t=0;t=1){const o=s[t-1];if(!vu(i,o,e.bounds)){h&&h.append(i,o),n.vertexLength+4>ba.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=i.sub(o)._perp(),e=t.x/(Math.abs(t.x)+Math.abs(t.y)),s=t.y>0?1:0,l=o.dist(i);a+l>32768&&(a=0),_u(this.layoutVertexArray,i.x,i.y,e,s,0,0,a),_u(this.layoutVertexArray,i.x,i.y,e,s,0,1,a),a+=l,_u(this.layoutVertexArray,o.x,o.y,e,s,0,0,a),_u(this.layoutVertexArray,o.x,o.y,e,s,0,1,a);const p=n.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),n.vertexLength+=4,n.primitiveLength+=2,u){const t=this.layoutVertexExtArray,e=c.projectTilePoint(i.x,i.y,r),n=c.projectTilePoint(o.x,o.y,r),s=c.upVector(r,i.x,i.y),a=c.upVector(r,o.x,o.y);gu(t,e,s),gu(t,e,s),gu(t,n,a),gu(t,n,a)}}}}}if(n.vertexLength+o>ba.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(o,this.layoutVertexArray,this.indexArray)),"Polygon"!==fu[t.type])continue;const s=[],a=[],l=n.vertexLength;for(let t=0;t0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const t=h.borders,e=this.featuresOnBorder.push(h)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,o,s,r)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let r,o;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);r=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),o=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil(7*(t.x+450)),o=0;else r=0,o=+i;let n=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;e<2*t.edges;e++)this.centroidVertexArray.emplace(n++,0,o),this.centroidVertexArray.emplace(n++,r,o);for(let e=0;ei[1].x)||t.y===e.y&&(t.yi[1].y)}function bu(){const t=Math.PI/32,e=Math.tan(t),i=Ea;return i*Math.sqrt(1+2*e*e)-i}function wu(t,e,i){const r=1<{for(const i of t)a.push({polygon:i,bounds:e})},c=Math.ceil(Math.log2(i)),u=Math.ceil(Math.log2(r)),h=c-u,p=[];for(let t=0;t0?0:1);for(let t=0;te+1?f.push({polygons:d,bounds:t,depth:e+1}):l(d,t)}if(m.length){const t=[new n(0===i?h:r.x,1===i?h:r.y),a];p.length>e+1?f.push({polygons:m,bounds:t,depth:e+1}):l(m,t)}}return a}(t,e,Math.ceil((s-o)/11.25),Math.ceil((a-l)/11.25),1,((t,e,o)=>{if(0===t)return.5*(e+o);{const t=Pa((i.y+e/wa)/r);return(Ia(.5*(Pa((i.y+o/wa)/r)+t))*r-i.y)*wa}}))}Po(xu,"FillExtrusionBucket",{omit:["layers","features"]}),Po(yu,"PartMetadata");var Tu={paint:new qn({"fill-extrusion-opacity":new jn($t["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Nn($t["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new jn($t["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new jn($t["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Gn($t["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Nn($t["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Nn($t["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new jn($t["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Eu(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Su{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=Au(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=function(t,e,i){var r=Eu(256*t,256*(e=Math.pow(2,i)-e-1),i),o=Eu(256*(t+1),256*(e+1),i);return r[0]+","+r[1]+","+o[0]+","+o[1]}(this.x,this.y,this.z),r=function(t,e,i){let r,o="";for(let n=t;n>0;n--)r=1<this.canonical.z?new Mu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Mu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Au(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return Au(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Mu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Mu(e,this.wrap,e,i,r),new Mu(e,this.wrap,e,i+1,r),new Mu(e,this.wrap,e,i,r+1),new Mu(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.yt.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new is,this.layoutVertexArray2=new rs,this.indexArray=new ms,this.programConfigurations=new ha(t.layers,t.zoom),this.segments=new ba,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,r){this.hasPattern=Hc("line",this.layers,e);const o=this.layers[0].layout.get("line-sort-key"),n=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Za(e,t);if(!this.layers[0]._featureFilter.filter(new Pn(this.zoom),c,i))continue;const u=o?o.evaluate(c,{},i):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:Ga(e,i,r),patterns:{},sortKey:u};n.push(h)}o&&n.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:s,featureIndex:a}=e,l=this.addConstantDashes(s);for(const r of n){const{geometry:o,index:n,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const t=Yc("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,o,n,i,s.positions,e.availableImages);a.insert(t[n].feature,o,n,c,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,o=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==o.kind)e=!0;else{const e=o.value,i=r.value;if(!i)continue;t.addDash(i.from,e),t.addDash(i.to,e),i.other&&t.addDash(i.other,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const r of this.layers){const o=r.paint.get("line-dasharray").value,n=r.layout.get("line-cap").value;if("constant"===o.kind&&"constant"===n.kind)continue;let s,a,l,c,u,h;if("constant"===o.kind){const t=o.value;if(!t)continue;s=t.other||t.to,a=t.to,l=t.from}else s=o.evaluate({zoom:i-1},t),a=o.evaluate({zoom:i},t),l=o.evaluate({zoom:i+1},t);"constant"===n.kind?c=u=h=n.value:(c=n.evaluate({zoom:i-1},t),u=n.evaluate({zoom:i},t),h=n.evaluate({zoom:i+1},t)),e.addDash(s,c),e.addDash(a,u),e.addDash(l,h);const p=e.getKey(s,c),d=e.getKey(a,u),f=e.getKey(l,h);t.patterns[r.id]={min:p,mid:d,max:f}}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,r)}addFeatures(t,e,i,r,o){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ru)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Lu),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,o,n){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap").evaluate(t,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,o,n,r)}addLine(t,e,i,r,o,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l0;if(b&&e>l){const t=h.dist(p);if(t>2*c){const e=h.sub(h.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,f,0,0,u),p=e}}const T=p&&d;let E=T?i:s?"butt":r;if(T&&"round"===E&&(xo&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x100)_=m.mult(-1);else{const t=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(h,_,0,0,u),this.addCurrentVertex(h,_.mult(-1),0,0,u)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(h,f,e,i,u),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e2*c){const e=h.add(d.sub(h)._mult(c/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,u),h=e}}}}addCurrentVertex(t,e,i,r,o,n=!1){const s=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,o),this.addHalfVertex(t,s,a,n,!0,-r,o)}addHalfVertex({x:t,y:e},i,r,o,n,s,a){this.layoutVertexArray.emplaceBack((t<<1)+(o?1:0),(e<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),n?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Po(Uu,"LineBucket",{omit:["layers","patternFeatures"]});const Vu=new qn({"line-cap":new Nn($t.layout_line["line-cap"]),"line-join":new Nn($t.layout_line["line-join"]),"line-miter-limit":new jn($t.layout_line["line-miter-limit"]),"line-round-limit":new jn($t.layout_line["line-round-limit"]),"line-sort-key":new Nn($t.layout_line["line-sort-key"])});var ju={paint:new qn({"line-opacity":new Nn($t.paint_line["line-opacity"]),"line-color":new Nn($t.paint_line["line-color"]),"line-translate":new jn($t.paint_line["line-translate"]),"line-translate-anchor":new jn($t.paint_line["line-translate-anchor"]),"line-width":new Nn($t.paint_line["line-width"]),"line-gap-width":new Nn($t.paint_line["line-gap-width"]),"line-offset":new Nn($t.paint_line["line-offset"]),"line-blur":new Nn($t.paint_line["line-blur"]),"line-dasharray":new Gn($t.paint_line["line-dasharray"]),"line-pattern":new Gn($t.paint_line["line-pattern"]),"line-gradient":new $n($t.paint_line["line-gradient"]),"line-trim-offset":new jn($t.paint_line["line-trim-offset"])}),layout:Vu};const Nu=new class extends Nn{possiblyEvaluate(t,e){return e=new Pn(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=v({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(ju.paint.properties["line-width"].specification);function Gu(t,e){return e>0?e+2*t:t}Nu.useIntegerZoom=!0;const Zu=Kn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),$u=Kn([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),qu=Kn([{name:"a_projected_pos",components:4,type:"Float32"}],4);Kn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Xu=Kn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Wu=Kn([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Kn([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Hu=Kn([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Yu=Kn([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Kn([{name:"triangle",components:3,type:"Uint16"}]),Kn([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Kn([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Kn([{type:"Float32",name:"offsetX"}]),Kn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Ku=24;const Ju=128;function Qu(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Pn(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let o=0;for(;o{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),kn.applyArabicShaping&&(t=kn.applyArabicShaping(t)),t}(t.text,e,i)})),t}const oh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function nh(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function sh(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var ah=function(t,e,i,r,o){var n,s,a=8*o-r-1,l=(1<>1,u=-7,h=i?o-1:0,p=i?-1:1,d=t[e+h];for(h+=p,n=d&(1<<-u)-1,d>>=-u,u+=a;u>0;n=256*n+t[e+h],h+=p,u-=8);for(s=n&(1<<-u)-1,n>>=-u,u+=r;u>0;s=256*s+t[e+h],h+=p,u-=8);if(0===n)n=1-c;else{if(n===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),n-=c}return(d?-1:1)*s*Math.pow(2,n-r)},lh=function(t,e,i,r,o,n){var s,a,l,c=8*n-o-1,u=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:n-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*l-1)*Math.pow(2,o),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;t[i+d]=255&a,d+=f,a/=256,o-=8);for(s=s<0;t[i+d]=255&s,d+=f,s/=256,c-=8);t[i+d-f]|=128*m},ch=uh;function uh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}uh.Varint=0,uh.Fixed64=1,uh.Bytes=2,uh.Fixed32=5;var hh=4294967296,ph=1/hh,dh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function fh(t){return t.type===uh.Bytes?t.readVarint()+t.pos:t.pos+1}function mh(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function _h(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var o=i.pos-1;o>=t;o--)i.buf[o+r]=i.buf[o]}function gh(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Ah(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Ih(t,e,i){e.glyphs=[],1===t&&i.readMessage(zh,e)}function zh(t,e,i){if(3===t){const{id:t,bitmap:r,width:o,height:n,left:s,top:a,advance:l}=i.readMessage(kh,{});e.glyphs.push({id:t,bitmap:new lc({width:o+6,height:n+6},r),metrics:{width:o,height:n,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function kh(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Ph(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let o=0,n=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),o=Math.max(o,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t>3,n=this.pos;this.type=7&r,t(o,e,this),this.pos===n&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Ch(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Ah(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Ch(this.buf,this.pos)+Ch(this.buf,this.pos+4)*hh;return this.pos+=8,t},readSFixed64:function(){var t=Ch(this.buf,this.pos)+Ah(this.buf,this.pos+4)*hh;return this.pos+=8,t},readFloat:function(){var t=ah(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ah(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,o,n=i.buf;if(r=(112&(o=n[i.pos++]))>>4,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<3,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<10,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<17,o<128)return mh(t,r,e);if(r|=(127&(o=n[i.pos++]))<<24,o<128)return mh(t,r,e);if(r|=(1&(o=n[i.pos++]))<<31,o<128)return mh(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&dh?function(t,e,i){return dh.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",o=e;o239?4:l>223?3:l>191?2:1;if(o+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(n=t[o+1]))&&(c=(31&l)<<6|63&n)<=127&&(c=null):3===u?(s=t[o+2],128==(192&(n=t[o+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&n)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=t[o+2],a=t[o+3],128==(192&(n=t[o+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&n)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),o+=u}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==uh.Bytes)return t.push(this.readVarint(e));var i=fh(this);for(t=t||[];this.pos127;);else if(e===uh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===uh.Fixed32)this.pos+=4;else{if(e!==uh.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,o,n=0;n55295&&r<57344){if(!o){r>56319||n+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):o=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,o=r;continue}r=o-55296<<10|r-56320|65536,o=null}else o&&(t[i++]=239,t[i++]=191,t[i++]=189,o=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&_h(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),lh(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),lh(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i=128&&_h(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,uh.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,gh,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,yh,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,bh,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xh,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,vh,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,wh,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Th,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Eh,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Sh,e)},writeBytesField:function(t,e){this.writeTag(t,uh.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,uh.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,uh.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,uh.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,uh.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,uh.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,uh.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,uh.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,uh.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,uh.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class Dh{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:o,content:n}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=o,this.content=n,this.version=i}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Lh{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const o=[];this.addImages(t,i,o),this.addImages(e,r,o);const{w:n,h:s}=Ph(o),a=new cc({width:n||1,height:s||1});for(const e in t){const r=t[e],o=i[e].paddedRect;cc.copy(r.data,a,{x:0,y:0},{x:o.x+1,y:o.y+1},r.data)}for(const t in e){const i=e[t],o=r[t].paddedRect,n=o.x+1,s=o.y+1,l=i.data.width,c=i.data.height;cc.copy(i.data,a,{x:0,y:0},{x:n,y:s},i.data),cc.copy(i.data,a,{x:0,y:c-1},{x:n,y:s-1},{width:l,height:1}),cc.copy(i.data,a,{x:0,y:0},{x:n,y:s+c},{width:l,height:1}),cc.copy(i.data,a,{x:l-1,y:0},{x:n-1,y:s},{width:1,height:c}),cc.copy(i.data,a,{x:0,y:0},{x:n+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const o=t[r],n={x:0,y:0,w:o.data.width+2,h:o.data.height+2};i.push(n),e[r]=new Dh(n,o),o.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e))),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,o]=t.tl;i.update(e.data,void 0,{x:r,y:o})}}Po(Dh,"ImagePosition"),Po(Lh,"ImageAtlas");const Bh={horizontal:1,vertical:2,horizontalOnly:3};class Rh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Rh;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Rh;return e.imageName=t,e}}class Fh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Fh;for(let r=0;r=0&&i>=t&&Uh[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Fh;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Rh.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Oh(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m){const _=Fh.fromFeature(t,o);let g;h===Bh.vertical&&_.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:x}=kn;if(y&&1===_.sections.length){g=[];const t=y(_.toString(),qh(_,c,n,e,r,d,f));for(const e of t){const t=new Fh;t.text=e,t.sections=_.sections;for(let i=0;i0&&n>b&&(b=n)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(E=t[m]);const r=e[a.fontStack];if(!r)continue;const n=r.glyphs[m];if(!n)continue;if(x=n.metrics,C=8203!==m?Ku:0,_){const t=void 0!==r.ascender?Math.abs(r.ascender):0,e=void 0!==r.descender?Math.abs(r.descender):0,i=(t+e)*g;w=0;let u=0;for(let i=0;i-i/2;){if(s--,s<0)return!1;a-=t[s].dist(n),n=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>o)return!1;s++,a+=e.dist(i)}return!0}function Qh(t){let e=0;for(let i=0;ic){const u=(c-l)/n,h=yi(r.x,o.x,u),p=yi(r.y,o.y,u),d=new Kh(h,p,0,o.angleTo(r),i);return!s||Jh(t,d,a,s,e)?d:void 0}l+=n}}function rp(t,e,i,r,o,n,s,a,l){const c=tp(r,n,s),u=ep(r,o),h=u*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&y=0&&p+c<=u){const i=new Kh(g,y,0,m,e);i._round(),r&&!Jh(t,i,n,r,o)||d.push(i)}}h+=f}return a||d.length||s||(d=op(t,h/2,i,r,o,n,s,!0,l)),d}function np(t,e,i,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new n(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new n(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}Po(Kh,"Anchor");const sp=1e20;function ap(t,e,i,r,o,n,s,a,l){for(let c=e;c-1);l++,n[l]=a,s[l]=c,s[l+1]=sp}for(let a=0,l=0;a{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=r.glyphs[e];if(void 0!==o)return void i(null,{stack:t,id:e,glyph:o});if(o=this._tinySDF(r,t,e),o)return r.glyphs[e]=o,void i(null,{stack:t,id:e,glyph:o});const n=Math.floor(e/256);if(256*n>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[n])return void i(null,{stack:t,id:e,glyph:o});let s=r.requests[n];s||(s=r.requests[n]=[],up.loadGlyphRange(t,n,this.url,this.requestManager,((t,e)=>{if(e){r.ascender=e.ascender,r.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e.glyphs[+t]);r.ranges[n]=!0}for(const i of s)i(t,e);delete r.requests[n]}))),s.push(((r,o)=>{r?i(r):o&&i(null,{stack:t,id:e,glyph:o.glyphs[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:r,glyph:o}of i)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[r]=o&&{id:o.id,bitmap:o.bitmap.clone(),metrics:o.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==cp.none&&(this.localGlyphMode===cp.all?!!this.localFontFamily:!!this.localFontFamily&&(tn(t)||on(t)||$o(t)||qo(t)||Zo(t)))}_tinySDF(t,e,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let o=t.tinySDF;if(!o){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),o=t.tinySDF=new up.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),o.fontWeight=i}if(this.localGlyphs[o.fontWeight][i])return this.localGlyphs[o.fontWeight][i];const n=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=o.draw(n);return this.localGlyphs[o.fontWeight][i]={id:i,bitmap:new lc({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function hp(t,e,i,r){const o=[],s=t.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,u=t.right-t.left,h=t.bottom-t.top,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],f=(t,e)=>t+e[1]-e[0],m=p.reduce(f,0),_=d.reduce(f,0),g=l-m,y=c-_;let x=0,v=m,b=0,w=_,T=0,E=g,S=0,C=y;if(s.content&&r){const t=s.content;x=pp(p,0,t[0]),b=pp(d,0,t[1]),v=pp(p,t[0],t[2]),w=pp(d,t[1],t[3]),T=t[0]-x,S=t[1]-b,E=t[2]-t[0]-v,C=t[3]-t[1]-w}const M=(r,o,l,c)=>{const p=fp(r.stretch-x,v,u,t.left),d=mp(r.fixed-T,E,r.stretch,m),f=fp(o.stretch-b,w,h,t.top),g=mp(o.fixed-S,C,o.stretch,_),y=fp(l.stretch-x,v,u,t.left),M=mp(l.fixed-T,E,l.stretch,m),A=fp(c.stretch-b,w,h,t.top),I=mp(c.fixed-S,C,c.stretch,_),z=new n(p,f),k=new n(y,f),P=new n(y,A),D=new n(p,A),L=new n(d/a,g/a),B=new n(M/a,I/a),R=e*Math.PI/180;if(R){const t=Math.sin(R),e=Math.cos(R),i=[e,-t,t,e];z._matMult(i),k._matMult(i),D._matMult(i),P._matMult(i)}const F=r.stretch+r.fixed,O=o.stretch+o.fixed;return{tl:z,tr:k,bl:D,br:P,tex:{x:s.paddedRect.x+1+F,y:s.paddedRect.y+1+O,w:l.stretch+l.fixed-F,h:c.stretch+c.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:B,minFontScaleX:E/a/u,minFontScaleY:C/a/h,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const t=dp(p,g,m),e=dp(d,y,_);for(let i=0;i{if(t)o(t);else if(e){const t={},i=function(t){return new ch(t).readFields(Ih,{})}(e);for(const e of i.glyphs)t[e.id]=e;o(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},up.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:o="sans-serif",fontWeight:n="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${n} ${t}px ${o}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:o,actualBoundingBoxRight:n}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.min(this.size-this.buffer,Math.ceil(n-o)),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(sp,0,h),_.fill(0,0,h);for(let t=0;t0?t*t:0,_[r]=t<0?t*t:0}}ap(g,0,0,c,u,c,this.f,this.v,this.z),ap(_,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;t0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const o=t-1>>1,n=e[o];if(i(r,n)>=0)break;e[t]=n,t=o}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,o=e[t];for(;t=0)break;e[t]=n,t=r}e[t]=o}}function yp(t,e){return te?1:0}function xp(t,e=1,i=!1){let r=1/0,o=1/0,s=-1/0,a=-1/0;const l=t[0];for(let t=0;ts)&&(s=e.x),(!t||e.y>a)&&(a=e.y)}const c=Math.min(s-r,a-o);let u=c/2;const h=new gp([],vp);if(0===c)return new n(r,o);for(let e=r;ep.d||!p.d)&&(p=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-p.d<=e||(u=r.h/2,h.push(new bp(r.p.x-u,r.p.y-u,u,t)),h.push(new bp(r.p.x+u,r.p.y-u,u,t)),h.push(new bp(r.p.x-u,r.p.y+u,u,t)),h.push(new bp(r.p.x+u,r.p.y+u,u,t)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function vp(t,e){return e.max-t.max}function bp(t,e,i,r){this.p=new n(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let o=0;ot.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(i=!i),r=Math.min(r,el(t,o,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const wp=Number.POSITIVE_INFINITY,Tp=Math.sqrt(2);function Ep(t,e){return e[1]!==wp?function(t,e,i){let r=0,o=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":o=i-7;break;case"bottom-right":case"bottom-left":case"bottom":o=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,o]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const o=e/Tp;switch(t){case"top-right":case"top-left":r=o-7;break;case"bottom-right":case"bottom-left":r=7-o;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-o;break;case"top-left":case"bottom-left":i=o;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Sp(t,e,i,r,o,n,s,a,l,c){t.createArrays(),t.tilePixelRatio=wa/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Pn(e),a),h["text-size"].possiblyEvaluate(new Pn(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Pn(e),a),h["icon-size"].possiblyEvaluate(new Pn(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new Pn(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new Pn(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new Pn(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const n of t.features){const l=u.get("text-font").evaluate(n,{},a).join(","),h=f.evaluate(n,{},a),m=p.layoutTextSize.evaluate(n,{},a),_=(p.layoutIconSize.evaluate(n,{},a),{horizontal:{},vertical:void 0}),g=n.text;let y,x=[0,0];if(g){const r=g.toString(),s=u.get("text-letter-spacing").evaluate(n,{},a)*Ku,c=u.get("text-line-height").evaluate(n,{},a)*Ku,p=dn(r)?s:0,f=u.get("text-anchor").evaluate(n,{},a),y=u.get("text-variable-anchor");if(!y){const t=u.get("text-radial-offset").evaluate(n,{},a);x=t?Ep(f,[t*Ku,wp]):u.get("text-offset").evaluate(n,{},a).map((t=>t*Ku))}let v=d?"center":u.get("text-justify").evaluate(n,{},a);const b=u.get("symbol-placement"),w="point"===b,T="point"===b?u.get("text-max-width").evaluate(n,{},a)*Ku:0,E=n=>{t.allowVerticalPlacement&&pn(r)&&(_.vertical=Oh(g,e,i,o,l,T,c,f,n,p,x,Bh.vertical,!0,b,m,h))};if(!d&&y){const t="auto"===v?y.map((t=>Cp(t))):[v];let r=!1;for(let n=0;n=0||!pn(r)){const t=Oh(g,e,i,o,l,T,c,f,v,p,x,Bh.horizontal,!1,b,m,h);t&&(_.horizontal[v]=t)}E("point"===b?"left":v)}}let v=!1;if(n.icon&&n.icon.name){const e=r[n.icon.name];e&&(y=Hh(o[n.icon.name],u.get("icon-offset").evaluate(n,{},a),u.get("icon-anchor").evaluate(n,{},a)),v=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&P("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const b=zp(_.horizontal)||_.vertical;t.iconsInText||(t.iconsInText=!!b&&b.iconsInText),(b||y)&&Mp(t,n,_,y,r,p,m,0,x,v,s,a,c)}n&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function Cp(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Mp(t,e,i,r,o,n,s,a,l,u,h,p,d){let f=n.textMaxSize.evaluate(e,{},p);void 0===f&&(f=s);const m=t.layers[0].layout,_=m.get("icon-offset").evaluate(e,{},p),g=zp(i.horizontal)||i.vertical,y="globe"===d.name,x=s/24,v=t.tilePixelRatio*f/24,b=(I=t.overscaling,t.zoom>18&&I>2&&(I>>=1),Math.max(wa/(512*I),1)*m.get("symbol-spacing")),w=m.get("text-padding")*t.tilePixelRatio,T=m.get("icon-padding")*t.tilePixelRatio,E=c(m.get("text-max-angle")),S="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),C="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),M=m.get("symbol-placement"),A=b/2;var I;const z=m.get("icon-text-fit");let k;r&&"none"!==z&&(t.allowVerticalPlacement&&i.vertical&&(k=Yh(r,i.vertical,z,m.get("icon-text-fit-padding"),_,x)),g&&(r=Yh(r,g,z,m.get("icon-text-fit-padding"),_,x)));const D=(s,a,c)=>{if(a.x<0||a.x>=wa||a.y<0||a.y>=wa)return;let f=null;if(y){const{x:t,y:e,z:i}=d.projectTilePoint(a.x,a.y,c);f={anchor:new Kh(t,e,i,0,void 0),up:d.upVector(c,a.x,a.y)}}!function(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x,v,b,w,T,E){const S=t.addToLineVertexArray(e,r);let C,M,A,I,z,k,D,L=0,B=0,R=0,F=0,O=-1,U=-1;const V={};let j=$s("");const N=i?i.anchor:e;let G=0,Z=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,Z]=l.layout.get("text-offset").evaluate(v,{},E).map((t=>t*Ku)):(G=l.layout.get("text-radial-offset").evaluate(v,{},E)*Ku,Z=wp),t.allowVerticalPlacement&&o.vertical){const t=o.vertical;if(f)k=Pp(t),a&&(D=Pp(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},E)+90;A=kp(c,N,e,u,h,p,t,d,i,m),a&&(I=kp(c,N,e,u,h,p,a,g,i))}}if(n){const r=l.layout.get("icon-rotate").evaluate(v,{},E),o="none"!==l.layout.get("icon-text-fit"),s=hp(n,r,w,o),d=a?hp(a,r,w,o):void 0;M=kp(c,N,e,u,h,p,n,g,r),L=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Ju*l.layout.get("icon-size").evaluate(v,{},E)],m[0]>Ap&&P(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Ju*b.compositeIconSizes[0].evaluate(v,{},E),Ju*b.compositeIconSizes[1].evaluate(v,{},E)],(m[0]>Ap||m[1]>Ap)&&P(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,x,y,v,!1,i,e,S.lineStartIndex,S.lineLength,-1,T,E),O=t.icon.placedSymbolArray.length-1,d&&(B=4*d.length,t.addSymbols(t.icon,d,m,x,y,v,Bh.vertical,i,e,S.lineStartIndex,S.lineLength,-1,T,E),U=t.icon.placedSymbolArray.length-1)}for(const r in o.horizontal){const n=o.horizontal[r];C||(j=$s(n.text),f?z=Pp(n):C=kp(c,N,e,u,h,p,n,d,l.layout.get("text-rotate").evaluate(v,{},E),m));const a=1===n.positionedLines.length;if(R+=Ip(t,i,e,n,s,l,f,v,m,S,o.vertical?Bh.horizontal:Bh.horizontalOnly,a?Object.keys(o.horizontal):[r],V,O,b,T,E),a)break}o.vertical&&(F+=Ip(t,i,e,o.vertical,s,l,f,v,m,S,Bh.vertical,["vertical"],V,U,b,T,E));let $=-1;const q=(t,e)=>t?Math.max(t,e):e;$=q(z,$),$=q(k,$),$=q(D,$);const X=$>-1?1:0;t.glyphOffsetArray.length>=Ud.MAX_GLYPHS&&P("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(N.x,N.y,N.z,e.x,e.y,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,O,U,j,void 0!==C?C:t.collisionBoxArray.length,void 0!==C?C+1:t.collisionBoxArray.length,void 0!==A?A:t.collisionBoxArray.length,void 0!==A?A+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,I||t.collisionBoxArray.length,I?I+1:t.collisionBoxArray.length,u,R,F,L,B,X,0,G,Z,$)}(t,a,f,s,i,r,o,k,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,w,S,l,0,T,C,_,e,n,u,h,p)};if("line"===M)for(const o of np(e.geometry,0,0,wa,wa)){const e=rp(o,b,E,i.vertical||g,r,24,v,t.overscaling,wa);for(const i of e){const e=g;e&&Dp(t,e.text,A,i)||D(o,i,p)}}else if("line-center"===M){for(const t of e.geometry)if(t.length>1){const e=ip(t,E,i.vertical||g,r,24,v);e&&D(t,e,p)}}else if("Polygon"===e.type)for(const t of Xc(e.geometry,0)){const e=xp(t,16);D(t[0],new Kh(e.x,e.y,0,0,void 0),p)}else if("LineString"===e.type)for(const t of e.geometry)D(t,new Kh(t[0].x,t[0].y,0,0,void 0),p);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)D([e],new Kh(e.x,e.y,0,0,void 0),p)}const Ap=32640;function Ip(t,e,i,r,o,s,a,l,c,u,h,p,d,f,m,_,g){const y=function(t,e,i,r,o,s,a,l){const c=[];if(0===e.positionedLines.length)return c;const u=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=function(t){const e=t[0],i=t[1],r=e*i;return r>0?[e,-i]:r<0?[-e,i]:0===e?[i,e]:[i,-e]}(i);let p=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)p-=t.lineOffset;const d=e.positionedLines.length,f=p/d;let m=e.top-i[1];for(let t=0;tAp&&P(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===x.kind&&(v=[Ju*m.compositeTextSizes[0].evaluate(l,{},g),Ju*m.compositeTextSizes[1].evaluate(l,{},g)],(v[0]>Ap||v[1]>Ap)&&P(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,y,v,c,a,l,h,e,i,u.lineStartIndex,u.lineLength,f,_,g);for(const e of p)d[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function zp(t){for(const e in t)return t[e];return null}function kp(t,e,i,r,o,s,a,l,u,h){let p=a.top,d=a.bottom,f=a.left,m=a.right;const _=a.collisionPadding;if(_&&(f-=_[0],p-=_[1],m+=_[2],d+=_[3]),u){const t=new n(f,p),e=new n(m,p),i=new n(f,d),r=new n(m,d),o=c(u);let s=new n(0,0);h&&(s=new n(h[0],h[1])),t._rotateAround(o,s),e._rotateAround(o,s),i._rotateAround(o,s),r._rotateAround(o,s),f=Math.min(t.x,e.x,i.x,r.x),m=Math.max(t.x,e.x,i.x,r.x),p=Math.min(t.y,e.y,i.y,r.y),d=Math.max(t.y,e.y,i.y,r.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,f,p,m,d,l,r,o,s),t.length-1}function Pp(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Dp(t,e,i,r){const o=t.compareText;if(e in o){const t=o[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])1?null:function(t,e,i,r){const o=Math.sin(i);return t*(Math.sin((1-r)*i)/o)+e*(Math.sin(r*i)/o)}(t.a[e],t.b[e],t.angle,m(i,0,1))+t.center[e]}function Xp(t){if(t.z<=1)return Gp[t.z+2*t.y+t.x];const[e,i]=Hp(t),r=[Kp(e[0],e[1]),Kp(e[0],i[1]),Kp(i[0],e[1]),Kp(i[0],i[1])],o=[Np,Np,Np],n=[jp,jp,jp];for(const t of r)o[0]=Math.min(o[0],t[0]),o[1]=Math.min(o[1],t[1]),o[2]=Math.min(o[2],t[2]),n[0]=Math.max(n[0],t[0]),n[1]=Math.max(n[1],t[1]),n[2]=Math.max(n[2],t[2]);return new Jl(o,n)}function Wp(t,e,i){const r=e/t.worldSize,o=Number.MAX_VALUE,n=[-o,-o,-o],s=[o,o,o],a=ml(new Float64Array(16));if(yl(a,a,[r,r,r]),_l(a,a,t.globeMatrix),i.z<=1){const t=Xp(i).getCorners();for(let e=0;e.5?T-=1:T<-.5&&(T+=1),Math.abs(T)>Math.abs(E))w=T>=0?1:3,b=d;else{w=E>=0?0:2;const t=[a[4],a[5],a[6]];let e;e=E>=0?-Math.sin(c(h.getSouth()))*Op:-Math.sin(c(h.getNorth()))*Op,b=Dl(b,d,t,e)}const S=p[w],C=p[(w+1)%4],M=new $p(S,C,b),A=[qp(M,0)||S[0],qp(M,1)||S[1],qp(M,2)||S[2]];return s[2]=Math.min(S[2],C[2]),zl(s,s,A),kl(n,n,A),new Jl(s,n)}function Hp(t){const e=1<x&&(v(t,c,r,o,a,l),v(c,i,a,l,n,s))}v(h,p,r,n,o,n),v(p,d,o,n,o,s),v(d,f,o,s,r,s),v(f,h,r,s,r,n),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:e}}const ud=ml(new Float32Array(16));class hd{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new Sa(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return za(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return ld(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,r){const o=t.horizonLineFromTop(!1),s=new n(e,Math.max(o,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,r))}pointCoordinate3D(t,e,i){const r=new n(e,i);if(t.elevation)return t.elevation.pointCoordinate(r);{const e=this.pointCoordinate(t,r.x,r.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?e<-vd+i&&(e=-vd+i):e>vd-i&&(e=vd-i);const n=o/Math.pow(bd(e),r),s=n*Math.sin(r*t),a=o-n*Math.cos(r*t);return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:i,f:r}=this,o=r-e,n=Math.sign(o),s=Math.sign(i)*Math.sqrt(t*t+o*o);let a=Math.atan2(t,Math.abs(o))*n;o*i<0&&(a-=Math.PI*Math.sign(t)*n);const l=m(u(a/i)+this.center[0],-180,180),c=m(u(2*Math.atan(Math.pow(r/s,1/i))-vd),-85.051129,La);return new Sa(l,c)}}class Td extends hd{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:Aa(t),y:Ia(e),z:0}}unproject(t,e){const i=ka(t),r=Pa(e);return new Sa(i,r)}}const Ed=c(La);class Sd extends hd{project(t,e){const i=(e=c(e))*e,r=i*i;return{x:.5*((t=c(t))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,r=25,o=0,n=i*i;do{n=i*i;const t=n*n;o=(i*(1.007226+n*(.015085+t*(.028874*n-.044475-.005916*t)))-e)/(1.007226+n*(.045255+t*(.259866*n-.311325-.005916*11*t))),i=m(i-o,-Ed,Ed)}while(Math.abs(o)>1e-6&&--r>0);n=i*i;const s=m(u(t/(.8707+n*(n*(n*n*n*(.003971-.001529*n)-.013791)-.131979))),-180,180),a=u(i);return new Sa(s,a)}}const Cd=c(La);class Md extends hd{project(t,e){e=c(e),t=c(t);const i=Math.cos(e),r=2/Math.PI,o=Math.acos(i*Math.cos(t/2)),n=Math.sin(o)/o,s=.5*(t*r+2*i*Math.sin(t/2)/n)||0,a=.5*(e+Math.sin(e)/n)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,r=e=(2*(1-e)-1)*Math.PI,o=25;const n=1e-6;let s=0,a=0;do{const o=Math.cos(r),n=Math.sin(r),l=2*n*o,c=n*n,u=o*o,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,f=p*p,_=1-u*h*h,g=_?1/_:0,y=_?Math.acos(o*h)*Math.sqrt(1/_):0,x=.5*(2*y*o*p+2*i/Math.PI)-t,v=.5*(y*n+r)-e,b=.5*g*(u*f+y*o*h*c)+1/Math.PI,w=g*(d*l/4-y*n*p),T=.125*g*(l*p-y*n*u*d),E=.5*g*(c*h+y*f*o)+.5,S=w*T-E*b;s=(v*w-x*E)/S,a=(x*T-v*b)/S,i=m(i-s,-Math.PI,Math.PI),r=m(r-a,-Cd,Cd)}while((Math.abs(s)>n||Math.abs(a)>n)&&--o>0);return new Sa(u(i),u(r))}}class Ad extends hd{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(c(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:r}=this;return{x:c(t)*r*i+.5,y:-Math.sin(c(e))/r*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:r}=this,o=-(e-.5)/i,n=m(u((t-.5)/i)/r,-180,180),s=Math.asin(m(o*r,-1,1)),a=m(u(s),-85.051129,La);return new Sa(n,a)}}class Id extends Td{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(t,e,i){const r=Math.pow(2,i.z),o=(t/wa+i.x)/r,n=Kp(Pa((e/wa+i.y)/r),ka(o));return Fl(n,n,td(Xp(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Kp(e.lat,e.lng),r=Ll([],i),o=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Dl(i,i,r,za(1,0)*wa*o);const s=ml(new Float64Array(16));return _l(s,t.pixelMatrix,t.globeMatrix),Fl(i,i,s),new n(i[0],i[1])}pixelsPerMeter(t,e){return za(1,0)*e}pixelSpaceConversion(t,e,i){const r=yi(za(1,45)*e,za(1,t)*e,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const r=ed(Xp(i.canonical));return _l(new Float64Array(16),t.globeMatrix,r)}createInversionMatrix(t,e){const{center:i}=t,r=ml(new Float64Array(16));return _l(r,r,td(Xp(e))),vl(r,r,c(i.lng)),xl(r,r,c(i.lat)),yl(r,r,[t._projectionScaler,t._projectionScaler,1]),Float32Array.from(r)}pointCoordinate(t,e,i,r){return Zp(t,e,i,!0)||new Ba(0,0)}pointCoordinate3D(t,e,i){const r=this.pointCoordinate(t,e,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(t,e){return!Zp(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,r=t._centerAltitude*e,o=t._camera,n=t._camera.forward(),s=Ml([],Pl([],n,-i),[0,0,r]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,u=Math.tan(t.fovAboveCenter),h=Pl([],o.up(),u),p=Pl([],o.right(),u*c),d=Ll([],Ml([],Ml([],n,h),p)),f=[];let m;if(new Hl(s,d).closestPointOnSphere(l,a,f)){const e=Ml([],f,l),i=Vl([],e,s);m=Math.cos(t.fovAboveCenter)*Sl(i)}else{const t=Vl([],s,l),e=Vl([],l,s);Ll(e,e);const i=Sl(t)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(Bl(n,e));m*=Math.cos(r)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=rd(t.zoom);if(i>0){const r=ld(t,za(1,t.center.lat)*t.worldSize),o=t.worldSize/(2*Math.PI),n=Math.max(t.width,t.height)/t.worldSize*Math.PI;return yi(e,r+o*(1-Math.cos(n)),Math.pow(i,10))}return e}upVector(t,e,i){const r=1<0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,$u.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Po(Fd,"SymbolBuffers");class Od{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new ba,this.collisionVertexArray=new ds,this.collisionVertexArrayExt=new fs}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Xu.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Wu.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Po(Od,"CollisionBuffers");class Ud{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ml([]),this.placementViewportMatrix=ml([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Qu(this.zoom,e["text-size"]),this.iconSizeData=Qu(this.zoom,e["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),o=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Bh[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Fd(new ha(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Fd(new ha(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Ds,this.lineVertexArray=new Ls,this.symbolInstances=new Ps}calculateGlyphDependencies(t,e,i,r,o){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=n.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,_=new Pn(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:g}of t){const t=o._featureFilter.needGeometry,y=Za(e,t);if(!o._featureFilter.filter(_,y,i))continue;if(t||(y.geometry=Ga(e,i,r)),s&&1!==e.type&&i.z<=5){const t=y.geometry,e=1<t),((t,i)=>Bl(Kp(Pa((t.y/wa+o)/e),ka((t.x/wa+r)/e),1),Kp(Pa((i.y/wa+o)/e),ka((i.x/wa+r)/e),1))=0;for(const i of x.sections)if(i.image)d[i.image.name]=!0;else{const r=pn(x.toString()),o=i.fontStack||t,n=f[o]=f[o]||{};this.calculateGlyphDependencies(i.text,n,e,this.allowVerticalPlacement,r)}}}"line"===n.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let o=0;function n(e){r.push(t[e]),o++}function s(t,e,o){const n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(o[0]),n}function a(t,i,o){const n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=o[0].concat(r[n].geometry[0]),n}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=zd(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length,r=t.segment;if(void 0!==r){let i=t.dist(e[r+1]),o=t.dist(e[r]);const n={};for(let t=r+1;t=0;t--)n[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:o},t>0&&(o+=e[t-1].dist(e[t]));for(let t=0;t=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:r),n=th(this.textSizeData,t,o)/Ku;return this.tilePixelRatio*n}getSymbolInstanceIconSize(t,e,i){const r=this.icon.placedSymbolArray.get(i),o=th(this.iconSizeData,t,r);return this.tilePixelRatio*o}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,r,o,n){for(let s=r;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;er[t]-r[e]||o[e]-o[t])),n}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Po(Ud,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Ud.MAX_GLYPHS=65535,Ud.addDynamicAttributes=Bd;const Vd=new qn({"symbol-placement":new jn($t.layout_symbol["symbol-placement"]),"symbol-spacing":new jn($t.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new jn($t.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Nn($t.layout_symbol["symbol-sort-key"]),"symbol-z-order":new jn($t.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new jn($t.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new jn($t.layout_symbol["icon-ignore-placement"]),"icon-optional":new jn($t.layout_symbol["icon-optional"]),"icon-rotation-alignment":new jn($t.layout_symbol["icon-rotation-alignment"]),"icon-size":new Nn($t.layout_symbol["icon-size"]),"icon-text-fit":new jn($t.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new jn($t.layout_symbol["icon-text-fit-padding"]),"icon-image":new Nn($t.layout_symbol["icon-image"]),"icon-rotate":new Nn($t.layout_symbol["icon-rotate"]),"icon-padding":new jn($t.layout_symbol["icon-padding"]),"icon-keep-upright":new jn($t.layout_symbol["icon-keep-upright"]),"icon-offset":new Nn($t.layout_symbol["icon-offset"]),"icon-anchor":new Nn($t.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new jn($t.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new jn($t.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new jn($t.layout_symbol["text-rotation-alignment"]),"text-field":new Nn($t.layout_symbol["text-field"]),"text-font":new Nn($t.layout_symbol["text-font"]),"text-size":new Nn($t.layout_symbol["text-size"]),"text-max-width":new Nn($t.layout_symbol["text-max-width"]),"text-line-height":new Nn($t.layout_symbol["text-line-height"]),"text-letter-spacing":new Nn($t.layout_symbol["text-letter-spacing"]),"text-justify":new Nn($t.layout_symbol["text-justify"]),"text-radial-offset":new Nn($t.layout_symbol["text-radial-offset"]),"text-variable-anchor":new jn($t.layout_symbol["text-variable-anchor"]),"text-anchor":new Nn($t.layout_symbol["text-anchor"]),"text-max-angle":new jn($t.layout_symbol["text-max-angle"]),"text-writing-mode":new jn($t.layout_symbol["text-writing-mode"]),"text-rotate":new Nn($t.layout_symbol["text-rotate"]),"text-padding":new jn($t.layout_symbol["text-padding"]),"text-keep-upright":new jn($t.layout_symbol["text-keep-upright"]),"text-transform":new Nn($t.layout_symbol["text-transform"]),"text-offset":new Nn($t.layout_symbol["text-offset"]),"text-allow-overlap":new jn($t.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new jn($t.layout_symbol["text-ignore-placement"]),"text-optional":new jn($t.layout_symbol["text-optional"])});var jd={paint:new qn({"icon-opacity":new Nn($t.paint_symbol["icon-opacity"]),"icon-color":new Nn($t.paint_symbol["icon-color"]),"icon-halo-color":new Nn($t.paint_symbol["icon-halo-color"]),"icon-halo-width":new Nn($t.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Nn($t.paint_symbol["icon-halo-blur"]),"icon-translate":new jn($t.paint_symbol["icon-translate"]),"icon-translate-anchor":new jn($t.paint_symbol["icon-translate-anchor"]),"text-opacity":new Nn($t.paint_symbol["text-opacity"]),"text-color":new Nn($t.paint_symbol["text-color"],{runtimeType:re,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Nn($t.paint_symbol["text-halo-color"]),"text-halo-width":new Nn($t.paint_symbol["text-halo-width"]),"text-halo-blur":new Nn($t.paint_symbol["text-halo-blur"]),"text-translate":new jn($t.paint_symbol["text-translate"]),"text-translate-anchor":new jn($t.paint_symbol["text-translate-anchor"])}),layout:Vd};class Nd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Qt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Po(Nd,"FormatSectionOverride",{omit:["defaultValue"]});class Gd extends ya{constructor(t){super(t,jd)}recalculate(t,e){super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const o=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||Lr(n.value)||!o?o:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,o)}createBucket(t){return new Ud(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of jd.paint.overridableProperties){if(!Gd.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Nd(e),r=new Dr(i,e.property.specification);let o=null;o="constant"===e.value.kind||"source"===e.value.kind?new Rr("source",r):new Fr("composite",r,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Un(e.property,o,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Gd.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=jd.paint.properties[e];let o=!1;const n=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(o=!0)};if("constant"===i.value.kind&&i.value.value instanceof be)n(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{o||(e instanceof Ae&&Se(e.value)===ae?n(e.value.sections):e instanceof De?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return o}getProgramConfiguration(t){return new ua(this,t)}}var Zd={paint:new qn({"background-color":new jn($t.paint_background["background-color"]),"background-pattern":new Zn($t.paint_background["background-pattern"]),"background-opacity":new jn($t.paint_background["background-opacity"])})},$d={paint:new qn({"raster-opacity":new jn($t.paint_raster["raster-opacity"]),"raster-hue-rotate":new jn($t.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new jn($t.paint_raster["raster-brightness-min"]),"raster-brightness-max":new jn($t.paint_raster["raster-brightness-max"]),"raster-saturation":new jn($t.paint_raster["raster-saturation"]),"raster-contrast":new jn($t.paint_raster["raster-contrast"]),"raster-resampling":new jn($t.paint_raster["raster-resampling"]),"raster-fade-duration":new jn($t.paint_raster["raster-fade-duration"])})};class qd extends ya{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var Xd={paint:new qn({"sky-type":new jn($t.paint_sky["sky-type"]),"sky-atmosphere-sun":new jn($t.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new jn($t.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new jn($t.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new jn($t.paint_sky["sky-gradient-radius"]),"sky-gradient":new $n($t.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new jn($t.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new jn($t.paint_sky["sky-atmosphere-color"]),"sky-opacity":new jn($t.paint_sky["sky-opacity"])})};function Wd(t,e,i){const r=[0,0,1],o=ql([]);return Wl(o,o,i?-c(t)+Math.PI:c(t)),Xl(o,o,-c(e)),Ol(r,r,o),Ll(r,r)}const Hd={circle:class extends ya{constructor(t){super(t,hl)}createBucket(t){return new Xa(t)}queryRadius(t){const e=t;return sl("circle-radius",this,e)+sl("circle-stroke-width",this,e)+al(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,o,n,s,a){const l=cl(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),n.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Ql(t,r,n,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new ua(this,t)}},heatmap:class extends ya{createBucket(t){return new oc(t)}constructor(t){super(t,uc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=hc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return sl("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(e,i);return Ql(t,r,s,a,l,!0,!0,new n(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new ua(this,t)}},hillshade:class extends ya{constructor(t){super(t,pc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ya{constructor(t){super(t,Qc)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new ua(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Kc(t)}queryRadius(){return al(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,o,n){return!t.queryGeometry.isAboveHorizon&&Ya(ll(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),n.angle,t.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends ya{constructor(t){super(t,Tu)}createBucket(t){return new xu(t)}queryRadius(){return al(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new ua(this,t)}queryIntersectsFeature(t,e,i,r,o,s,a,l,c){const u=cl(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,t.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(e,i),p=this.paint.get("fill-extrusion-base").evaluate(e,i),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,_=t.tile.getBucket(this);if(f&&_ instanceof xu){const t=_.centroidVertexArray,e=c+1;if(et.polygon)).flat());const g=function(t,e,i,r,o,s,a,l,c,u,h){return"globe"===t.projection.name?function(t,e,i,r,o,n,s,a,l,c,u){const h=[],p=[],d=t.projection.upVectorScale(u,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(t,e,i,r)=>{t[0]=e,t[1]=i,t[2]=r,t[3]=1},g=bu();i>0&&(i+=g),r+=g;for(const g of e){const e=[],y=[];for(const h of g){const p=h.x+o.x,g=h.y+o.y,x=t.projection.projectTilePoint(p,g,u),v=t.projection.upVector(u,h.x,h.y);let b=i,w=r;if(s){const t=Pu(p,g,i,r,s,a,l,c);b+=t.base,w+=t.top}0!==i?_(f,x.x+v[0]*d*b,x.y+v[1]*d*b,x.z+v[2]*d*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*d*w,x.y+v[1]*d*w,x.z+v[2]*d*w),Fl(f,f,n),Fl(m,m,n),e.push(ku(f)),y.push(ku(m))}h.push(e),p.push(y)}return[h,p]}(t,e,i,r,o,s,a,l,c,u,h):a?function(t,e,i,r,o,n,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of t){const t=[],d=[];for(const c of p){const u=c.x+r.x,p=c.y+r.y,f=Pu(u,p,e,i,n,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,Zl(h,h,o),h[3]=Math.max(h[3],1e-5);const m=ku([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,Zl(h,h,o),h[3]=Math.max(h[3],1e-5);const _=ku([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);t.push(m),d.push(_)}c.push(t),u.push(d)}return[c,u]}(e,i,r,o,s,a,l,c,u):function(t,e,i,r,o){const s=[],a=[],l=o[8]*e,c=o[9]*e,u=o[10]*e,h=o[11]*e,p=o[8]*i,d=o[9]*i,f=o[10]*i,m=o[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x+r.x,a=s.y+r.y,_=o[0]*e+o[4]*a+o[12],g=o[1]*e+o[5]*a+o[13],y=o[2]*e+o[6]*a+o[14],x=o[3]*e+o[7]*a+o[15],v=_+l,b=g+c,w=y+u,T=Math.max(x+h,1e-5),E=_+p,S=g+d,C=y+f,M=Math.max(x+m,1e-5),A=new n(v/T,b/T);A.z=w/T,t.push(A);const I=new n(E/M,S/M);I.z=C/M,i.push(I)}s.push(t),a.push(i)}return[s,a]}(e,i,r,o,s)}(s,r,p,h,u,a,f?l:null,d,m,s.center.lat,t.tileID.canonical),y=t.queryGeometry;return function(t,e,i){let r=1/0;Ya(i,e)&&(r=zu(i,e[0]));for(let o=0;o=3)for(let e=0;e1&&(s=t[++n]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=e/i*(r+1);if(s.isDash){const t=r-Math.abs(p);h=Math.sqrt(u*u+t*t)}else h=r-Math.sqrt(u*u+p*p);this.image.data[o+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const i=t[0],r=t[t.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const o=this.width*this.nextRow;let n=0,s=t[n];for(let i=0;i1&&(s=t[++n]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[o+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const r="round"===e,o=r?7:0,n=2*o+1;if(this.nextRow+n>this.height)return P("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Qd{constructor(){this.tasks={},this.taskQueue=[],C(["process"],this),this.invoker=new Jd(this.process),this.nextId=0}add(t,e){const i=this.nextId++,r=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===r){B();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){B();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i>=1)>1;){const t=i+o>>1,l=r+n>>1;1&e?(o=i,n=r,i=s,r=a):(i=o,r=n,o=s,n=a),s=t,a=l}const l=4*t;sf[l+0]=i,sf[l+1]=r,sf[l+2]=o,sf[l+3]=n}const af=new Uint16Array(2178),lf=new Uint8Array(1089),cf=new Uint16Array(1089);function uf(t){return 0===t?-.03125:32===t?.03125:0}var hf=Kn([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const pf={type:2,extent:wa,loadGeometry:()=>[[new n(0,0),new n(8193,0),new n(8193,8193),new n(0,8193),new n(0,0)]]};class df{constructor(t,e,i,r,o){this.tileID=t,this.uid=w(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Ud){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Ud&&e.hasRTLText){this.hasRTLText=!0,kn.isLoading()||kn.isLoaded()||"deferred"!==In()||zn();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new As}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Yd(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Yd(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Yd(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,o,n,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:n,params:o,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),o=e?e.sourceLayer:"",n=r._geojsonTileLayer||r[o];if(!n)return;const s=Yr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let e=0;et)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=sf[e+0],r=sf[e+1],o=sf[e+2],n=sf[e+3],s=i+o>>1,a=r+n>>1,l=s+a-r,c=a+i-s,u=r*nf+i,h=n*nf+o,p=a*nf+s,d=Math.hypot((af[2*u+0]+af[2*h+0])/2-af[2*p+0],(af[2*u+1]+af[2*h+1])/2-af[2*p+1])>=16;if(lf[p]=lf[p]||(d?1:0),t<1022){const t=(r+c>>1)*nf+(i+l>>1),e=(n+c>>1)*nf+(o+l>>1);lf[p]=lf[p]||lf[t]||lf[e]}}const o=new es,n=new ms;let s=0;function a(t,e){const i=e*nf+t;return 0===cf[i]&&(o.emplaceBack(af[2*i+0],af[2*i+1],t*wa/of,e*wa/of),cf[i]=++s),cf[i]-1}function l(t,e,i,r,o,s){const c=t+i>>1,u=e+r>>1;if(Math.abs(t-o)+Math.abs(e-s)>1&&lf[u*nf+c])l(o,s,t,e,c,u),l(i,r,o,s,c,u);else{const l=a(t,e),c=a(i,r),u=a(o,s);n.emplaceBack(l,c,u)}}return l(0,0,of,of,of,0),l(of,of,0,0,0,of),{vertices:o,indices:n}}(this.tileID.canonical,e);r=t.vertices,o=t.indices}else{r=new es,o=new ms;for(const{x:t,y:e}of i)r.emplaceBack(t,e,0,0);const t=mc(r.int16,void 0,4);for(let e=0;e{const u=(a-t)/(c-1),h=(l-s)/(c-1),p=r.length;for(let a=0;as*t+e;for(let t=0;te[s])return null}else{const a=1/r[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>o&&(o=l),cn)return null}return o}function gf(t,e,i,r,o,n,s,a,l,c,u){const h=r-t,p=o-e,d=n-i,f=s-t,m=a-e,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,x=u[0]*m-u[1]*f,v=h*g+p*y+d*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-t,T=c[1]-e,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const C=T*d-E*p,M=E*h-w*d,A=w*p-T*h,I=(u[0]*C+u[1]*M+u[2]*A)*b;return I<0||S+I>1?null:(f*C+m*M+_*A)*b}function yf(t,e,i){return(t-e)/(i-e)}function xf(t,e,i,r,o,n,s,a,l){const c=1<{const n=r?1:0,s=(t+1)*i-n,a=e*i,l=(e+1)*i-n;o[0]=t*i,o[1]=a,o[2]=s,o[3]=l};let s=new mf(r);const a=[];for(let e=0;e=1;r/=2){const t=i[i.length-1];s=new mf(r);for(let e=0;e0;){const{idx:a,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[a]){xf(f,m,_,t,e,i,r,u,h);const a=1<<_,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,g=(m+1)/a,y=wf(l,p,this.dem)*s,x=wf(c,p,this.dem)*s,v=wf(c,g,this.dem)*s,b=wf(l,g,this.dem)*s,w=gf(u[0],u[1],y,h[0],u[1],x,h[0],h[1],v,o,n),T=gf(h[0],h[1],v,u[0],h[1],b,u[0],u[1],y,o,n),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const t=Dl([],o,n,d);if(bf(y,x,b,v,yf(t[0],u[0],h[0]),yf(t[1],u[1],h[1]))>=t[2])return d}continue}let g=0;for(let p=0;p=l[c[i]]&&(c.splice(i,0,p),e=!0);e||(c[g]=p),g++}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}_unpackMapbox(t,e,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}static pack(t,e){const i=[0,0,0,0],r=Ef.getUnpackVector(e);let o=Math.floor((t+r[3])/r[2]);return i[2]=o%256,o=Math.floor(o/256),i[1]=o%256,o=Math.floor(o/256),i[0]=o,i}getPixels(){return new cc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,o=e*this.dim+this.dim,n=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:r=o-1;break;case 1:o=r+1}switch(i){case-1:n=s-1;break;case 1:s=n+1}const a=-e*this.dim,l=-i*this.dim;for(let e=n;e{this.remove(t,o)}),i)),this.data[r].push(o),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),o=this.data[i][r];return this.data[i].splice(r,1),o.timeout&&clearTimeout(o.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(o.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class Cf{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Cf.ReadOnly=!1,Cf.ReadWrite=!0,Cf.disabled=new Cf(519,Cf.ReadOnly,[0,1]);const Mf=7680;class Af{constructor(t,e,i,r,o,n){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=o,this.pass=n}}Af.disabled=new Af({func:519,mask:0},0,0,Mf,Mf,Mf);class If{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}If.Replace=[1,0],If.disabled=new If(If.Replace,ye.transparent,[!1,!1,!1,!1]),If.unblended=new If(If.Replace,ye.transparent,[!0,!0,!0,!0]),If.alphaBlended=new If([1,771],ye.transparent,[!0,!0,!0,!0]);const zf=1029,kf=2305;class Pf{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}Pf.disabled=new Pf(!1,zf,kf),Pf.backCCW=new Pf(!0,zf,kf),Pf.backCW=new Pf(!0,zf,2304),Pf.frontCW=new Pf(!0,1028,2304),Pf.frontCCW=new Pf(!0,1028,kf);class Df extends Zt{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Sf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new ff,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const e in this._tiles){const i=this._tiles[e];this._source.prepareTile(i)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,i.tileID),i.upload(t),i.prepare(this.map.style.imageManager)}else for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return x(this._tiles).map((t=>t.tileID)).sort(Lf).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,r=e.tileID,o=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Lf).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,r){if(r)if(t.state="errored",404!==r.status)this._source.fire(new Gt(r,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=W.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Nt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+o)?i+=o:1===Math.abs(i-o)&&(i-=o)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[n]&&(t.neighboringTiles[n].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const o in this._tiles){let n=this._tiles[o];if(r[o]||!n.hasData()||n.tileID.overscaledZ<=e||n.tileID.overscaledZ>i)continue;let s=n.tileID;for(;n&&n.tileID.overscaledZ>e+1;){const t=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[t.key],n&&n.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){r[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,r=Math.ceil(t.height/e)+1,o=Math.floor(i*r*5),n="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,o):o,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Mu(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const o=this._updateRetainedTiles(r);if(Bf(this._source.type)&&0!==r.length){const t={},e={},i=Object.keys(o);for(const r of i){const i=o[r],n=this._tiles[r];if(!n||n.fadeEndTime&&n.fadeEndTime<=W.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Df.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),e[r]=i}const n=r[r.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(o[t]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>n;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&e[r.key]){o[t]=i.tileID;break}}}for(const e in t)o[e]||(this._coveredTiles[e]=!0,o[e]=t[e])}for(const t in o)this._tiles[t].clearFadeHold();const n=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i}(this._tiles,o);for(const t of n){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},r=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),o=t[0].overscaledZ,n=Math.max(o-Df.maxOverzooming,this._source.minzoom),s=Math.max(o+Df.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||r=this._source.maxzoom){const t=r.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=r.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let o=t.wasRequested();for(let s=r.overscaledZ-1;s>=n;--s){const n=r.scaledTo(s);if(i[n.key])break;if(i[n.key]=!0,t=this.getTile(n),!t&&o&&(t=this._addTile(n)),t&&(e[n.key]=n,o=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return this._source.prepareTile&&this._source.prepareTile(e),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null;e=new df(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._source.prepareTile&&this._source.prepareTile(e)||this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Nt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const r=[],o=this.transform;if(!o)return r;const n="globe"===o.projection.name,s=Aa(o.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(n){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(m(s,...Rf(t,-1))-s),Math.abs(m(s,...Rf(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(m(s,...Rf(t,-1))-s),Math.abs(m(s,...Rf(t,0))-s),Math.abs(m(s,...Rf(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const n=t.containsTile(l,o,e,i);n&&r.push(n)}}return r}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(Bf(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=W.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){const i=new Map,r=Array.isArray(t)?t:[t],o=this.map.painter.terrain,n=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const t of r){const e=t.coveringTiles({tileSize:n,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}y(Array.from(i.values()),((t,e)=>{const i=new df(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function Lf(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Bf(t){return"raster"===t||"image"===t||"video"===t}function Rf(t,e){const i=1<=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new pu.VectorTile(new ch(this.rawTileData)).layers,this.sourceLayerCoder=new tf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,r){this.loadVTLayers();const o=t.params||{},n=Yr(o.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,r)=>ol(s.bufferedTilespaceGeometry,t,e,i,r)));c.sort(Vf);let u=null;a.elevation&&c.length>0&&(u=Ff.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a(f||(f=Ga(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,r,f,this.z,t.transform,t.pixelPosMatrix,u,o))))}return h}loadMatchingFeature(t,e,i,r,o,n,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,d=this.bucketLayerIDs[u];if(r&&!function(t,e){for(let i=0;i=0)return!0;return!1}(r,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=Za(m,!0);if(!i.filter(new Pn(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new Pn(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let e=0;e{const s=e instanceof Vn?e.get(n):null;return s&&s.evaluate?s.evaluate(i,r,o):s}))}function Vf(t,e){return e-t}Po(Of,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class jf{constructor(t){const e={},i=[];for(const r in t){const o=t[r],n=e[r]={};for(const t in o.glyphs){const e=o.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const r=e.metrics.localGlyph?2:1,s={x:0,y:0,w:e.bitmap.width+2*r,h:e.bitmap.height+2*r};i.push(s),n[t]=s}}const{w:r,h:o}=Ph(i),n=new lc({width:r||1,height:o||1});for(const i in t){const r=t[i];for(const t in r.glyphs){const o=r.glyphs[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const s=e[i][t],a=o.metrics.localGlyph?2:1;lc.copy(o.bitmap,n,{x:0,y:0},{x:s.x+a,y:s.y+a},o.bitmap)}}this.image=n,this.positions=e}}Po(jf,"GlyphAtlas");class Nf{constructor(t){this.tileID=new Mu(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=cd(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,e,i,r,o){this.status="parsing",this.data=t,this.collisionBoxArray=new As;const n=new tf(Object.keys(t.layers).sort()),s=new Of(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Kd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},u=e.familiesBySource[this.source];for(const e in u){const r=t.layers[e];if(!r)continue;let o=!1,l=!1;for(const t of u[e])"symbol"===t[0].type?o=!0:l=!0;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&P(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=n.encode(e),p=[];for(let t=0;t=e.maxzoom||"none"!==e.visibility&&(Gf(t,this.zoom,i),(a[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:i})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(t.map((t=>t.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=A(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{h||(h=t,p=e,v.call(this))}),void 0,!1,m):p={};const g=Object.keys(c.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{h||(h=t,d=e,v.call(this))}),void 0,!1,m):d={};const y=Object.keys(c.patternDependencies);function v(){if(h)return o(h);if(p&&d&&f){const t=new jf(p),e=new Lh(d,f);for(const r in a){const o=a[r];o instanceof Ud?(Gf(o.layers,this.zoom,i),Sp(o,p,t.positions,d,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection)):o.hasPattern&&(o instanceof Uu||o instanceof Kc||o instanceof xu)&&(Gf(o.layers,this.zoom,i),o.addFeatures(c,this.tileID.canonical,e.patternPositions,i,this.tileTransform))}this.status="done",o(null,{buckets:x(a).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?t.positions:null})}}y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{h||(h=t,f=e,v.call(this))}),void 0,!1,m):f={},v.call(this)}}function Gf(t,e,i){const r=new Pn(e);for(const e of t)e.recalculate(r,i)}class Zf{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,r){const o=this.entries[t]=this.entries[t]||{callbacks:[]};if(o.result){const[t,i]=o.result;return this.scheduler?this.scheduler.add((()=>{r(t,i)}),e):r(t,i),()=>{}}return o.callbacks.push(r),o.cancel||(o.cancel=i(((i,r)=>{o.result=[i,r];for(const t of o.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,r)}),e):t(i,r);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{o.result||(o.callbacks=o.callbacks.filter((t=>t!==r)),o.callbacks.length||(o.cancel(),delete this.entries[t]))}}}function $f(t,e,i){const r=JSON.stringify(t.request);return t.data&&(this.deduped.entries[r]={result:[null,t.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const r=Pt(t.request,((t,r,o,n)=>{t?e(t):r&&e(null,{vectorTile:i?void 0:new pu.VectorTile(new ch(r)),rawData:r,cacheControl:o,expires:n})}));return()=>{r.cancel(),e()}}),e)}t.ARRAY_TYPE=dl,t.AUTH_ERR_MSG=ot,t.Aabb=Jl,t.Actor=class{constructor(t,i,r){this.target=t,this.parent=i,this.mapId=r,this.callbacks={},this.cancelCallbacks={},C(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=B()?t:e,this.scheduler=new Qd}send(t,e,i,r,o=!1,n){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=n,this.callbacks[s]=i);const a=O(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:t,hasCallback:!!i,targetMapId:r,mustQueue:o,sourceMapId:this.mapId,data:Bo(e,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||B()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ro(e.error)):i(null,Ro(e.data)))}else{const i=O(this.globalScope)?void 0:[],r=e.hasCallback?(e,r)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Bo(e):null,data:Bo(r,i)},i)}:t=>{},o=Ro(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,o,r);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],o.source)[t[1]](o,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=Su,t.Color=ye,t.ColorMode=If,t.CullFaceMode=Pf,t.DEMData=Ef,t.DataConstantProperty=jn,t.DedupedRequest=Zf,t.DepthMode=Cf,t.EXTENT=wa,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,r=1<1)return e;const o=r.getSource().maxzoom,n=1<{const n=this.getAtTileOffset(t,o.x,o.y),s=r.upVector(t.canonical,o.x,o.y);return Pl(s,s,n*r.upVectorScale(t.canonical,e,i).metersToTile),s}}getForTilePoints(t,e,i,r){const o=Ff.create(this,t,r);return!!o&&(e.forEach((t=>{t[2]=this.exaggeration()*o.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,r=e.tileID,o=1<this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!nt(t))return t;const i=lt(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!nt(t))return t;const i=lt(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,r){if(!nt(t))return t;const o=lt(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),i&&o.params.push(`language=${i}`),r&&o.params.push(`worldview=${r}`),this._makeAPIURL(o,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,r){const o=lt(t);return nt(t)?(o.path=`/styles/v1${o.path}/sprite${e}${i}`,this._makeAPIURL(o,this._customAccessToken||r)):(o.path+=`${e}${i}`,ct(o))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!nt(t))return t;const r=lt(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==r.authority&&512===i?"@2x":""}${K.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${Y.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${Y.TILE_URL_VERSION}${r.path}`);const o=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(r.params)||Y.ACCESS_TOKEN;return Y.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,o)}canonicalizeTileURL(t,e){const i=lt(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${Y.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${Y.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,e){const i=!!e&&nt(e),r=[];for(const e of t.tiles||[])st(e)?r.push(this.canonicalizeTileURL(e,i)):r.push(e);return r}_makeAPIURL(t,e){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=lt(Y.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!Y.REQUIRE_ACCESS_TOKEN)return ct(t);if(e=e||Y.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),ct(t)}},t.ResourceType=At,t.SegmentVector=ba,t.SourceCache=Df,t.StencilMode=Af,t.StructArrayLayout1ui2=Ts,t.StructArrayLayout2f1f2i16=ps,t.StructArrayLayout2i4=Qn,t.StructArrayLayout2ui4=ws,t.StructArrayLayout3f12=fs,t.StructArrayLayout3ui6=ms,t.StructArrayLayout4i8=es,t.StructArrayLayout5f20=vs,t.Texture=Yd,t.Tile=df,t.Transitionable=Bn,t.Uniform1f=Js,t.Uniform1i=class extends Ks{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends Ks{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends Ks{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=Qs,t.UniformColor=ta,t.UniformMatrix2f=class extends Ks{constructor(t,e){super(t,e),this.current=ra}set(t){for(let e=0;e<4;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix2fv(this.location,!1,t);break}}},t.UniformMatrix3f=class extends Ks{constructor(t,e){super(t,e),this.current=ia}set(t){for(let e=0;e<9;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}},t.UniformMatrix4f=class extends Ks{constructor(t,e){super(t,e),this.current=ea}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=Cu,t.ValidationError=jr,t.VectorTileWorkerSource=class extends Zt{constructor(t,e,i,r,o){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=o||$f,this.loading={},this.loaded={},this.deduped=new Zf(t.scheduler),this.isSpriteLoaded=r,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,r=t&&t.request,o=r&&r.collectResourceTiming,n=this.loading[i]=new Nf(t);n.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return n.status="done",l||(this.loaded[i]=n),e(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),n.vectorTile=a.vectorTile||new pu.VectorTile(new ch(c));const h=()=>{n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const n={};if(o){const t=N(r);t.length>0&&(n.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,v({rawTileData:c.slice(0)},i,u,n))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[i]=n}))}reloadTile(t,e){const i=this.loaded,r=t.uid,o=this;if(i&&i[r]){const n=i[r];n.showCollisionBoxes=t.showCollisionBoxes,n.enableTerrain=!!t.enableTerrain,n.projection=t.projection,n.tileTransform=cd(t.tileID.canonical,t.projection);const s=(t,i)=>{const r=n.reloadCallback;r&&(delete n.reloadCallback,n.parse(n.vectorTile,o.layerIndex,this.availableImages,o.actor,r)),e(t,i)};"parsing"===n.status?n.reloadCallback=s:"done"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(t,e){const i=t.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}},t.WritingMode=Bh,t.ZoomHistory=Fo,t.add=Ml,t.addDynamicAttributes=Bd,t.adjoint=function(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=s*u-a*c,t[1]=o*c-r*u,t[2]=r*a-o*s,t[3]=a*l-n*u,t[4]=i*u-o*l,t[5]=o*n-i*a,t[6]=n*c-s*l,t[7]=r*l-i*c,t[8]=i*s-r*n,t},t.asyncAll=y,t.bezier=d,t.bindAll=C,t.boundsAttributes=hf,t.bufferConvexPolygon=function(t,e){const i=[];for(let r=0;rbt&&(t.getActor().send("enforceCacheSizeLimit",vt),Mt=0)},t.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:r}=t.point,o=id(i,r,t.worldSize/t._projectionScaler,0,0);return _l(o,o,ed(Xp(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:r,lat:o}=t._center;return id(e,i,t.worldSize,r,o)},t.calculateGlobeMercatorMatrix=function(t){const e=t.worldSize,i=t.point,r=za(1,t.center.lat)*e,o=t.pixelsPerMeter,n=e/(r/t.pixelsPerMeter),s=ml(new Float64Array(16));return gl(s,s,[i.x,i.y,0]),yl(s,s,[n,n,o]),Float32Array.from(s)},t.circumferenceAtLatitude=Ma,t.clamp=m,t.clearTileCache=function(t){const i=[];for(const t in wt)i.push(e.caches.delete(t)),delete wt[t];t&&Promise.all(i).catch(t).then((()=>t()))},t.clipLine=np,t.clone=function(t){var e=new dl(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=z,t.collisionCircleLayout=Yu,t.config=Y,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new dl(16);return dl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=fl,t.createExpression=Br,t.createLayout=Kn,t.createStyleLayer=function(t){return"custom"===t.type?new qd(t):new Hd[t.type](t)},t.cross=Rl,t.degToRad=c,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},t.dot=Bl,t.ease=f,t.easeCubicInOut=p,t.emitValidationErrors=Ao,t.endsWith=M,t.enforceCacheSizeLimit=function(t){for(const e in wt)Et(e),wt[e].then((e=>{e.keys().then((i=>{for(let r=0;rn&&(r+=(t[o]-n)*(t[o]-n)),e[o]{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=ml(new Float64Array(16));return _l(i,t.pixelMatrix,t.globeMatrix),Fl(e,e,i),new n(e[0],e[1])},t.globeECEFOrigin=function(t,e){const i=[0,0,0];return Fl(i,i,td(Xp(e.canonical))),Fl(i,i,t),i},t.globeNormalizeECEF=td,t.globePixelsToTileUnits=function(t,e){return wa/(512*Math.pow(2,t))*Qp(Xp(e))},t.globePoleMatrixForTile=function(t,e,i){const r=ml(new Float64Array(16)),o=1<0;return 0===r&&!o&&!s&&n},t.identity=ml,t.identity$1=ql,t.invert=function(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],d=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*s,x=i*l-o*s,v=i*c-n*s,b=r*l-o*a,w=r*c-n*a,T=o*c-n*l,E=u*m-h*f,S=u*_-p*f,C=u*g-d*f,M=h*_-p*m,A=h*g-d*m,I=p*g-d*_,z=y*I-x*A+v*M+b*C-w*S+T*E;return z?(t[0]=(a*I-l*A+c*M)*(z=1/z),t[1]=(o*A-r*I-n*M)*z,t[2]=(m*T-_*w+g*b)*z,t[3]=(p*w-h*T-d*b)*z,t[4]=(l*C-s*I-c*S)*z,t[5]=(i*I-o*C+n*S)*z,t[6]=(_*v-f*T-g*x)*z,t[7]=(u*T-p*v+d*x)*z,t[8]=(s*A-a*C+c*E)*z,t[9]=(r*C-i*A-n*E)*z,t[10]=(f*w-m*v+g*y)*z,t[11]=(h*v-u*w-d*y)*z,t[12]=(a*S-s*M-l*E)*z,t[13]=(i*M-r*S+o*E)*z,t[14]=(m*x-f*b-_*y)*z,t[15]=(u*b-h*x+p*y)*z,t):null},t.isLngLatBehindGlobe=function(t,e){return od(t,e)>Math.PI/2*1.01},t.isMapAuthenticated=function(t){return yt.has(t)},t.isMapboxURL=nt,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!O(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Pa,t.len=Nl,t.length=Sl,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=$f,t.makeRequest=kt,t.mapValue=function(t,e,i,r,o){return m((t-e)/(i-e)*(o-r)+r,r,o)},t.mercatorXfromLng=Aa,t.mercatorYfromLat=Ia,t.mercatorZfromAltitude=za,t.mul=wl,t.mul$1=jl,t.multiply=_l,t.multiply$1=function(t,e,i){var r=e[0],o=e[1],n=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=i[0],d=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return t[0]=p*r+d*s+f*c,t[1]=p*o+d*a+f*u,t[2]=p*n+d*l+f*h,t[3]=m*r+_*s+g*c,t[4]=m*o+_*a+g*u,t[5]=m*n+_*l+g*h,t[6]=y*r+x*s+v*c,t[7]=y*o+x*a+v*u,t[8]=y*n+x*l+v*h,t},t.multiply$2=Il,t.nextPowerOfTwo=E,t.normalize=Ll,t.normalize$1=function(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=i*i+r*r+o*o+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=r*s,t[2]=o*s,t[3]=n*s,t},t.number=yi,t.ortho=function(t,e,i,r,o,n,s){var a=1/(e-i),l=1/(r-o),c=1/(n-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(o+r)*l,t[14]=(s+n)*c,t[15]=1,t},t.pbf=ch,t.perspective=function(t,e,i,r,o){var n,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=o&&o!==1/0?(t[10]=(o+r)*(n=1/(r-o)),t[14]=2*o*r*n):(t[10]=-1,t[14]=-2*r),t},t.pick=function(t,e){const i={};for(let r=0;rMo(lo(t)),t.validateFog=t=>Mo(vo(t)),t.validateLayer=t=>Mo(fo(t)),t.validateLight=t=>Mo(yo(t)),t.validateSource=t=>Mo(go(t)),t.validateStyle=Eo,t.validateTerrain=t=>Mo(xo(t)),t.values=x,t.vectorTile=pu,t.version=G,t.warnOnce=P,t.window=e,t.wrap=g})),o(["./shared"],(function(t){function e(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let i="[";for(const r of t)i+=`${e(r)},`;return`${i}]`}let i="{";for(const r of Object.keys(t).sort())i+=`${r}:${e(t[r])},`;return`${i}}`}function i(i){let r="";for(const o of t.refProperties)r+=`/${e(i[o])}`;return r}class r{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,r){for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of r)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const o=function(t,e){const r={};for(let o=0;othis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const n=i.sourceLayer||"_geojsonTileLayer";let s=o[n];s||(s=o[n]=[]),s.push(e)}}}class o{loadTile(e,i){const{uid:r,encoding:o,rawImageData:n,padding:s,buildQuadTree:a}=e,l=t.window.ImageBitmap&&n instanceof t.window.ImageBitmap?this.getImageData(n,s):n;i(null,new t.DEMData(r,l,o,s<1,a))}getImageData(t,e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const i=this.offscreenCanvasContext.getImageData(-e,-e,t.width+2*e,t.height+2*e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}var n=function t(e,i){var r,o=e&&e.type;if("FeatureCollection"===o)for(r=0;r=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!e&&t.reverse()}const l=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class c{constructor(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return l.call(this,t,e,i)}}class u{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new c(this._features[t])}}var h=t.vectorTile.VectorTileFeature,p=d;function d(t,e){this.options=e||{},this.features=t,this.length=t.length}function f(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}d.prototype.feature=function(t){return new f(this.features[t],this.options.extent)},f.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var i=0;i>31}function T(t,e){for(var i=t.loadGeometry(),r=t.type,o=0,n=0,s=i.length,a=0;a>1;C(t,e,s,r,o,n%2),S(t,e,i,r,s-1,n+1),S(t,e,i,s+1,o,n+1)}function C(t,e,i,r,o,n){for(;o>r;){if(o-r>600){const s=o-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);C(t,e,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(o,Math.floor(i+(s-a)*c/s+u)),n)}const s=e[2*i+n];let a=r,l=o;for(M(t,e,r,i),e[2*o+n]>s&&M(t,e,r,o);as;)l--}e[2*r+n]===s?M(t,e,r,l):(l++,M(t,e,l,o)),l<=i&&(r=l+1),i<=l&&(o=l-1)}}function M(t,e,i,r){A(t,i,r),A(e,2*i,2*r),A(e,2*i+1,2*r+1)}function A(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function I(t,e,i,r){const o=t-i,n=e-r;return o*o+n*n}m.fromVectorTileJs=g,m.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new p(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return g({layers:i})},m.GeoJSONWrapper=_;const z=t=>t[0],k=t=>t[1];class P{constructor(t,e=z,i=k,r=64,o=Float64Array){this.nodeSize=r,this.points=t;const n=t.length<65536?Uint16Array:Uint32Array,s=this.ids=new n(t.length),a=this.coords=new o(2*t.length);for(let r=0;r=i&&c<=o&&u>=r&&u<=n&&l.push(t[s]);continue}const f=Math.floor((d+p)/2);c=e[2*f],u=e[2*f+1],c>=i&&c<=o&&u>=r&&u<=n&&l.push(t[f]);const m=(h+1)%2;(0===h?i<=c:r<=u)&&(a.push(d),a.push(f-1),a.push(m)),(0===h?o>=c:n>=u)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,o,n){const s=[0,t.length-1,0],a=[],l=o*o;for(;s.length;){const c=s.pop(),u=s.pop(),h=s.pop();if(u-h<=n){for(let o=h;o<=u;o++)I(e[2*o],e[2*o+1],i,r)<=l&&a.push(t[o]);continue}const p=Math.floor((h+u)/2),d=e[2*p],f=e[2*p+1];I(d,f,i,r)<=l&&a.push(t[p]);const m=(c+1)%2;(0===c?i-o<=d:r-o<=f)&&(s.push(h),s.push(p-1),s.push(m)),(0===c?i+o>=d:r+o>=f)&&(s.push(p+1),s.push(u),s.push(m))}return a}(this.ids,this.coords,t,e,i,this.nodeSize)}}const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},L=Math.fround||(B=new Float32Array(1),t=>(B[0]=+t,B[0]));var B;class R{constructor(t){this.options=Z(Object.create(D),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:o}=this.options;e&&console.time("total time");const n=`prepare ${t.length} points`;e&&console.time(n),this.points=t;let s=[];for(let e=0;e=i;t--){const i=+Date.now();s=this._cluster(s,t),this.trees[t]=new P(s,$,q,o,Float32Array),e&&console.log("z%d: %d clusters in %dms",t,s.length,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let o=180===t[2]?180:((t[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,o=180;else if(i>o){const t=this.getClusters([i,r,180,n],e),s=this.getClusters([-180,r,o,n],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(j(i),N(n),j(o),N(r)),l=[];for(const t of a){const e=s.points[t];l.push(e.numPoints?U(e):this.points[e.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",o=this.trees[i];if(!o)throw new Error(r);const n=o.points[e];if(!n)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=o.within(n.x,n.y,s),l=[];for(const e of a){const i=o.points[e];i.parentId===t&&l.push(i.numPoints?U(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],o=Math.pow(2,t),{extent:n,radius:s}=this.options,a=s/n,l=(i-a)/o,c=(i+1+a)/o,u={features:[]};return this._addTileFeatures(r.range((e-a)/o,l,(e+1+a)/o,c),r.points,e,i,o,u),0===e&&this._addTileFeatures(r.range(1-a/o,l,1,c),r.points,o,i,o,u),e===o-1&&this._addTileFeatures(r.range(0,l,a/o,c),r.points,-1,i,o,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,o){const n=this.getChildren(e);for(const e of n){const n=e.properties;if(n&&n.cluster?o+n.point_count<=r?o+=n.point_count:o=this._appendLeaves(t,n.cluster_id,i,r,o):oe&&(h+=i.numPoints||1)}if(h>u&&h>=s){let t=o.x*u,s=o.y*u,a=n&&u>1?this._map(o,!0):null;const p=(r<<5)+(e+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=e)continue;r.zoom=e;const c=r.numPoints||1;t+=r.x*c,s+=r.y*c,r.parentId=p,n&&(a||(a=this._map(o,!0)),n(a,this._map(r)))}o.parentId=p,i.push(F(t/h,s/h,p,h,a))}else if(i.push(o),h>1)for(const t of c){const r=l.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?Z({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?Z({},r):r}}function F(t,e,i,r,o){return{x:L(t),y:L(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:o}}function O(t,e){const[i,r]=t.geometry.coordinates;return{x:L(j(i)),y:L(N(r)),zoom:1/0,index:e,parentId:-1}}function U(t){return{type:"Feature",id:t.id,properties:V(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),G(t.y)]}};var e}function V(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return Z(Z({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function j(t){return t/360+.5}function N(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function G(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function Z(t,e){for(const i in e)t[i]=e[i];return t}function $(t){return t.x}function q(t){return t.y}function X(t,e,i,r){for(var o,n=r,s=i-e>>1,a=i-e,l=t[e],c=t[e+1],u=t[i],h=t[i+1],p=e+3;pn)o=p,n=d;else if(d===n){var f=Math.abs(p-s);fr&&(o-e>3&&X(t,e,o,r),t[o+2]=n,i-o>3&&X(t,o,i,r))}function W(t,e,i,r,o,n){var s=o-i,a=n-r;if(0!==s||0!==a){var l=((t-i)*s+(e-r)*a)/(s*s+a*a);l>1?(i=o,r=n):l>0&&(i+=s*l,r+=a*l)}return(s=t-i)*s+(a=e-r)*a}function H(t,e,i,r){var o={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)Y(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r0&&(s+=r?(o*c-l*n)/2:Math.sqrt(Math.pow(l-o,2)+Math.pow(c-n,2))),o=l,n=c}var u=e.length-3;e[2]=1,X(e,0,u,i),e[u+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function tt(t,e,i,r){for(var o=0;o1?1:i}function rt(t,e,i,r,o,n,s,a){if(r/=e,n>=(i/=e)&&s=r)return null;for(var l=[],c=0;c=i&&f=r)){var m=[];if("Point"===p||"MultiPoint"===p)ot(h,m,i,r,o);else if("LineString"===p)nt(h,m,i,r,o,!1,a.lineMetrics);else if("MultiLineString"===p)at(h,m,i,r,o,!1);else if("Polygon"===p)at(h,m,i,r,o,!0);else if("MultiPolygon"===p)for(var _=0;_=i&&s<=r&&(e.push(t[n]),e.push(t[n+1]),e.push(t[n+2]))}}function nt(t,e,i,r,o,n,s){for(var a,l,c=st(t),u=0===o?ct:ut,h=t.start,p=0;pi&&(l=u(c,d,f,_,g,i),s&&(c.start=h+a*l)):y>r?x=i&&(l=u(c,d,f,_,g,i),v=!0),x>r&&y<=r&&(l=u(c,d,f,_,g,r),v=!0),!n&&v&&(s&&(c.end=h+a*l),e.push(c),c=st(t)),s&&(h+=a)}var b=t.length-3;d=t[b],f=t[b+1],m=t[b+2],(y=0===o?d:f)>=i&&y<=r&<(c,d,f,m),b=c.length-3,n&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&<(c,c[0],c[1],c[2]),c.length&&e.push(c)}function st(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function at(t,e,i,r,o,n){for(var s=0;ss.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function _t(t,e,i,r){var o=e.geometry,n=e.type,s=[];if("Point"===n||"MultiPoint"===n)for(var a=0;a0&&e.size<(o?s:r))i.numPoints+=e.length/3;else{for(var a=[],l=0;ls)&&(i.numSimplified++,a.push(e[l]),a.push(e[l+1])),i.numPoints++;o&&function(t,e){for(var i=0,r=0,o=t.length,n=o-2;r0===e)for(r=0,o=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r1&&console.time("creation"),p=this.tiles[h]=mt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=t,o){if(e===l.maxZoom||e===o)continue;var f=1<1&&console.time("clipping");var m,_,g,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,x=rt(t,u,i-b,i+T,0,p.minX,p.maxX,l),v=rt(t,u,i+w,i+E,0,p.minX,p.maxX,l),t=null,x&&(m=rt(x,u,r-b,r+T,1,p.minY,p.maxY,l),_=rt(x,u,r+w,r+E,1,p.minY,p.maxY,l),x=null),v&&(g=rt(v,u,r-b,r+T,1,p.minY,p.maxY,l),y=rt(v,u,r+w,r+E,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(m||[],e+1,2*i,2*r),a.push(_||[],e+1,2*i,2*r+1),a.push(g||[],e+1,2*i+1,2*r),a.push(y||[],e+1,2*i+1,2*r+1)}}},yt.prototype.getTile=function(t,e,i){var r=this.options,o=r.extent,n=r.debug;if(t<0||t>24)return null;var s=1<1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,u=e,h=i;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[xt(c,u,h)];return l&&l.source?(n>1&&console.log("found parent tile z%d-%d-%d",c,u,h),n>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,t,e,i),n>1&&console.timeEnd("drilling down"),this.tiles[a]?dt(this.tiles[a],o):null):null};class bt extends t.VectorTileWorkerSource{constructor(t,e,i,r,o){super(t,e,i,r,vt),o&&(this.loadGeoJSON=o)}loadData(e,i){const r=e&&e.request,o=r&&r.collectResourceTiming;this.loadGeoJSON(e,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{n(a,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=a.features.filter((t=>i.value.evaluate({zoom:0},t)));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=e.cluster?new R(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},o={},n={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const e of a){const[n,s]=i[e],a=t.createExpression(s),l=t.createExpression("string"==typeof n?[n,["accumulated"],["get",e]]:n);r[e]=a.value,o[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=r[t].evaluate(n,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)n.accumulated=t[e],t[e]=o[e].evaluate(n,s)},e}(e)).load(a.features):function(t,e){return new yt(t,e)}(a,e.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(o){const i=t.getPerformanceMeasurement(r);i&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)t.getJSON(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class wt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:bt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}clearCaches(t,e,i){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],i()}checkIfReady(t,e,i){i()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,i){this.isSpriteLoaded[e]=i;for(const r in this.workerSources[e]){const o=this.workerSources[e][r];for(const e in o)o[e]instanceof t.VectorTileWorkerSource&&(o[e].isSpriteLoaded=i,o[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const r=this.workerSources[t][i];for(const t in r)r[t].availableImages=e}i()}enableTerrain(t,e,i){this.terrain=e,i()}setProjection(e,i){this.projections[e]=t.getProjection(i)}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(e,i,r){const o=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;o.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).loadTile(o,r)}loadDEMTile(e,i,r){const o=this.enableTerrain?t.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(e,i.source).loadTile(o,r)}reloadTile(e,i,r){const o=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;o.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).reloadTile(o,r)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,r){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e}getWorkerSource(t,e,i){return this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),this.workerSources[t][e][i]||(this.workerSources[t][e][i]=new this.workerSourceTypes[e]({send:(e,i,r,o,n,s)=>{this.actor.send(e,i,r,t,n,s)},scheduler:this.actor.scheduler},this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded[t])),this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new o),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(t,e,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new wt(self)),wt})),o(["./shared"],(function(t){function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r{t.window.removeEventListener("click",p,!0)}),0)}function f(t,e){const i=t.getBoundingClientRect();return g(t,i,e)}function m(t,e){const i=t.getBoundingClientRect(),r=[];for(let o=0;o=0?0:e.button}function g(e,i,r){const o=e.offsetWidth===i.width?1:e.offsetWidth/i.width;return new t.pointGeometry((r.clientX-i.left)*o,(r.clientY-i.top)*o)}function y(t,e){var i=e[0],r=e[1],o=e[2],n=e[3],s=i*n-o*r;return s?(t[0]=n*(s=1/s),t[1]=-r*s,t[2]=-o*s,t[3]=i*s,t):null}function x(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class v extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}hasImage(t){return!!this.getImage(t)}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]{this.ready=!0}))}broadcast(e,i,r){t.asyncAll(this.actors,((t,r)=>{t.send(e,i,r)}),r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function D(e,i,r){return i*(t.EXTENT/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}P.Actor=t.Actor;class L{constructor(t,e,i,r){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(e,i){let r,o;if(e instanceof t.pointGeometry||"number"==typeof e[0]){const n=t.pointGeometry.convert(e);r=[t.pointGeometry.convert(e)],o=i.isPointAboveHorizon(n)}else{const n=t.pointGeometry.convert(e[0]),s=t.pointGeometry.convert(e[1]);r=[n,s],o=t.polygonizeBounds(n,s).every((t=>i.isPointAboveHorizon(t)))}return new L(r,i.getCameraPoint(),o,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],o=t.polygonizeBounds(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=r.x?o[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(o[3]=this.cameraPoint)),t.bufferConvexPolygon(o,e)}bufferedCameraGeometryGlobe(e){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new t.pointGeometry(1,1)):this.screenBounds[1],o=t.polygonizeBounds(i,r,e),n=this.cameraPoint.clone();switch(3*((n.y>i.y)+(n.y>r.y))+((n.x>i.x)+(n.x>r.x))){case 0:o[0]=n,o[4]=n.clone();break;case 1:o.splice(1,0,n);break;case 2:o[1]=n;break;case 3:o.splice(4,0,n);break;case 5:o.splice(2,0,n);break;case 6:o[3]=n;break;case 7:o.splice(3,0,n);break;case 8:o[2]=n}return o}containsTile(e,i,r,o=0){const n=e.queryPadding/i._projectionScaler+1,s=r?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let a=e.tileID.wrap+(s.unwrapped?o:0);const l=s.polygon.map((i=>t.getTilePoint(e.tileTransform,i,a)));if(!t.polygonIntersectsBox(l,0,0,t.EXTENT,t.EXTENT))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?o:0);const c=this.screenGeometryMercator.polygon.map((i=>t.getTileVec3(e.tileTransform,i,a))),u=c.map((e=>new t.pointGeometry(e[0],e[1]))),h=i.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),p=t.getTileVec3(e.tileTransform,h,a),d=c.map((e=>{const i=t.sub(e,e,p);return t.normalize(i,i),new t.Ray(p,i)})),f=D(e,1,i.zoom)*i._projectionScaler;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=t.getBounds(l),m.min.x=t.clamp(m.min.x,0,t.EXTENT),m.min.y=t.clamp(m.min.y,0,t.EXTENT),m.max.x=t.clamp(m.max.x,0,t.EXTENT),m.max.y=t.clamp(m.max.y,0,t.EXTENT),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(t,e){const i=F(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===e.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),e):{polygon:this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(t,e){const i=F(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===e.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),e):{polygon:this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,i){const r=function(e,i){const r=t.multiply([],i.pixelMatrix,i.globeMatrix),o=[0,-t.GLOBE_RADIUS,0,1],n=[0,t.GLOBE_RADIUS,0,1],s=[0,0,0,1];t.transformMat4$1(o,o,r),t.transformMat4$1(n,n,r),t.transformMat4$1(s,s,r);const a=new t.pointGeometry(o[0]/o[3],o[1]/o[3]),l=new t.pointGeometry(n[0]/n[3],n[1]/n[3]),c=t.polygonContainsPoint(e,a)&&o[3]1?B(e.slice(0,p),i):[],m=pnew t.pointGeometry(R(e.x),e.y))),m=m.map((e=>new t.pointGeometry(R(e.x),e.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=t.number(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new t.pointGeometry(0,g),new t.pointGeometry(0,0),new t.pointGeometry(1,0),new t.pointGeometry(1,g)]:[new t.pointGeometry(1,g),new t.pointGeometry(1,1),new t.pointGeometry(0,1),new t.pointGeometry(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,i);if(r)return r;const o=function(e,i){let r=!1,o=-1/0,n=0;for(let t=0;to&&(o=e[t].x,n=t);for(let t=0;t.5&&(o.x{t.x-=1})),{polygon:e,unwrapped:r}}(B(e,i).map((e=>new t.pointGeometry(R(e.x),e.y))),i);return{polygon:o.polygon.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:o.unwrapped}}}function B(e,i){return t.resample(e,(t=>{const e=i.pointCoordinate3D(t);t.x=e.x,t.y=e.y}),1/256)}function R(t){return t<0?1+t%1:t%1}function F(t){return 100*t|0}function O(e,i,r,o,n){const s=function(r,o){if(r)return n(r);if(o){const r=t.pick(t.extend(o,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);o.vector_layers&&(r.vectorLayers=o.vector_layers,r.vectorLayerIds=r.vectorLayers.map((t=>t.id))),o.language_options&&(r.languageOptions=o.language_options),o.language&&o.language[o.id]&&(r.language=o.language[o.id]),o.worldview_options&&(r.worldviewOptions=o.worldview_options),o.worldview?r.worldview=o.worldview[o.id]:o.worldview_default&&(r.worldview=o.worldview_default),r.tiles=i.canonicalizeTileset(r,e.url),n(null,r)}};return e.url?t.getJSON(i.transformRequest(i.normalizeSourceURL(e.url,null,r,o),t.ResourceType.Source),s):t.exported.frame((()=>s(null,e)))}class U{constructor(e,i,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),o=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),n=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=r&&e.x=o&&e.y{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new U(i.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(i.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const r=t.exported.devicePixelRatio>=2,o=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(o,t.ResourceType.Tile),((r,o,n,s)=>(delete e.request,e.aborted?(e.state="unloaded",i(null)):r?(e.state="errored",i(r)):o?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:n,expires:s}),e.setTexture(o,this.map.painter),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))))}static loadTileData(t,e,i){t.setTexture(e,i)}static unloadTileData(t,e){t.texture&&e.saveTileTexture(t.texture)}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let At;function It(e,i,r,o,n,s,a,l){const c=[e,r,n,i,o,s,1,1,1],u=[a,l,1],h=t.adjoint([],c),[p,d,f]=t.transformMat3(u,u,t.transpose(h,h));return t.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class zt extends t.Evented{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(e,i){this._loaded=i||!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((i,r)=>{if(this._loaded=!0,i)this.fire(new t.ErrorEvent(i));else if(r){const{HTMLImageElement:i}=t.window;this.image=r instanceof i?t.exported.getImageData(r):r,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const i=e.map(t.MercatorCoordinate.fromLngLat);return this.tileID=function(e){let i=1/0,r=1/0,o=-1/0,n=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),o=Math.max(o,t.x),n=Math.max(n,t.y);const s=Math.max(o-i,n-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new t.CanonicalTileID(a,Math.floor((i+o)/2*l),Math.floor((r+n)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const i=t.tileTransform(this.tileID,this.map.transform.projection),[r,o,n,s]=this.coordinates.map((e=>{const r=i.projection.project(e[0],e[1]);return t.getTilePoint(i,r)._round()}));this.perspectiveTransform=function(e,i,r,o,n,s,a,l,c,u){const h=It(0,0,e,0,0,i,e,i),p=It(r,o,n,s,a,l,c,u);return t.multiply$1(p,t.adjoint(h,h),p),[p[6]/p[8]*e/t.EXTENT,p[7]/p[8]*i/t.EXTENT]}(this.width,this.height,r.x,r.y,o.x,o.y,s.x,s.y,n.x,n.y);const a=this._boundsArray=new t.StructArrayLayout4i8;a.emplaceBack(r.x,r.y,0,0),a.emplaceBack(o.x,o.y,t.EXTENT,0),a.emplaceBack(s.x,s.y,0,t.EXTENT),a.emplaceBack(n.x,n.y,t.EXTENT,t.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,t.boundsAttributes.members),this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture?this.texture.update(this.image):(this.texture=new t.Texture(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._prepareData(e)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const kt={vector:class extends t.Evented{constructor(e,i,r,o){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(i,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(o),this._tileWorkers={},this._deduped=new t.DedupedRequest}load(e){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"}));const i=this.language||this.map._language,r=this.worldview||this.map._worldview;this._tileJSONRequest=O(this._options,this.map._requestManager,i,r,((o,n)=>{this._tileJSONRequest=null,this._loaded=!0,o?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new t.ErrorEvent(o))):n&&(t.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(o)}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load((()=>{const t=this.map.style._getSourceCaches(this.id);for(const e of t)e.clearTiles()}))}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}_setLanguage(t){return t===this.language||this.setSourceProperty((()=>{this.language=t})),this}_setWorldview(t){return t===this.worldview?this:this.worldviewOptions&&t&&!this.worldviewOptions[t]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${t}".`),this):(this.setSourceProperty((()=>{this.worldview=t})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),o={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(o.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",o,n.bind(this));else if(e.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",o,n.bind(this),void 0,!0);else{const i=t.loadVectorTile.call({deduped:this._deduped},o,((t,i)=>{t||!i?n.call(this,t):(o.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",o,n.bind(this),void 0,!0))}),!0);e.request={cancel:i}}function n(r,o){return delete e.request,e.aborted?i(null):r&&404!==r.status?i(r):(o&&o.resourceTiming&&(e.resourceTiming=o.resourceTiming),this.map._refreshExpiredTiles&&o&&e.setExpiryData(o),e.loadVectorData(o,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Mt,"raster-dem":class extends Mt{constructor(e,i,r,o){super(e,i,r,o),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function o(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,n,s,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const i=t.window.ImageBitmap&&n instanceof t.window.ImageBitmap&&(null==At&&(At=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.window.createImageBitmap),At),r=1-(n.width-t.prevPowerOfTwo(n.width))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=i?n:t.exported.getImageData(n,r),c={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,o.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),o=(i.x-1+r)%r,n=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,a=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,n,i.z,o,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,n,i.z,o,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new t.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(e.resourceTiming=i.resourceTiming[this.id]),this.fire(new t.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,i){const r=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(r,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((t,o)=>(delete e.request,e.unloadVectorData(),e.aborted?i(null):t?i(t):(e.loadVectorData(o,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends zt{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:zt,canvas:class extends zt{constructor(e,i,r,o){super(e,i,r,o),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends t.Evented{constructor(e,i,r,o){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(o),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new t.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new t.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new U(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.coveringTiles=this._coveringTiles.bind(this),t.extend(this,t.pick(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return t.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:i,z:r}=t.canonical;return this._implementation.hasTile({x:e,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const{x:r,y:o,z:n}=e.tileID.canonical,s=new t.window.AbortController,a=this._implementation.loadTile({x:r,y:o,z:n},{signal:s.signal});if(!a)return this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null);a.cancel=()=>s.abort(),e.request=a.then(function(r){return delete e.request,e.aborted?(e.state="unloaded",i(null)):r?function(e){return e instanceof t.window.ImageData||e instanceof t.window.ImageBitmap||e instanceof t.window.HTMLCanvasElement}(r)?(this.loadTileData(e,r),e.state="loaded",void i(null)):(e.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",i(t))}))}loadTileData(t,e){Mt.loadTileData(t,e,this._map.painter)}unloadTileData(t){Mt.unloadTileData(t,this._map.painter)}prepareTile(t){if(!this._implementation.prepareTile)return null;const{x:e,y:i,z:r}=t.tileID.canonical,o=this._implementation.prepareTile({x:e,y:i,z:r});return o?(this.loadTileData(t,o),t.state="loaded",o):null}unloadTile(t,e){if(this.unloadTileData(t),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z})))}_update(){this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Pt=function(e,i,r,o){const n=new kt[i.type](e,i,r,o);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],n),n};function Dt(e,i){const r=t.identity([]);return t.scale(r,r,[.5*e.width,.5*-e.height,1]),t.translate(r,r,[1,-1,0]),t.multiply(r,r,e.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}function Lt(t,e,i,r,o,n,s,a=!1){const l=t.tilesIn(r,s,a);l.sort(Rt);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r,o,n,Dt(t.transform,r.tile.tileID),a)});const u=function(t){const e={},i={};for(const r of t){const t=r.queryResults,o=r.wrappedTileID,n=i[o]=i[o]||{};for(const i in t){const r=t[i],o=n[i]=n[i]||{},s=e[i]=e[i]||[];for(const t of r)o[t.featureIndex]||(o[t.featureIndex]=!0,s.push(t))}}return e}(c);for(const e in u)u[e].forEach((e=>{const i=e.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?t.getFeatureState(r["source-layer"],i.id):{})}));return u}function Bt(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],o={};for(let t=0;t{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Ot]}numActive(){return Object.keys(this.active).length}}let Vt;function jt(){return Vt||(Vt=new Ut),Vt}function Nt(e,i){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(r[t]=i[t])})),r}function Gt(t){t=t.slice();const e=Object.create(null);for(let i=0;i0?(o-s)/a:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}class Qt{constructor(t,e,i){const r=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||r<0||e>this.height)return!o&&[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(o)return!0;for(let t=0;t0:s}_queryCircle(t,e,i,r,o){const n=t-i,s=t+i,a=e-i,l=e+i;if(s<0||n>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(n,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},o),r?c.length>0:c}query(t,e,i,r,o){return this._query(t,e,i,r,!1,o)}hitTest(t,e,i,r,o){return this._query(t,e,i,r,!0,o)}hitTestCircle(t,e,i,r){return this._queryCircle(t,e,i,!0,r)}_queryCell(t,e,i,r,o,n,s,a){const l=s.seenUids,c=this.boxCells[o];if(null!==c){const o=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(t<=o[c+2]&&e<=o[c+3]&&i>=o[c+0]&&r>=o[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[u],x1:o[c],y1:o[c+1],x2:o[c+2],y2:o[c+3]})}}}const u=this.circleCells[o];if(null!==u){const o=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(o[u],o[u+1],o[u+2],t,e,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return n.push(!0),!0;{const t=o[u],e=o[u+1],i=o[u+2];n.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,r,o,n,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[o];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return n.push(!0),!0}}const h=this.circleCells[o];if(null!==h){const t=this.circles;for(const e of h)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return n.push(!0),!0}}}_forEachCell(t,e,i,r,o,n,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(o.call(this,t,e,i,r,this.xCellCount*l+p,n,s,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,o,n){const s=r-t,a=o-e,l=i+n;return l*l>s*s+a*a}_circleAndRectCollide(t,e,i,r,o,n,s){const a=(n-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;const c=(s-o)/2,u=Math.abs(e-(o+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=i*i}}const te=Math.tan(85*Math.PI/180);function ee(e,i,r,o,n,s,a){const l=t.create();if(r)if("globe"===s.name){const e=t.calculateGlobeLabelMatrix(n,i);t.multiply(l,l,e)}else{const e=y([],a);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3],o||t.rotateZ(l,l,n.angle)}else t.multiply(l,n.labelPlaneMatrix,e);return l}function ie(t,e,i,r,o,n,s){const a=ee(t,e,i,r,o,n,s);return"globe"===n.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function re(e,i,r,o,n,s,a){if(r){if("globe"===s.name){const l=ee(e,i,r,o,n,s,a);return t.invert(l,l),t.multiply(l,e,l),l}{const i=t.clone(e),r=t.identity([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],t.multiply(i,i,r),o||t.rotateZ(i,i,-n.angle),i}}return n.glCoordMatrix}function oe(e,i,r=0){const o=[e.x,e.y,r,1];r?t.transformMat4$1(o,o,i):ge(o,o,i);const n=o[3];return{point:[o[0]/n,o[1]/n,o[2]/n],signedDistanceFromCamera:n}}function ne(e,i){const r=[e[0],e[1],e[2],1];t.transformMat4$1(r,r,i);const o=r[3];return{point:[r[0]/o,r[1]/o,r[2]/o],signedDistanceFromCamera:o}}function se(t,e){return Math.min(.5+t/e*.5,1.5)}function ae(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function le(e,i,r,o,n,s,a,l,c,u){const h=r.transform,p=o?e.textSizeData:e.iconSizeData,d=t.evaluateSizeForZoom(p,r.transform.zoom),f="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=o?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=o?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const y=e.lineVertexArray,x=o?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b=!1;for(let o=0;oMath.abs(r.x-i.x)*o?{useVertical:!0}:e.writingMode===t.WritingMode.vertical?i.yte}(i,r,o)?1===e.flipState?{needsFlipping:!0}:null:i.x>r.x?{needsFlipping:!0}:null}function he(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y,x){const v=i/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v;let T;if(e.numGlyphs>1){const i=e.glyphStartIndex+e.numGlyphs,n=e.lineStartIndex,u=e.lineStartIndex+e.lineLength,h=ce(v,l,b,w,r,p,d,e,c,s,f,_,!1,g,y,x);if(!h)return{notEnoughRoom:!0};const E=ne(h.first.point,a).point,S=ne(h.last.point,a).point,C=new t.pointGeometry(E[0],E[1]),M=new t.pointGeometry(S[0],S[1]);if(o&&!r){const t=ue(e,C,M,m);if(e.flipState=t&&t.needsFlipping?1:2,t)return t}T=[h.first];for(let t=e.glyphStartIndex+1;t0?s.point:de(d,o,i,1,n,void 0,g,y.canonical),l=ue(e,new t.pointGeometry(i[0],i[1]),new t.pointGeometry(a[0],a[1]),m);if(e.flipState=l&&l.needsFlipping?1:2,l)return l}const i=fe(v*l.getoffsetX(e.glyphStartIndex),b,w,r,p,d,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,s,f,_,!1,!1,g,y,x);if(!i)return{notEnoughRoom:!0};T=[i]}if(h)for(const e of T)t.updateGlobeVertexNormal(h,u.length+0,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+1,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+2,e.up[0],e.up[1],e.up[2]),t.updateGlobeVertexNormal(h,u.length+3,e.up[0],e.up[1],e.up[2]),t.addDynamicAttributes(u,e.point[0],e.point[1],e.point[2],e.angle);else for(const e of T)t.addDynamicAttributes(u,e.point[0],e.point[1],e.point[2],e.angle);return{}}function pe(e,i,r,o,n){const s=o.projectTilePoint(e.x,e.y,i);if(!n)return oe(s,r,s.z);const a=n(e);return oe(new t.pointGeometry(s.x+a[0],s.y+a[1]),r,s.z+a[2])}function de(e,i,r,o,n,s,a,l){const c=pe(e.add(e.sub(i)._unit()),l,n,a,s).point,u=t.sub([],r,c);return t.scaleAndAdd([],r,u,o/t.length(u))}function fe(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g,y){const x=o?e-i:e+i;let v=x>0?1:-1,b=0;o&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=v>0?l+a:l+a+1,T=n,E=n,S=0,C=0;const M=Math.abs(x),A=[],I=[];let z=s;const k=()=>{const e=w-v;return 0===S?s:new t.pointGeometry(u.getx(e),u.gety(e))},P=()=>de(k(),z,E,M-S+1,h,d,_,g.canonical);for(;S+C<=M;){if(w+=v,w=c)return null;if(E=T,A.push(T),f&&I.push(z||k()),T=p[w],void 0===T){z=new t.pointGeometry(u.getx(w),u.gety(w));const e=pe(z,g.canonical,h,_,d);T=e.signedDistanceFromCamera>0?p[w]=e.point:P()}else z=null;S+=C,C=t.distance(E,T)}z=z||new t.pointGeometry(u.getx(w),u.gety(w));const D=k();m&&d&&(p[w]=T=void 0===p[w]?T:P(),C=t.distance(E,T));const L=(M-S)/C,B=z.sub(D).mult(L)._add(D),R=t.sub([],T,E),F=t.scaleAndAdd([],E,R,L);let O=[0,0,1],U=R[0],V=R[1];if(y&&(O=_.upVector(g.canonical,B.x,B.y),0!==O[0]||0!==O[1]||1!==O[2])){const e=[1,0,0],i=[0,1,0];e[0]=O[2],e[1]=0,e[2]=-O[0],t.cross(i,O,e),t.normalize(e,e),t.normalize(i,i),U=t.dot(R,e),V=t.dot(R,i)}if(r){const e=t.cross([],O,R);t.normalize(e,e),t.scaleAndAdd(F,F,e,r*v)}const j=b+Math.atan2(V,U);return A.push(F),f&&I.push(B),{point:F,angle:j,path:A,tilePath:I,up:O}}const me=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _e(t,e){for(let i=0;i0,t.getProjection()),f=n*d.perspectiveRatio,m=(i.x1*e+r.x-i.padding)*f+d.point.x,_=(i.y1*e+r.y-i.padding)*f+d.point.y,g=(i.x2*e+r.x+i.padding)*f+d.point.x,y=(i.y2*e+r.y+i.padding)*f+d.point.y,x=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!o&&this.grid.hitTest(m,_,g,y,a)||x?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,e.getProjection()):t=>[0,0,0],x=new t.pointGeometry(r.tileAnchorX,r.tileAnchorY),v=e.getProjection().projectTilePoint(r.tileAnchorX,r.tileAnchorY,m.canonical),b=y(x),w=[v.x+b[0],v.y+b[1],v.z+b[2]],T="globe"===e.projection.name,E=this.projectAndGetPerspectiveRatio(a,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,e.getProjection()),{perspectiveRatio:S}=E,C=(h?s/S:s*S)/t.ONE_EM,M=oe(new t.pointGeometry(w[0],w[1]),l,w[2]).point,A=E.signedDistanceFromCamera>0?ce(C,n,r.lineOffsetX*C,r.lineOffsetY*C,!1,M,x,r,o,l,{},g&&!h?y:null,h&&!!g,e.getProjection(),m,h):null;let I=!1,z=!1,k=!0;if(A&&!E.occluded){const e=.5*d*S+f,r=new t.pointGeometry(-100,-100),o=new t.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new Jt,s=A.first,a=A.last;let l=[];for(let t=s.path.length-1;t>=1;t--)l.push(s.path[t]);for(let t=1;t{const i=y(ene(t,c));l=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let m=[];if(l.length>0){const e=l.map((e=>new t.pointGeometry(e[0],e[1])));let i=1/0,n=-1/0,s=1/0,a=-1/0;for(let t=0;t=r.x&&n<=o.x&&s>=r.y&&a<=o.y?[e]:no.x||ao.y?[]:t.clipLine([e],r.x,r.y,o.x,o.y)}for(const t of m){n.reset(t,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/h)+1;for(let t=0;t0){t.transformMat4$1(s,s,e);const o="globe"===n.name;this.fogState&&r&&!o&&(a=function(e,i,r,o,n,s){const a=s.calculateFogTileMatrix(n),l=[i,r,o];return t.transformMat4(l,l,a),M(e,l,s.pitch,s._fov)}(this.fogState,i[0],i[1],i[2],r.toUnwrapped(),this.transform)>.9)}else ge(s,s,e);return{point:new t.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+ye,(-s[1]/s[3]+1)/2*this.transform.height+ye),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(n)/s[3]*.5,1.5),signedDistanceFromCamera:s[3],occluded:o&&s[2]>s[3]||a}}isOffscreen(t,e,i,r){return i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t=0&&et.collisionGroupID===e}}return this.collisionGroups[t]}}function Ie(e,i,r,o,n){const{horizontalAlign:s,verticalAlign:a}=t.getAnchorAlignment(e),l=-(s-.5)*i,c=-(a-.5)*r,u=t.evaluateVariableOffset(e,o);return new t.pointGeometry(l+u[0]*n,c+u[1]*n)}function ze(e,i,r,o,n){const s=new t.pointGeometry(e,i);return r&&s._rotate(o?n:-n),s}class ke{constructor(t,e,i,r,o){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new xe(this.transform,o),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new Ae(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,r,o){const n=r.getBucket(i),s=r.latestFeatureIndex;if(!n||!s||i.id!==n.layerIds[0])return;const a=n.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(n.projection);const p=(d=r.tileID,f=n.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):ve(m,f,d));var d,f,m;const _="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),v=this.transform.calculatePixelsToTileUnitsMatrix(r),b=ie(p,r.tileID.canonical,_,g,this.transform,n.getProjection(),v);let w=null;if(_){const e=re(p,r.tileID.canonical,_,g,this.transform,n.getProjection(),v);w=t.multiply([],this.transform.labelPlaneMatrix,e)}let T=null;y&&r.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:x,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Me(n.bucketInstanceId,s,n.sourceLayerIndex,n.index,r.tileID);const E={bucket:n,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(o)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:o,parameters:E})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:E})}attemptAnchorPlacement(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_,g){const y=[h.textOffset0,h.textOffset1],x=Ie(t,i,r,y,o),v=this.collisionIndex.placeCollisionBox(d,o,e,ze(x.x,x.y,n,s,this.transform.angle),u,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,ze(x.x,x.y,n,s,this.transform.angle),u,a,l,c.predicate).box.length)&&v.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(e=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:i,height:r,anchor:t,textScale:o,prevAnchor:e},this.markUsedJustification(d,t,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(e,i,r,o){const{bucket:n,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=e.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(n.projection);let S=x&&(v||!n.hasIconData()||y),C=v&&(x||!n.hasTextData()||g);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),r&&o&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const M=(e,o,d)=>{if(u){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let o=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[n.bucketInstanceId];o=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(r,o,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new t.pointGeometry(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[e.crossTileID]=new Se(!1,!1,!1,!0),void(i[e.crossTileID]=!0)}if(i[e.crossTileID])return;if(p)return void(this.placements[e.crossTileID]=new Se(!1,!1,!1));let E=!1,M=!1,A=!0,I=!1,z=!1,k=null,P={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},L=null,B=null,R=null,F=0,O=0,U=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(O=d.verticalTextFeatureIndex);const V=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID,(this.transform.elevation||t.elevation)&&(t.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[n.bucketInstanceId].tileID,t.tileAnchorX,t.tileAnchorY):0)},j=d.textBox;if(j){V(j);const i=i=>{let r=t.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},r=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of n.writingModes)if(e===t.WritingMode.vertical?(P=r(),D=P):P=i(),P&&P.box&&P.box.length)break}else P=i()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];l.indexOf(t.anchor)>0&&(l=l.filter((e=>e!==t.anchor)),l.unshift(t.anchor))}const c=(t,i,r)=>{const s=n.getSymbolInstanceTextSize(f,e,this.transform.zoom,o),c=(t.x2-t.x1)*s+2*t.padding,u=(t.y2-t.y1)*s+2*t.padding,p=T&&!v?i:null;p&&V(p);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,e,o,n,r,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,k=g.shift;break}}return d};r((()=>c(j,d.iconBox,t.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return i&&V(i),n.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&e.numVerticalGlyphVertices>0&&i?c(i,d.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),P&&(E=P.box,A=P.offscreen,I=P.occluded);const u=i(P&&P.box);if(!E&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,u))}}else{const s=(i,r)=>{const s=n.getSymbolInstanceTextSize(f,e,this.transform.zoom,o),l=this.collisionIndex.placeCollisionBox(n,s,i,new t.pointGeometry(0,0),x,h,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(n,r,e),this.placedOrientations[e.crossTileID]=r),l};r((()=>s(j,t.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?(V(i),s(i,t.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(P&&P.box&&P.box.length)}}if(L=P,E=L&&L.box&&L.box.length>0,A=L&&L.offscreen,I=L&&L.occluded,e.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),o=t.evaluateSizeForFeature(n.textSizeData,f,i),u=s.get("text-padding");B=this.collisionIndex.placeCollisionCircles(n,x,i,n.lineVertexArray,n.glyphOffsetArray,o,a,l,c,r,w,_.predicate,e.collisionCircleDiameter*o/t.ONE_EM,u,this.retainedQueryData[n.bucketInstanceId].tileID),E=x||B.circles.length>0&&!B.collisionDetected,A=A&&B.offscreen,I=B.occluded}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>{V(e);const i=T&&k?ze(k.x,k.y,b,w,this.transform.angle):new t.pointGeometry(0,0),r=n.getSymbolInstanceIconSize(m,this.transform.zoom,o);return this.collisionIndex.placeCollisionBox(n,r,e,i,v,h,a,_.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(R=e(d.verticalIconBox),M=R.box.length>0):(R=e(d.iconBox),M=R.box.length>0),A=A&&R.offscreen,z=R.occluded}const N=g||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,G=y||0===e.numIconVertices;if(N||G?G?N||(M=M&&E):E=M&&E:M=E=M&&E,E&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,s.get("text-ignore-placement"),n.bucketInstanceId,D&&D.box&&O?O:F,_.ID),M&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),n.bucketInstanceId,U,_.ID),B&&(E&&this.collisionIndex.insertCollisionCircles(B.circles,s.get("text-ignore-placement"),n.bucketInstanceId,F,_.ID),r)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Ce);for(let t=0;t=0;--e){const i=t[e];M(n.symbolInstances.get(i),i,n.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=n>=0&&t!==n?0:r.crossTileID)}markUsedOrientation(e,i,r){const o=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,n=i===t.WritingMode.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=o;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,o=e?e.opacities:{},n=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],n=o[t];n?(this.opacities[t]=new Ee(n,r,e.text,e.icon,null,e.clipped),i=i||e.text!==n.text.placed||e.icon!==n.icon.placed):(this.opacities[t]=new Ee(null,r,e.text,e.icon,e.skipFade,e.clipped),i=i||e.text||e.icon)}for(const t in o){const e=o[t];if(!this.opacities[t]){const o=new Ee(e,r,!1,!1);o.isHidden()||(this.opacities[t]=o,i=i||e.text.placed||e.icon.placed)}}for(const t in n)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=n[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0].layout,n=!!e.layers[0].dynamicFilter(),s=new Ee(null,0,!1,!1,!0),a=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),c=o.get("text-variable-anchor"),u="map"===o.get("text-rotation-alignment"),h="map"===o.get("text-pitch-alignment"),p="none"!==o.get("icon-text-fit"),d=new Ee(null,0,a&&(l||!e.hasIconData()||o.get("icon-optional")),l&&(a||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const f=(t,e,i)=>{for(let r=0;r0||l>0,x=o.numIconVertices>0,v=this.placedOrientations[o.crossTileID],b=v===t.WritingMode.vertical,w=v===t.WritingMode.horizontal||v===t.WritingMode.horizontalOnly;if(!y&&!x||g.isHidden()||m++,y){const t=Ve(g.text);f(e.text,a,b?je:t),f(e.text,l,w?je:t);const i=g.text.isHidden();[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||b?1:0)})),o.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const r=this.variableOffsets[o.crossTileID];r&&this.markUsedJustification(e,r.anchor,o,v);const n=this.placedOrientations[o.crossTileID];n&&(this.markUsedJustification(e,"left",o,n),this.markUsedOrientation(e,n,o))}if(x){const t=Ve(g.icon);o.placedIconSymbolIndex>=0&&(f(e.icon,o.numIconVertices,b?je:t),e.icon.placedSymbolArray.get(o.placedIconSymbolIndex).hidden=g.icon.isHidden()),o.verticalPlacedIconSymbolIndex>=0&&(f(e.icon,o.numVerticalIconVertices,w?je:t),e.icon.placedSymbolArray.get(o.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[r];if(i){let r=new t.pointGeometry(0,0),o=!0;if(i.textBox||i.verticalTextBox){if(c){const t=this.variableOffsets[_];t?(r=Ie(t.anchor,t.width,t.height,t.textOffset,t.textScale),u&&r._rotate(h?this.transform.angle:-this.transform.angle)):o=!1}n&&(o=!g.clipped),i.textBox&&Pe(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||b,r.x,r.y),i.verticalTextBox&&Pe(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||w,r.x,r.y)}const s=o&&Boolean(!w&&i.verticalIconBox);i.iconBox&&Pe(e.iconCollisionBox.collisionVertexArray,g.icon.placed,s,p?r.x:0,p?r.y:0),i.verticalIconBox&&Pe(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,p?r.x:0,p?r.y:0)}}}if(e.fullyClipped=0===m,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Pe(t,e,i,r,o){t.emplaceBack(e?1:0,i?1:0,r||0,o||0),t.emplaceBack(e?1:0,i?1:0,r||0,o||0),t.emplaceBack(e?1:0,i?1:0,r||0,o||0),t.emplaceBack(e?1:0,i?1:0,r||0,o||0)}const De=Math.pow(2,25),Le=Math.pow(2,24),Be=Math.pow(2,17),Re=Math.pow(2,16),Fe=Math.pow(2,9),Oe=Math.pow(2,8),Ue=Math.pow(2,1);function Ve(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*De+e*Le+i*Be+e*Re+i*Fe+e*Oe+i*Ue+e}const je=0;class Ne{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,o){const n=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex{const e=t.exported.now()-o;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=o)&&(!t.maxzoom||t.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new Ne(t)),this._inProgressLayer.continuePlacement(r[t.source],this.placement,this._showCollisionBoxes,t,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Ze=512/t.EXTENT/2;class $e{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;it.overscaledZ)for(const i in o){const n=o[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{const n=o[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const He=(e,i)=>t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),Ye=t.pick(Zt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Ke=t.pick(Zt,["setCenter","setZoom","setBearing","setPitch"]),Je={version:8,layers:[],sources:{}},Qe={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class ti extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new P(jt(),this),this.imageManager=new v,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(e._requestManager,i.localFontFamily?t.LocalGlyphMode.all:i.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new t.LineAtlas(256,512),this.crossTileSymbolIndex=new We,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const r=this;this._rtlTextPluginCallback=ti.registerForPluginStateChange((e=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in r._sourceCaches){const e=r._sourceCaches[t],i=e.getSource().type;"vector"!==i&&"geojson"!==i||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,i.accessToken);const o=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(o,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,r)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Je,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(e,i){if(i&&He(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=t.clone$1(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const r=Gt(this.stylesheet.layers);this._order=r.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let e of r)e=t.createStyleLayer(e),e.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=e,this._serializedLayers[e.id]=e.serialize(),this._updateLayerCount(e,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_loadSprite(e){this._spriteRequest=function(e,i,r){let o,n,s;const a=t.exported.devicePixelRatio>1?"@2x":"";let l=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,a,".json"),t.ResourceType.SpriteJSON),((t,e)=>{l=null,s||(s=t,o=e,u())})),c=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,a,".png"),t.ResourceType.SpriteImage),((t,e)=>{c=null,s||(s=t,n=e,u())}));function u(){if(s)r(s);else if(o&&n){const e=t.exported.getImageData(n),i={};for(const r in o){const{width:n,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=o[r],f=new t.RGBAImage({width:n,height:s});t.RGBAImage.copy(e,f,{x:a,y:l},{x:0,y:0},{width:n,height:s}),i[r]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.getSource(e.source);if(!i)return;const r=e.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&Qe[t.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const r=this.map.painter;if(r){const t=i.getProgramIds();if(!t)continue;const o=i.getProgramConfiguration(e.zoom);for(const e of t)r.useProgram(e,o)}}for(const e in r){const i=this._sourceCaches[e];r[e]!==i.used&&i.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(i){if(this._checkLoaded(),He(this,t.validateStyle(i)))return!1;(i=t.clone$1(i)).layers=Gt(i.layers);const r=function(t,i){if(!t)return[{command:Zt.setStyle,args:[i]}];let r=[];try{if(!e(t.version,i.version))return[{command:Zt.setStyle,args:[i]}];e(t.center,i.center)||r.push({command:Zt.setCenter,args:[i.center]}),e(t.zoom,i.zoom)||r.push({command:Zt.setZoom,args:[i.zoom]}),e(t.bearing,i.bearing)||r.push({command:Zt.setBearing,args:[i.bearing]}),e(t.pitch,i.pitch)||r.push({command:Zt.setPitch,args:[i.pitch]}),e(t.sprite,i.sprite)||r.push({command:Zt.setSprite,args:[i.sprite]}),e(t.glyphs,i.glyphs)||r.push({command:Zt.setGlyphs,args:[i.glyphs]}),e(t.transition,i.transition)||r.push({command:Zt.setTransition,args:[i.transition]}),e(t.light,i.light)||r.push({command:Zt.setLight,args:[i.light]}),e(t.fog,i.fog)||r.push({command:Zt.setFog,args:[i.fog]}),e(t.projection,i.projection)||r.push({command:Zt.setProjection,args:[i.projection]});const o={},n=[];!function(t,i,r,o){let n;for(n in i=i||{},t=t||{})t.hasOwnProperty(n)&&(i.hasOwnProperty(n)||qt(n,r,o));for(n in i)i.hasOwnProperty(n)&&(t.hasOwnProperty(n)?e(t[n],i[n])||("geojson"===t[n].type&&"geojson"===i[n].type&&Wt(t,i,n)?r.push({command:Zt.setGeoJSONSourceData,args:[n,i[n].data]}):Xt(n,i,r,o)):$t(n,i,r))}(t.sources,i.sources,n,o);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&o[t.source]?r.push({command:Zt.removeLayer,args:[t.id]}):s.push(t)}));let a=t.terrain;a&&o[a.source]&&(r.push({command:Zt.setTerrain,args:[void 0]}),a=void 0),r=r.concat(n),e(a,i.terrain)||r.push({command:Zt.setTerrain,args:[i.terrain]}),function(t,i,r){i=i||[];const o=(t=t||[]).map(Yt),n=i.map(Yt),s=t.reduce(Kt,{}),a=i.reduce(Kt,{}),l=o.slice(),c=Object.create(null);let u,h,p,d,f,m,_;for(u=0,h=0;u!(t.command in Ke)));if(0===r.length)return!1;const o=r.filter((t=>!(t.command in Ye)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((t=>t.command)).join(", ")}.`);return r.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=i,this._updateMapProjection(),!0}addImage(e,i){return this.getImage(e)?this.fire(new t.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,i),this._afterImageUpdated(e),this)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new t.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateSource,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const o=Pt(e,i,this.dispatcher,this);o.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:o.serialize(),sourceId:e})));const n=i=>{const r=(i?"symbol:":"other:")+e,n=this._sourceCaches[r]=new t.SourceCache(r,o,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[e]=n,n.style=this,n.onAdd(this.map)};n(!1),"vector"!==i.type&&"geojson"!==i.type||n(!0),o.onAdd&&o.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const i=this.getSource(e);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(e);for(const e of r)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}addLayer(e,i,r={}){this._checkLoaded();const o=e.id;if(this.getLayer(o))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${o}" already exists on this map`)));let n;if("custom"===e.type){if(He(this,t.validateCustomStyleLayer(e)))return;n=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(o,e.source),e=t.clone$1(e),e=t.extend(e,{source:o})),this._validate(t.validateLayer,`layers.${o}`,e,{arrayIndex:-1},r))return;n=t.createStyleLayer(e),this._validateLayer(n),n.setEventedParent(this,{layer:{id:o}}),this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=n;const a=this._getLayerSourceCache(n);if(this._removedLayers[o]&&n.source&&a&&"custom"!==n.type){const t=this._removedLayers[o];delete this._removedLayers[o],t.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",a.pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const o=i?this._order.indexOf(i):this._order.length;i&&-1===o?this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(o,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(e,i,r){this._checkLoaded();const o=this.getLayer(e);o?o.minzoom===i&&o.maxzoom===r||(null!=i&&(o.minzoom=i),null!=r&&(o.maxzoom=r),this._updateLayer(o)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,r,o={}){this._checkLoaded();const n=this.getLayer(i);if(n){if(!e(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(t.validateFilter,`layers.${n.id}.filter`,r,{layerType:n.type},o)||(n.filter=t.clone$1(r),this._updateLayer(n)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const i=this.getLayer(e);return i&&t.clone$1(i.filter)}setLayoutProperty(i,r,o,n={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getLayoutProperty(r),o)||(s.setLayoutProperty(r,o,n),this._updateLayer(s)):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(i,r,o,n={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getPaintProperty(r),o)||(s.setPaintProperty(r,o,n)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){const i=this.getLayer(t);return i&&i.getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const r=e.source,o=e.sourceLayer,n=this.getSource(r);if(!n)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const s=n.type;if("geojson"===s&&o)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!o)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(r);for(const t of a)t.setFeatureState(o,e.id,i)}removeFeatureState(e,i){this._checkLoaded();const r=e.source,o=this.getSource(r);if(!o)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const n=o.type,s="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(r);for(const t of a)t.removeFeatureState(s,e.id,i)}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,o=this.getSource(i);if(o){if("vector"!==o.type||r)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(r,e.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:e,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let o=this._order.length-1;o>=0;o--){const n=this._order[o];if(e(n)){i[n]=o;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const o=[];for(let n=this._order.length-1;n>=0;n--){const s=this._order[n];if(e(s))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),a=L.createFromScreenPoints(e,r);for(const t in this._sourceCaches){const e=this._sourceCaches[t].getSource().id;i.layers&&!o[e]||n.push(Lt(this._sourceCaches[t],this._layers,this._serializedLayers,a,i,r,s,!!this.map._showQueryGeometry))}return this.placement&&n.push(function(t,e,i,r,o,n,s){const a={},l=n.queryRenderedSymbols(r),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(Rt);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,o.filter,o.layers,o.availableImages,t);for(const t in r){const e=a[t]=a[t]||[],o=r[t];o.sort(((t,e)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of o)e.push(t)}}for(const e in a)a[e].forEach((r=>{const o=r.feature,n=i(t[e]).getFeatureState(o.layer["source-layer"],o.id);o.source=o.layer.source,o.layer["source-layer"]&&(o.sourceLayer=o.layer["source-layer"]),o.state=n}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateFilter,"querySourceFeatures.filter",i.filter,null,i);const r=this._getSourceCaches(e);let o=[];for(const t of r)o=o.concat(Bt(t,i));return o}addSourceType(t,e,i){return ti.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(ti.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const i in t)if(!e(t[i],r[i])){o=!0;break}if(!o)return;const n=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(t,i),this.light.updateTransitions(n)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,r=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===r){if("object"==typeof i.source){const e="terrain-dem-src";this.addSource(e,i.source),i=t.clone$1(i),i=t.extend(i,{source:e})}if(this._validate(t.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode)this._createTerrain(i,r);else{const r=this.terrain,o=r.get();for(const e of Object.keys(t.spec.terrain))!i.hasOwnProperty(e)&&t.spec.terrain[e].default&&(i[e]=t.spec.terrain[e].default);for(const t in i)if(!e(i[t],o[t])){r.set(i),this.stylesheet.terrain=i;const t=this._setTransitionParameters({duration:0});r.updateTransitions(t);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new k(t,this.map.transform);this.stylesheet.fog=t;const i=this._setTransitionParameters({duration:0});e.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,r=i.get();0===Object.keys(t).length&&i.set(t);for(const o in t)if(!e(t[o],r[o])){i.set(t),this.stylesheet.fog=t;const e=this._setTransitionParameters({duration:0});i.updateTransitions(e);break}}else this._createFog(t);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:t.exported.now(),transition:t.extend(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const i=this.terrain=new C(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(e,i,r,o,n={}){return(!n||!1!==n.validate)&&He(this,e.call(t.validateStyle,t.extend({key:i,style:this.serialize(),value:r,styleSpec:t.spec},o)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(e,i,r,o,n=!1){let s=!1,a=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng,e.projection);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n=n||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new Ge(e,this._order,n,i,r,o,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};r(this._otherSourceCaches[e.source]),r(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,r){return t.makeRequest(i,r)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(e){const i=this._getSourceCaches(e);return 0===i.length?(this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):i.every((t=>t.loaded()))}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}ti.getSourceType=function(t){return kt[t]},ti.setSourceType=function(t,e){kt[t]=e},ti.registerForPluginStateChange=t.registerForPluginStateChange;var ei="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",ii="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let ri={},oi={};ri=ci("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),oi=ci("#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const ni=ci("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),si=ei,ai="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var li={background:ci("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:ci("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:ci("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:ci("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ci("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:ci("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:ci("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ci("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ci("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:ci("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:ci("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:ci("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:ci("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:ci("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ci("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:ci("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:ci("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:ci("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:ci("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:ci("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:ci("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:ci("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:ci("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxGradient:ci("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",ii),skyboxCapture:ci("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:ci("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector.xyz*height;vec4 globe=u_globe_matrix*vec4(globe_pos,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:ci("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function ci(t,e,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,n=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=t.match(o),a=e.match(o),l=ei.match(o);let c=a?a.concat(s):s;i||(ri.staticUniforms&&(c=ri.staticUniforms.concat(c)),oi.staticUniforms&&(c=oi.staticUniforms.concat(c))),c&&(c=c.concat(l));const u={};return{fragmentSource:t=t.replace(r,((t,e,i,r,o)=>(u[o]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`))),vertexSource:e=e.replace(r,((t,e,i,r,o)=>{const n="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":n;return u[o]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${n} a_${o};\nvarying ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${n} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`})),staticAttributes:n,staticUniforms:c}}class ui{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,o,n,s,a,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t{const o=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:hi(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:o,u_highlight:n,u_accent:s}})(e,r,o,e.terrain?i.projMatrix:null);e.prepareDrawProgram(l,h,i.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(r);h.draw(l,c.TRIANGLES,n,s,a,t.CullFaceMode.disabled,p,o.id,d,f,m)}function di(e,i,r){if(!i.needsDEMTextureUpload)return;const o=e.context,n=o.gl;o.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new t.Texture(o,s,n.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function fi(e,i,r,o,n,s){const a=e.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),di(e,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=i.fbo;if(!h){const e=new t.Texture(a,{width:u,height:u,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=i.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(e.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,o,n,s,t.CullFaceMode.disabled,((e,i)=>{const r=i.stride,o=t.create();return t.ortho(o,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(o,o,[0,-t.EXTENT,0]),{u_matrix:o,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),r.id,p,d,f),i.needsHillshadePrepare=!1}const mi=(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image0:new t.Uniform1i(e,i.u_image0),u_skirt_height:new t.Uniform1f(e,i.u_skirt_height)}),_i=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),gi=(t,e,i,r,o,n,s,a,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:o,u_merc_center:n,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function yi(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const xi=new class{constructor(){this.operations={}}newMorphing(t,e,i,r,o){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:r,phase:0,duration:o,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},vi={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bi(t,e){const i=1<({u_matrix:t});function Ti(e,i,r,o,n){if(n>0){const s=t.exported.now(),a=(s-e.timeAdded)/n,l=i?(s-i.timeAdded)/n:-1,c=r.getSource(),u=o.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),p=h&&e.refreshedUponExpiration?1:t.clamp(h?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Ei extends t.SourceCache{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new P(jt(),null),r=Pt("mock-dem",e,i,t.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class Si extends t.SourceCache{constructor(t){const e=Pt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new P(jt(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,i,r){if(e.freezeTileCoverage)return;this.transform=e;const o=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){const i=new t.Tile(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom);i.state="loaded",this._tiles[r.key]=i}return i}),{});for(const t in this._tiles)t in o||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ci extends t.OverscaledTileID{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class Mi extends t.Elevation{constructor(e,i){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,o,n]=function(e){const i=new t.StructArrayLayout4i8,r=new t.StructArrayLayout3ui6,o=131;i.reserve(17161),r.reserve(33800);const n=t.EXTENT/128,s=t.EXTENT+n/2,a=s+n;for(let e=-n;es||e<0||e>s?24575:0,n=t.clamp(Math.round(r),0,t.EXTENT),a=t.clamp(Math.round(e),0,t.EXTENT);i.emplaceBack(n+o,a,n,a)}const l=(t,e)=>{const i=e*o+t;r.emplaceBack(i+1,i,i+o),r.emplaceBack(i+o,i+o+1,i+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)l(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)l(e,t),l(t,e)})),[i,r,32768]}(),s=e.context;this.gridBuffer=s.createVertexBuffer(r,t.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(o),this.gridSegments=t.SegmentVector.simpleSegment(0,0,r.length,o.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,r.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Si(i.map),this.orthoMatrix=t.create(),t.ortho(this.orthoMatrix,0,t.EXTENT,0,t.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new t.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ei(i.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency()}update(e,i,r){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const o=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(o.get("source")),this._exaggeration=o.get("exaggeration");const n=()=>{this.sourceCache.used&&t.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(i,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,n(),this._initializing=!0),n(),i.updateElevation(!r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&t.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const o=this.proxyCoords=i.getIds().map((t=>{const e=i.getTileByID(t).tileID;return e.projMatrix=r.calculateProjMatrix(e.toUnwrapped()),e}));!function(e,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),o=new t.pointGeometry(r.x,r.y);e.sort(((e,i)=>{if(i.overscaledZ-e.overscaledZ)return i.overscaledZ-e.overscaledZ;const r=new t.pointGeometry(e.canonical.x+(1<{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const t in s){const i=s[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],n),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=o.map((t=>new Ci(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(o),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],o=r.dem;!o||r.demTexture&&!r.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),di(this.painter,r,o))}}_prepareDemTileUniforms(t,e,i,r){if(!e||null==e.demTexture)return!1;const o=t.tileID.canonical,n=Math.pow(2,e.tileID.canonical.z-o.z),s=r||"";return i[`u_dem_tl${s}`]=[o.x*n%1,o.y*n%1],i[`u_dem_scale${s}`]=n,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,i=e.gl;if(!this._emptyDepthBufferTexture){const r=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(e,r,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const r=i.dem.tree.minimums[0];return r>0&&t++,e+r}),0);return t?e/t:0}_updateEmptyDEMTexture(){const e=this.painter.context,i=e.gl;e.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),o=new t.RGBAImage({width:1,height:1},new Uint8Array(t.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(o,{premultiply:!1}):n=this._emptyDEMTexture=new t.Texture(e,o,i.RGBA,{premultiply:!1}),n}setupElevationDraw(e,i,r){const o=this.painter.context,n=o.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(a),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection,u=e.tileID.canonical;s.u_tile_tl_up=c.upVector(u,0,0),s.u_tile_tr_up=c.upVector(u,t.EXTENT,0),s.u_tile_br_up=c.upVector(u,t.EXTENT,t.EXTENT),s.u_tile_bl_up=c.upVector(u,0,t.EXTENT),s.u_tile_up_scale=r&&r.useDenormalizedUpVectorScale?t.GLOBE_METERS_TO_ECEF:c.upVectorScale(u,l.center.lat,l.worldSize).metersToTile;let h=null,p=null,d=1;if(r&&r.morphing&&this._useVertexMorphing){const t=r.morphing.srcDemTile,i=r.morphing.dstDemTile;d=r.morphing.phase,t&&i&&(this._prepareDemTileUniforms(e,t,s,"_prev")&&(p=t),this._prepareDemTileUniforms(e,i,s)&&(h=i))}if(p&&h?(o.activeTexture.set(n.TEXTURE2),h.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),o.activeTexture.set(n.TEXTURE4),p.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE,n.NEAREST),s.u_dem_lerp=d):(h=this.terrainTileForTile[e.tileID.key],o.activeTexture.set(n.TEXTURE2),(this._prepareDemTileUniforms(e,h,s)?h.demTexture:this.emptyDEMTexture).bind(n.NEAREST,n.CLAMP_TO_EDGE)),o.activeTexture.set(n.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&h){const e=(1<{if(c===t)return;const r=[vi[t],"PROJECTION_GLOBE_VIEW"];p&&r.push("CUSTOM_ANTIALIASING"),i&&r.push(vi[u]),l=e.useProgram("globeRaster",null,r),c=t},f=e.colorModeForRenderPass(),m=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);xi.update(n);const _=t.calculateGlobeMercatorMatrix(h),g=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],y=e.globeSharedBuffers,x=[h.width*t.exported.devicePixelRatio,h.height*t.exported.devicePixelRatio];if((u?[!1,!0]:[!1]).forEach((u=>{c=-1;const p=u?a.LINES:a.TRIANGLES;for(const c of o){const o=r.getTile(c),v=t.StencilMode.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];yi(b,w)&&xi.newMorphing(c.key,b,w,n,250),s.activeTexture.set(a.TEXTURE0),o.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=xi.getMorphValuesForProxy(c.key),E=T?1:0,S={useDenormalizedUpVectorScale:!0};T&&t.extend$1(S,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:t.easeCubicInOut(T.phase)}});const C=Float32Array.from(h.globeMatrix),M=t.globeTileLatLngCorners(c.canonical),A=t.getLatitudinalLod((M[0][0]+M[1][0])/2),I=t.getGridMatrix(c.canonical,M,A),z=t.globeNormalizeECEF(t.globeTileBounds(c.canonical)),k=gi(h.projMatrix,C,_,z,t.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,I);if(d(E,u),i.setupElevationDraw(o,l,S),e.prepareDrawProgram(s,l,c.toUnwrapped()),y){const[i,r,o]=u?y.getWirefameBuffers(e.context,A):y.getGridBuffers(A);l.draw(s,p,m,v,f,t.CullFaceMode.backCCW,k,"globe_raster",i,r,o)}}})),y){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),l=e.useProgram("globeRaster",null,n);for(const n of o){const{x:o,y:c,z:u}=n.canonical,p=0===c,d=c===(1<e.draw(s,a.TRIANGLES,m,t.StencilMode.disabled,f,t.CullFaceMode.disabled,gi(h.projMatrix,y,y,T,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,{}),e.prepareDrawProgram(s,l,n.toUnwrapped()),p&&E(l,_),d&&(y=t.scale(t.create(),y,[1,-1,1]),E(l,v))}}}}(e,i,r,o,n);else{const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=(t,i)=>{if(c===t)return;const r=[vi[t]];i&&r.push(vi[u]),l=e.useProgram("terrainRaster",null,r),c=t},p=e.colorModeForRenderPass(),d=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);xi.update(n);const f=e.transform,m=6*Math.pow(1.5,22-f.zoom)*i.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const _=u?a.LINES:a.TRIANGLES,[g,y]=u?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of o){const o=r.getTile(c),x=t.StencilMode.disabled,v=i.prevTerrainTileForTile[c.key],b=i.terrainTileForTile[c.key];yi(v,b)&&xi.newMorphing(c.key,v,b,n,250),s.activeTexture.set(a.TEXTURE0),o.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=xi.getMorphValuesForProxy(c.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:t.easeCubicInOut(w.phase)}});const S=_i(c.projMatrix,bi(c.canonical,f.renderWorldCopies)?m/10:m);h(T,u),i.setupElevationDraw(o,l,E),e.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,_,d,x,p,t.CullFaceMode.backCCW,S,"terrain_raster",i.gridBuffer,g,y)}}))}}(i,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,o=this.proxySourceCache,n=this.proxiedCoords[o.id],s=this._drapedRenderBatches.shift(),a=[],l=i.style.order;let c=0;for(const u of n){const n=o.getTileByID(u.proxyTileKey),h=o.proxyCachedFBO[u.key]?o.proxyCachedFBO[u.key][e]:void 0,p=void 0!==h?o.renderCache[h]:this.pool[c++],d=void 0!==h;if(n.texture=p.tex,d&&!p.dirty){a.push(n.tileID);continue}let f;r.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(r.clear({color:t.Color.transparent,stencil:0}),p.dirty=!1);for(let t=s.start;t<=s.end;++t){const e=i.style._layers[l[t]];if(e.isHidden(i.transform.zoom))continue;const o=i.style._getLayerSourceCache(e),n=o?this.proxyToSource[u.key][o.id]:[u];if(!n)continue;const s=n;r.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(o?o.id:null)&&(this._setupStencil(p,n,e,o),f=o?o.id:null),i.renderLayer(i,o,e,s)}this.renderedToTile?(p.dirty=!0,a.push(n.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,r=0,o=0,n=!1;for(let s=0;st.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((t=>t.dem)).map((r=>{const o=r.tileID,n=Math.pow(2,o.overscaledZ),{x:s,y:a}=o.canonical,l=s/n,c=(s+1)/n,u=a/n,h=(a+1)/n;return{minx:l,miny:u,maxx:c,maxy:h,t:r.dem.tree.raycastRoot(l,u,c,h,t,e,i),tile:r}}));r.sort(((t,e)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.t:Number.MAX_VALUE)));for(const o of r){if(null==o.t)return null;const r=o.tile.dem.tree.raycast(o.minx,o.miny,o.maxx,o.maxy,t,e,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,i=e.gl,r=this.drapeBufferSize;e.activeTexture.set(i.TEXTURE0);const o=new t.Texture(e,{width:r[0],height:r[1],data:null},i.RGBA);o.bind(i.LINEAR,i.CLAMP_TO_EDGE);const n=e.createFramebuffer(r[0],r[1],!1);return n.colorAttachment.set(o.texture),n.depthAttachment=new Et(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:o,dirty:!1}}_initFBOPool(){for(;this.pool.length{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom),r=e.getCrossfadeParameters(),o=!!r&&1!==r.t,n=e.hasTransition();return"custom"!==e.type&&!i&&(o||n)}))}_clearRasterFadeFromRenderCache(){let t=!1;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e]._source instanceof Mt){t=!0;break}if(t)for(let t=0;te.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i=0;o--){const n=i[o];if(e.getTileByID(n.key),void 0!==e.proxyCachedFBO[n.key]){const i=t[n.key],o=this.proxyToSource[n.key];let s=0;for(const t in o){const e=o[t],n=i[t];if(!n||n.length!==e.length||e.some(((e,i)=>e!==n[i]||r[t]&&r[t].hasOwnProperty(e.key)))){s=-1;break}++s}for(const t in e.proxyCachedFBO[n.key])e.renderCache[e.proxyCachedFBO[n.key][t]].dirty=s<0||s!==Object.values(i).length}}const o=[...this._drapedRenderBatches];o.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of o)for(const r of i){if(e.proxyCachedFBO[r.key])continue;let i=e.renderCachePool.pop();void 0===i&&e.renderCache.length<50&&(i=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==i&&(e.proxyCachedFBO[r.key]={},e.proxyCachedFBO[r.key][t.start]=i,e.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const o=this.painter.context,n=o.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=e.length,this._overlapStencilMode.test={func:n.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:n.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(o.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(e,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):t.StencilMode.disabled}_renderTileClippingMasks(e,i){const r=this.painter,o=this.painter.context,n=o.gl;r._tileClippingMaskIDs={},o.setColorMode(t.ColorMode.disabled),o.setDepthMode(t.DepthMode.disabled);const s=r.useProgram("clippingMask");for(const a of e){const e=r._tileClippingMaskIDs[a.key]=--i;s.draw(o,n.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,wi(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(e){const i=this.painter.transform;if(e.x<0||e.x>i.width||e.y<0||e.y>i.height)return null;const r=[e.x,e.y,1,1];t.transformMat4$1(r,r,i.pixelMatrixInverse),t.scale$1(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const o=i._camera.position,n=t.mercatorZfromAltitude(1,i.center.lat),s=[o[0],o[1],o[2]/n,0],a=t.subtract([],r.slice(0,3),s);t.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(t.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=n,s):null}drawDepth(){const e=this.painter,i=e.context,r=this.proxySourceCache,o=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===o&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=i.gl,r=i.createFramebuffer(o,n,!0);i.activeTexture.set(e.TEXTURE0);const s=new t.Texture(i,{width:o,height:n,data:null},e.RGBA);s.bind(e.NEAREST,e.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,o,n);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,o,n]),function(e,i,r,o){if("globe"===e.transform.projection.name)return;const n=e.context,s=n.gl;n.clear({depth:1});const a=e.useProgram("terrainDepth"),l=new t.DepthMode(s.LESS,t.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of o){const o=r.getTile(e),c=_i(e.projMatrix,0);i.setupElevationDraw(o,a),a.draw(n,s.TRIANGLES,l,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(e,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof zt)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;e(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,i)=>{const r=e.wrap+e.canonical.x/(1<s+l.max.x||o+na+l.max.y};for(let t=0;tt.key===i.tileID.key));if(t)return t}if(i.tileID.key!==e.key){const r=e.canonical.z-i.tileID.canonical.z;let n,s,a;o=t.create();const l=i.tileID.wrap-e.wrap<0?(n=t.EXTENT>>r,s=n*((i.tileID.canonical.x<=o){const r=e.canonical.z-o;i.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,i.transform.tileZoom),s=new t.OverscaledTileID(a,e.wrap,o,e.canonical.x>>r,e.canonical.y>>r)):0!==r&&(a=o,s=new t.OverscaledTileID(a,e.wrap,o,e.canonical.x>>r,e.canonical.y>>r))}s.key!==e.key&&(c.push(s.key),r=i.getTile(s))}const u=t=>{c.forEach((e=>{o[e]=t})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&u(r.tileID.key);const t=s.calculateScaledKey(a);if(r=i.getTileByID(t),r&&r.hasData())break;const e=o[t];if(null===e)break;void 0===e?c.push(t):r=i.getTileByID(e)}return u(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let i=0;const r=new t.StructArrayLayout2ui4,o=131;for(let t=1;t<129;t++){for(let e=1;e<129;e++)i=t*o+e,r.emplaceBack(i,i+1),r.emplaceBack(i,i+o),r.emplaceBack(i+1,i+o),128===t&&r.emplaceBack(i+o,i+o+1);r.emplaceBack(i+1,i+1+o)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function Ai(t){const e=[];for(let i=0;i`#define ${t}`)));const _=m.concat(e.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ai):ai,ai,si,ni.fragmentSource,oi.fragmentSource,r.fragmentSource).join("\n"),g=m.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",si,ni.vertexSource,oi.vertexSource,ri.vertexSource,r.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,_),a.compileShader(y),a.attachShader(this.program,y);const x=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(x,g),a.compileShader(x),a.attachShader(this.program,x),this.attributes={};const v={};this.numAttributes=u.length;for(let t=0;t({u_dem:new t.Uniform1i(e,i.u_dem),u_dem_prev:new t.Uniform1i(e,i.u_dem_prev),u_dem_unpack:new t.Uniform4f(e,i.u_dem_unpack),u_dem_tl:new t.Uniform2f(e,i.u_dem_tl),u_dem_scale:new t.Uniform1f(e,i.u_dem_scale),u_dem_tl_prev:new t.Uniform2f(e,i.u_dem_tl_prev),u_dem_scale_prev:new t.Uniform1f(e,i.u_dem_scale_prev),u_dem_size:new t.Uniform1f(e,i.u_dem_size),u_dem_lerp:new t.Uniform1f(e,i.u_dem_lerp),u_exaggeration:new t.Uniform1f(e,i.u_exaggeration),u_depth:new t.Uniform1i(e,i.u_depth),u_depth_size_inv:new t.Uniform2f(e,i.u_depth_size_inv),u_meter_to_dem:new t.Uniform1f(e,i.u_meter_to_dem),u_label_plane_matrix_inv:new t.UniformMatrix4f(e,i.u_label_plane_matrix_inv),u_tile_tl_up:new t.Uniform3f(e,i.u_tile_tl_up),u_tile_tr_up:new t.Uniform3f(e,i.u_tile_tr_up),u_tile_br_up:new t.Uniform3f(e,i.u_tile_br_up),u_tile_bl_up:new t.Uniform3f(e,i.u_tile_bl_up),u_tile_up_scale:new t.Uniform1f(e,i.u_tile_up_scale)}))(e,v)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((e,i)=>({u_fog_matrix:new t.UniformMatrix4f(e,i.u_fog_matrix),u_fog_range:new t.Uniform2f(e,i.u_fog_range),u_fog_color:new t.Uniform4f(e,i.u_fog_color),u_fog_horizon_blend:new t.Uniform1f(e,i.u_fog_horizon_blend),u_fog_temporal_offset:new t.Uniform1f(e,i.u_fog_temporal_offset),u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_globe_pos:new t.Uniform3f(e,i.u_globe_pos),u_globe_radius:new t.Uniform1f(e,i.u_globe_radius),u_globe_transition:new t.Uniform1f(e,i.u_globe_transition),u_is_globe:new t.Uniform1i(e,i.u_is_globe),u_viewport:new t.Uniform2f(e,i.u_viewport)}))(e,v))}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].location&&i[t].set(e[t])}}draw(t,e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_){const g=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(o),t.setCullFace(n);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(s[t]);d&&d.setUniforms(t,this.binderUniforms,h,{zoom:p});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[e];for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new ui)).bind(t,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f,m,_),g.drawElements(e,i.primitiveLength*y,g.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function zi(t,e,i){const r=1/D(i,1,e.transform.tileZoom),o=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,e.transform.tileZoom)/o,s=n*(i.tileID.canonical.x+i.tileID.wrap*o),a=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const ki=t.create(),Pi=(e,i,r,o,n,s,a,l,c)=>{const u=i.style.light,h=u.properties.get("position"),p=[h.x,h.y,h.z],d=t.create$1();"viewport"===u.properties.get("anchor")&&(t.fromRotation(d,-i.transform.angle),t.transformMat3(p,p,d));const f=u.properties.get("color"),m=i.transform,_={u_matrix:e,u_lightpos:p,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[f.r,f.g,f.b],u_vertical_gradient:+r,u_opacity:o,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ki,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===m.projection.name&&(_.u_tile_id=[n.canonical.x,n.canonical.y,1<{const p=Pi(e,i,r,o,n,l,c,u,h),d={u_height_factor:-Math.pow(2,n.overscaledZ)/a.tileSize/8};return t.extend(p,zi(s,i,a),d)},Li=t=>({u_matrix:t}),Bi=(e,i,r,o)=>t.extend(Li(e),zi(r,i,o)),Ri=(t,e)=>({u_matrix:t,u_world:e}),Fi=(e,i,r,o,n)=>t.extend(Bi(e,i,r,o),{u_world:n}),Oi=t.create(),Ui=(e,i,r,o,n,s)=>{const a=e.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const e=t.globePixelsToTileUnits(a.zoom,i.canonical)*a._projectionScaler;c=Float32Array.from([e,0,0,e])}else c=a.calculatePixelsToTileUnitsMatrix(r);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(i.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Oi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=o,u.u_merc_center=n,u.u_tile_id=[i.canonical.x,i.canonical.y,1<{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},ji=(e,i,r,o)=>{const n=t.EXTENT/r.tileSize;return{u_matrix:e,u_camera_to_center_distance:i.getCameraToCenterDistance(o),u_extrude_scale:[i.pixelsToGLUnits[0]/n,i.pixelsToGLUnits[1]/n]}},Ni=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),Gi=t.create(),Zi=(e,i,r,o,n,s,a)=>{const l=e.transform,c="globe"===l.projection.name,u=c?t.globePixelsToTileUnits(l.zoom,i.canonical)*l._projectionScaler:D(r,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Gi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=o,h.u_merc_center=n,h.u_tile_id=[i.canonical.x,i.canonical.y,1<{const l=t.transform,c=l.calculatePixelsToTileUnitsMatrix(e),u={u_matrix:Wi(t,e,i,o),u_pixels_to_tile_units:c,u_device_pixel_ratio:s,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:a};if(Hi(i)){const i=Xi(e,t.transform);u.u_texsize=e.lineAtlasTexture.size,u.u_scale=[i,r.fromScale,r.toScale],u.u_mix=r.t}return u},qi=(t,e,i,r,o,n)=>{const s=t.transform,a=Xi(e,s);return{u_matrix:Wi(t,e,i,o),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:n,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Xi(t,e){return 1/D(t,1,e.tileZoom)}function Wi(t,e,i,r){return t.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function Hi(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const Yi=(t,e,i,r,o,n)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(a=o.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=o.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Ki(o.paint.get("raster-hue-rotate")),u_perspective_transform:n};var s,a};function Ki(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Ji=t.create(),Qi=(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_)=>{const g=n.transform,y={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_rotate_symbol:+r,u_aspect_ratio:g.width/g.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+o,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ji,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ji,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<t.extend(Qi(e,i,r,o,n,s,a,l,c,u,p,d,f,m,_,g),{u_gamma_scale:o?n.transform.cameraToCenterDistance*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+h}),er=(e,i,r,o,n,s,a,l,c,u,h,p,d,f,m,_)=>t.extend(tr(e,i,r,o,n,s,a,l,!0,c,!0,h,p,d,f,m,_),{u_texsize_icon:u,u_texture_icon:1}),ir=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),rr=(e,i,r,o,n,s)=>t.extend(function(t,e,i,r){const o=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(r.tileID.canonical.x+r.tileID.wrap*l),h=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[s,a],u_mix:e.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/D(r,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(o,s,r,n),{u_matrix:e,u_opacity:i}),or={fillExtrusion:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_opacity:new t.Uniform1f(e,i.u_opacity),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_up_dir:new t.Uniform3f(e,i.u_up_dir),u_height_lift:new t.Uniform1f(e,i.u_height_lift)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,i.u_height_factor),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_up_dir:new t.Uniform3f(e,i.u_up_dir),u_height_lift:new t.Uniform1f(e,i.u_height_lift),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.UniformMatrix2f(e,i.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_up_dir:new t.Uniform3f(e,i.u_up_dir)}),collisionBox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale)}),collisionCircle:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,i.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.UniformColor(e,i.u_color),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_overlay:new t.Uniform1i(e,i.u_overlay),u_overlay_scale:new t.Uniform1f(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.Uniform1f(e,i.u_extrude_scale),u_intensity:new t.Uniform1f(e,i.u_intensity),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_up_dir:new t.Uniform3f(e,i.u_up_dir)}),heatmapTexture:(e,i)=>({u_image:new t.Uniform1i(e,i.u_image),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_opacity:new t.Uniform1f(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_latrange:new t.Uniform2f(e,i.u_latrange),u_light:new t.Uniform2f(e,i.u_light),u_shadow:new t.UniformColor(e,i.u_shadow),u_highlight:new t.UniformColor(e,i.u_highlight),u_accent:new t.UniformColor(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_dimension:new t.Uniform2f(e,i.u_dimension),u_zoom:new t.Uniform1f(e,i.u_zoom),u_unpack:new t.Uniform4f(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_pixels_to_tile_units:new t.UniformMatrix2f(e,i.u_pixels_to_tile_units),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_dash_image:new t.Uniform1i(e,i.u_dash_image),u_gradient_image:new t.Uniform1i(e,i.u_gradient_image),u_image_height:new t.Uniform1f(e,i.u_image_height),u_texsize:new t.Uniform2f(e,i.u_texsize),u_scale:new t.Uniform3f(e,i.u_scale),u_mix:new t.Uniform1f(e,i.u_mix),u_alpha_discard_threshold:new t.Uniform1f(e,i.u_alpha_discard_threshold),u_trim_offset:new t.Uniform2f(e,i.u_trim_offset)}),linePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixels_to_tile_units:new t.UniformMatrix2f(e,i.u_pixels_to_tile_units),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_image:new t.Uniform1i(e,i.u_image),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_alpha_discard_threshold:new t.Uniform1f(e,i.u_alpha_discard_threshold)}),raster:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_tl_parent:new t.Uniform2f(e,i.u_tl_parent),u_scale_parent:new t.Uniform1f(e,i.u_scale_parent),u_fade_t:new t.Uniform1f(e,i.u_fade_t),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image0:new t.Uniform1i(e,i.u_image0),u_image1:new t.Uniform1i(e,i.u_image1),u_brightness_low:new t.Uniform1f(e,i.u_brightness_low),u_brightness_high:new t.Uniform1f(e,i.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,i.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,i.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,i.u_spin_weights),u_perspective_transform:new t.Uniform2f(e,i.u_perspective_transform)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_camera_forward:new t.Uniform3f(e,i.u_camera_forward),u_tile_matrix:new t.UniformMatrix4f(e,i.u_tile_matrix),u_up_vector:new t.Uniform3f(e,i.u_up_vector),u_ecef_origin:new t.Uniform3f(e,i.u_ecef_origin),u_texture:new t.Uniform1i(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_tile_id:new t.Uniform3f(e,i.u_tile_id),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_inv_rot_matrix:new t.UniformMatrix4f(e,i.u_inv_rot_matrix),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_camera_forward:new t.Uniform3f(e,i.u_camera_forward),u_tile_matrix:new t.UniformMatrix4f(e,i.u_tile_matrix),u_up_vector:new t.Uniform3f(e,i.u_up_vector),u_ecef_origin:new t.Uniform3f(e,i.u_ecef_origin),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texsize_icon:new t.Uniform2f(e,i.u_texsize_icon),u_texture:new t.Uniform1i(e,i.u_texture),u_texture_icon:new t.Uniform1i(e,i.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_color:new t.UniformColor(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image:new t.Uniform1i(e,i.u_image),u_pattern_tl_a:new t.Uniform2f(e,i.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,i.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,i.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,i.u_pattern_br_b),u_texsize:new t.Uniform2f(e,i.u_texsize),u_mix:new t.Uniform1f(e,i.u_mix),u_pattern_size_a:new t.Uniform2f(e,i.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,i.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,i.u_scale_a),u_scale_b:new t.Uniform1f(e,i.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,i.u_tile_units_to_pixels)}),terrainRaster:mi,terrainDepth:mi,skybox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_cubemap:new t.Uniform1i(e,i.u_cubemap),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_center_direction:new t.Uniform3f(e,i.u_center_direction),u_radius:new t.Uniform1f(e,i.u_radius),u_opacity:new t.Uniform1f(e,i.u_opacity),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset)}),skyboxCapture:(e,i)=>({u_matrix_3f:new t.UniformMatrix3f(e,i.u_matrix_3f),u_sun_direction:new t.Uniform3f(e,i.u_sun_direction),u_sun_intensity:new t.Uniform1f(e,i.u_sun_intensity),u_color_tint_r:new t.Uniform4f(e,i.u_color_tint_r),u_color_tint_m:new t.Uniform4f(e,i.u_color_tint_m),u_luminance:new t.Uniform1f(e,i.u_luminance)}),globeRaster:(e,i)=>({u_proj_matrix:new t.UniformMatrix4f(e,i.u_proj_matrix),u_globe_matrix:new t.UniformMatrix4f(e,i.u_globe_matrix),u_normalize_matrix:new t.UniformMatrix4f(e,i.u_normalize_matrix),u_merc_matrix:new t.UniformMatrix4f(e,i.u_merc_matrix),u_zoom_transition:new t.Uniform1f(e,i.u_zoom_transition),u_merc_center:new t.Uniform2f(e,i.u_merc_center),u_image0:new t.Uniform1i(e,i.u_image0),u_grid_matrix:new t.UniformMatrix3f(e,i.u_grid_matrix),u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_globe_pos:new t.Uniform3f(e,i.u_globe_pos),u_globe_radius:new t.Uniform1f(e,i.u_globe_radius),u_viewport:new t.Uniform2f(e,i.u_viewport)}),globeAtmosphere:(e,i)=>({u_frustum_tl:new t.Uniform3f(e,i.u_frustum_tl),u_frustum_tr:new t.Uniform3f(e,i.u_frustum_tr),u_frustum_br:new t.Uniform3f(e,i.u_frustum_br),u_frustum_bl:new t.Uniform3f(e,i.u_frustum_bl),u_horizon:new t.Uniform1f(e,i.u_horizon),u_transition:new t.Uniform1f(e,i.u_transition),u_fadeout_range:new t.Uniform1f(e,i.u_fadeout_range),u_color:new t.Uniform4f(e,i.u_color),u_high_color:new t.Uniform4f(e,i.u_high_color),u_space_color:new t.Uniform4f(e,i.u_space_color),u_star_intensity:new t.Uniform1f(e,i.u_star_intensity),u_star_density:new t.Uniform1f(e,i.u_star_density),u_star_size:new t.Uniform1f(e,i.u_star_size),u_temporal_offset:new t.Uniform1f(e,i.u_temporal_offset),u_horizon_angle:new t.Uniform1f(e,i.u_horizon_angle),u_rotation_matrix:new t.UniformMatrix4f(e,i.u_rotation_matrix)})};let nr;function sr(e,i,r,o,n,s,a){const l=e.context,c=l.gl,u=e.transform,h=e.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m0){const e=t.create(),i=v;t.mul(e,y.placementInvProjMatrix,u.glCoordMatrix),t.mul(e,e,y.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:i,invTransform:e,projection:y.getProjection()}),d+=w.length/4,f=d}b&&(e.terrain&&e.terrain.setupElevationDraw(g,h),h.draw(l,c.LINES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,ji(v,u,g,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!a||!p.length)return;const m=e.useProgram("collisionCircle"),_=new t.StructArrayLayout2f1f2i16;_.resize(4*d),_._trim();let g=0;for(const t of p)for(let e=0;e=0&&(m[x.associatedIconIndex]={shiftedAnchor:z,angle:k})}else _e(x.numGlyphs,d)}if(h){f.clear();const i=e.icon.placedSymbolArray;for(let e=0;e[0,0,0],r=ie(V,o.tileID.canonical,g,_,m,c.getProjection(),j);le(c,V,e,n,r,Z,g,u,i,l)}const X=y||n&&E||q,W=e.translatePosMatrix(V,o,s,a),H=X?ar:N,Y=e.translatePosMatrix(Z,o,s,a,!0),K=c.getProjection().createInversionMatrix(m,l.canonical),J=[];e.terrain&&g&&J.push("PITCH_WITH_MAP_TERRAIN"),F&&J.push("PROJECTION_GLOBE_VIEW"),X&&J.push("PROJECTED_POS_ON_VIEWPORT");const Q=d&&0!==r.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let tt;tt=d?c.iconsInText?er(w.kind,z,x,g,e,W,H,Y,k,B,l,U,T,K,O,c.getProjection()):tr(w.kind,z,x,g,e,W,H,Y,n,k,!0,l,U,T,K,O,c.getProjection()):Qi(w.kind,z,x,g,e,W,H,Y,n,k,l,U,T,K,O,c.getProjection());const et={program:e.useProgram(ur(d,n,c),p,J),buffers:h,uniformValues:tt,atlasTexture:P,atlasTextureIcon:R,atlasInterpolation:D,atlasInterpolationIcon:L,isSDF:d,hasHalo:Q,tile:o,labelPlaneMatrixInv:G};if(v&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)C.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:et})}else C.push({segments:h.segments,sortKey:0,state:et})}b&&C.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of C){const i=t.state;if(e.terrain&&e.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const o=i.uniformValues;i.hasHalo&&(o.u_is_halo=1,pr(i.buffers,t.segments,r,e,i.program,w,h,p,o)),o.u_is_halo=0}pr(i.buffers,t.segments,r,e,i.program,w,h,p,i.uniformValues)}}function pr(e,i,r,o,n,s,a,l,c){const u=o.context;n.draw(u,u.gl.TRIANGLES,s,a,l,t.CullFaceMode.disabled,c,r.id,e.layoutVertexBuffer,e.indexBuffer,i,r.paint,o.transform.zoom,e.programConfigurations.get(r.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer)}function dr(e,i,r,o,n,s,a){const l=e.context.gl,c=r.paint.get("fill-pattern"),u=c&&c.constantOr(1),h=r.getCrossfadeParameters();let p,d,f,m,_;a?(d=u&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(d=u?"fillPattern":"fill",p=l.TRIANGLES);for(const g of o){const o=i.getTile(g);if(u&&!o.patternsLoaded())continue;const y=o.getBucket(r);if(!y)continue;e.prepareDrawTile();const x=y.programConfigurations.get(r.id),v=e.useProgram(d,x);u&&(e.context.activeTexture.set(l.TEXTURE0),o.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),x.updatePaintBuffers(h));const b=c.constantOr(null);if(b&&o.imageAtlas){const t=o.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&x.setConstantPatternPositions(e,i)}const w=e.translatePosMatrix(g.projMatrix,o,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,_=y.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&u?Fi(w,e,h,o,t):Ri(w,t)}else m=y.indexBuffer,_=y.segments,f=u?Bi(w,e,h,o):Li(w);e.prepareDrawProgram(e.context,v,g.toUnwrapped()),v.draw(e.context,p,n,e.stencilModeForClipping(g),s,t.CullFaceMode.disabled,f,r.id,y.layoutVertexBuffer,m,_,r.paint,e.transform.zoom,x)}}function fr(e,i,r,o,n,s,a){const l=e.context,c=l.gl,u=e.transform,h=r.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),m="globe"===u.projection.name?t.fillExtrusionHeightLift():0,_="globe"===u.projection.name,g=_?t.globeToMercatorTransition(u.zoom):0,y=[t.mercatorXfromLng(u.center.lng),t.mercatorYfromLat(u.center.lat)],x=[];_&&x.push("PROJECTION_GLOBE_VIEW");for(const v of o){const o=i.getTile(v),b=o.getBucket(r);if(!b||b.projection.name!==u.projection.name)continue;const w=b.programConfigurations.get(r.id),T=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",w,x);if(e.terrain){const t=e.terrain;if(e.style.terrainSetForDrapingOnly())t.setupElevationDraw(o,T,{useMeterToDem:!0});else{if(!b.enableTerrain)continue;if(t.setupElevationDraw(o,T,{useMeterToDem:!0}),mr(l,i,v,b,r,t),!b.centroidVertexBuffer){const t=T.attributes.a_centroid_pos;void 0!==t&&c.vertexAttrib2f(t,0,0)}}}p&&(e.context.activeTexture.set(c.TEXTURE0),o.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),w.updatePaintBuffers(d));const E=h.constantOr(null);if(E&&o.imageAtlas){const t=o.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const S=e.translatePosMatrix(v.projMatrix,o,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),C=u.projection.createInversionMatrix(u,v.canonical),M=r.paint.get("fill-extrusion-vertical-gradient"),A=p?Di(S,e,M,f,v,d,o,m,g,y,C):Pi(S,e,M,f,v,m,g,y,C);e.prepareDrawProgram(l,T,v.toUnwrapped()),T.draw(l,l.gl.TRIANGLES,n,s,a,t.CullFaceMode.backCCW,A,r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,r.paint,e.transform.zoom,w,e.terrain?b.centroidVertexBuffer:null,_?b.layoutVertexExtBuffer:null)}}function mr(e,i,r,o,n,s){const a=[e=>{let i=e.canonical.x-1,r=e.wrap;return i<0&&(i=(1<{let i=e.canonical.x+1,r=e.wrap;return i===1<new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<{const e=i.getSource().minzoom,r=t=>{const e=i.getTileByID(t);if(e&&e.hasData())return e.getBucket(n)},o=[0,-1,1];for(const i of o){if(t.overscaledZ+i(c[0]=Math.min(e.min.y,i.min.y),c[1]=Math.max(e.max.y,i.max.y),c[2]=t.EXTENT-i.min.x>e.max.x?i.min.x-t.EXTENT:e.max.x,c),h=(e,i)=>(c[0]=Math.min(e.min.x,i.min.x),c[1]=Math.max(e.max.x,i.max.x),c[2]=t.EXTENT-i.min.y>e.max.y?i.min.y-t.EXTENT:e.max.y,c),p=[(t,e)=>u(t,e),(t,e)=>u(e,t),(t,e)=>h(t,e),(t,e)=>h(e,t)],d=new t.pointGeometry(0,0);let f,m,_;const g=(e,i,o,n,a)=>{const l=[[n?o:e,n?e:o,0],[n?o:i,n?i:o,0]],c=a<0?t.EXTENT+a:a,u=[n?c:(e+i)/2,n?(e+i)/2:c,0];return 0===o&&a<0||0!==o&&a>0?s.getForTilePoints(_,[u],!0,m):l.push(u),s.getForTilePoints(r,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let e=0;e<4;e++){const i=(e<2?1:5)-e,n=o.borders[e];if(0===n.length)continue;const c=_=a[e](r),u=l(c);if(!(u&&u instanceof t.FillExtrusionBucket&&u.enableTerrain))continue;if(o.borderDoneWithNeighborZ[e]===u.canonical.z&&u.borderDoneWithNeighborZ[i]===o.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(r);if(!t||!t.dem)return;f=t}const h=u.borders[i];let y=0;const x=u.borderDoneWithNeighborZ[i]!==o.canonical.z;if(o.canonical.z===u.canonical.z){for(let r=0;ra[0]+3));)x&&u.encodeCentroid(void 0,l,!1),y++;if(l&&ya[1]-3)&&(n++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[r]],s.intersectsCount()>1||l.intersectsCount()>1||1!==n){1!==n&&(y=r),o.encodeCentroid(void 0,s,!1),x&&u.encodeCentroid(void 0,l,!1);continue}const c=p[e](s,l),f=e%2?t.EXTENT-1:0;d.x=g(c[0],Math.min(t.EXTENT-1,c[1]),f,e<2,c[2]),d.y=0,o.encodeCentroid(d,s,!1),x&&u.encodeCentroid(d,l,!1)}else o.encodeCentroid(void 0,s,!1)}o.borderDoneWithNeighborZ[e]=u.canonical.z,o.needsCentroidUpdate=!0,x&&(u.borderDoneWithNeighborZ[i]=o.canonical.z,u.needsCentroidUpdate=!0)}else{for(const t of n)o.encodeCentroid(void 0,o.featuresOnBorder[t],!1);if(x){for(const t of h)u.encodeCentroid(void 0,u.featuresOnBorder[t],!1);u.borderDoneWithNeighborZ[i]=o.canonical.z,u.needsCentroidUpdate=!0}o.borderDoneWithNeighborZ[e]=u.canonical.z,o.needsCentroidUpdate=!0}}(o.needsCentroidUpdate||!o.centroidVertexBuffer&&0!==o.centroidVertexArray.length)&&o.uploadCentroid(e)}const _r=new t.Color(1,0,0,1),gr=new t.Color(0,1,0,1),yr=new t.Color(0,0,1,1),xr=new t.Color(1,0,1,1),vr=new t.Color(0,1,1,1);function br(t,e,i,r){Tr(t,0,e+i/2,t.transform.width,i,r)}function wr(t,e,i,r){Tr(t,e-i/2,0,i,t.transform.height,r)}function Tr(e,i,r,o,n,s){const a=e.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*t.exported.devicePixelRatio,r*t.exported.devicePixelRatio,o*t.exported.devicePixelRatio,n*t.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Er(e,i,r){const o=e.context,n=o.gl,s="globe"===e.transform.projection.name,a=r.projMatrix,l=e.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),c=i.getTileByID(r.key);e.terrain&&e.terrain.setupElevationDraw(c,l);const u=t.DepthMode.disabled,h=t.StencilMode.disabled,p=e.colorModeForRenderPass(),d="$debug";o.activeTexture.set(n.TEXTURE0),e.emptyTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),s?c._makeGlobeTileDebugBuffers(e.context,e.transform.projection):c._makeDebugTileBoundsBuffers(e.context,e.transform.projection);const f=c._tileDebugBuffer||e.debugBuffer,m=c._tileDebugIndexBuffer||e.debugIndexBuffer,_=c._tileDebugSegments||e.debugSegments;l.draw(o,n.LINE_STRIP,u,h,p,t.CullFaceMode.disabled,Ni(a,t.Color.red),d,f,m,_,null,null,null,c._globeTileDebugBorderBuffer);const g=c.latestRawTileData,y=Math.floor((g&&g.byteLength||0)/1024),x=i.getTile(r).tileSize,v=512/Math.min(x,512)*(r.overscaledZ/e.transform.zoom)*.5;let b=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(b+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,o=t.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,i.width,i.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(e,5,5),o.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${b} ${y}kb`);const w=c._tileDebugTextBuffer||e.debugBuffer,T=c._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,E=c._tileDebugTextSegments||e.debugSegments;l.draw(o,n.TRIANGLES,u,h,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Ni(a,t.Color.transparent,v),d,w,T,E,null,null,null,c._globeTileDebugTextBuffer)}const Sr=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Cr}=Sr;function Mr(t,e,i,r){t.emplaceBack(e,i,r)}class Ar{constructor(e){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,Mr(this.vertexArray,-1,-1,1),Mr(this.vertexArray,1,-1,1),Mr(this.vertexArray,-1,1,1),Mr(this.vertexArray,1,1,1),Mr(this.vertexArray,-1,-1,-1),Mr(this.vertexArray,1,-1,-1),Mr(this.vertexArray,-1,1,-1),Mr(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Cr),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function Ir(e,i,r,o,n,s){const a=e.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,i,r,o)=>({u_matrix_3f:t,u_sun_direction:e,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[o.r,o.g,o.b,o.a],u_luminance:5e-5}))(t.fromMat4(t.create$1(),o),n,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(e,a.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const zr=t.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class kr{constructor(e){const i=new t.StructArrayLayout5f20;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const r=new t.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(i,zr.members),this.indexBuffer=e.createIndexBuffer(r),this.segments=t.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Pr={symbol:function(e,i,r,o,n){if("translucent"!==e.renderPass)return;const s=t.StencilMode.disabled,a=e.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(e,i,r,o,n,s,a){const l=i.transform,c="map"===n,u="map"===s;for(const i of e){const e=o.getTile(i),n=e.getBucket(r);if(!n||!n.text||!n.text.segments.get().length)continue;const s=t.evaluateSizeForZoom(n.textSizeData,l.zoom),h=we(i,n.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(e),d=ee(h,e.tileID.canonical,u,c,l,n.getProjection(),p),f="none"!==r.layout.get("icon-text-fit")&&n.hasIconData();if(s){const r=Math.pow(2,l.zoom-e.tileID.overscaledZ);cr(n,c,u,a,t.symbolSize,l,d,i,r,s,f)}}}(o,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),n),0!==r.paint.get("icon-opacity").constantOr(1)&&hr(e,i,r,o,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,a),0!==r.paint.get("text-opacity").constantOr(1)&&hr(e,i,r,o,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(sr(e,i,r,o,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),sr(e,i,r,o,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,r,o){if("translucent"!==e.renderPass)return;const n=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=e.context,u=c.gl,h=e.transform,p=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),d=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="globe"===h.projection.name,_=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],g=[];for(let n=0;nt.sortKey-e.sortKey));const y={useDepthForOcclusion:!m};for(const i of g){const{programConfiguration:o,program:n,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:_,tile:g}=i.state,x=i.segments;e.terrain&&e.terrain.setupElevationDraw(g,n,y),e.prepareDrawProgram(c,n,g.tileID.toUnwrapped()),n.draw(c,u.TRIANGLES,p,d,f,t.CullFaceMode.disabled,_,r.id,s,l,x,r.paint,h.zoom,o,m?a:null)}},heatmap:function(e,i,r,o){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,s=n.gl,a=t.StencilMode.disabled,l=new t.ColorMode([s.ONE,s.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i,r){const o=t.gl,n=e.width*r,s=e.height*r;t.activeTexture.set(o.TEXTURE1),t.viewport.set([0,0,n,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==n||a.height!==s)){a&&a.destroy();const e=o.createTexture();o.bindTexture(o.TEXTURE_2D,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),a=i.heatmapFbo=t.createFramebuffer(n,s,!1),function(t,e,i,r,o,n){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o,n,0,s.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,0,e,a,n,s)}else o.bindTexture(o.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)}(n,e,r,"globe"===e.transform.projection.name?.5:.25),n.clear({color:t.Color.transparent});const c=e.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?t.CullFaceMode.frontCCW:t.CullFaceMode.disabled,d=[t.mercatorXfromLng(c.center.lng),t.mercatorYfromLat(c.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,i),i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,r))},line:function(e,i,r,o){if("translucent"!==e.renderPass)return;const n=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===n.constantOr(1)||0===s.constantOr(1))return;const a=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),l=e.colorModeForRenderPass(),c=e.terrain&&e.terrain.renderingToTexture?1:t.exported.devicePixelRatio,u=r.paint.get("line-dasharray"),h=u.constantOr(1),p=r.layout.get("line-cap"),d=r.paint.get("line-pattern"),f=d.constantOr(1),m=r.paint.get("line-gradient"),_=r.getCrossfadeParameters(),g=f?"linePattern":"line",y=e.context,x=y.gl,v=(t=>{const e=[];Hi(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET");const r=t.paint.get("line-pattern").constantOr(1),o=1!==t.paint.get("line-opacity").constantOr(1);return!r&&o&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(r);let b=v.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const n of o){const o=i.getTile(n);if(f&&!o.patternsLoaded())continue;const s=o.getBucket(r);if(!s)continue;e.prepareDrawTile();const w=s.programConfigurations.get(r.id),T=e.useProgram(g,w,v),E=d.constantOr(null);if(E&&o.imageAtlas){const t=o.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}const S=u.constantOr(null),C=p.constantOr(null);if(!f&&S&&C&&o.lineAtlas){const t=o.lineAtlas,e=t.getDash(S.to,C),i=t.getDash(S.from,C);e&&i&&w.setConstantPatternPositions(e,i)}let[M,A]=r.paint.get("line-trim-offset");if("round"===C||"square"===C){const t=1;M!==A&&(0===M&&(M-=t),1===A&&(A+=t))}const I=e.terrain?n.projMatrix:null,z=f?qi(e,o,r,_,I,c):$i(e,o,r,_,I,s.lineClipsArray.length,c,[M,A]);if(m){const o=s.gradients[r.id];let a=o.texture;if(r.gradientVersion!==o.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,o=n.canonical.z===r?Math.ceil(1<{T.draw(y,x.TRIANGLES,a,i,l,t.CullFaceMode.disabled,z,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,e.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const i=e.stencilModeForClipping(n).ref;0===i&&e.terrain&&y.clear({stencil:0});const r={func:x.EQUAL,mask:255};z.u_alpha_discard_threshold=.8,k(new t.StencilMode(r,i,255,x.KEEP,x.KEEP,x.INVERT)),z.u_alpha_discard_threshold=0,k(new t.StencilMode(r,i,255,x.KEEP,x.KEEP,x.KEEP))}else k(e.stencilModeForClipping(n))}b&&(e.resetStencilClippingMasks(),e.terrain&&y.clear({stencil:0}))},fill:function(e,i,r,o){const n=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=e.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(t.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);dr(e,i,r,o,n,a,!1)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){const n=e.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);dr(e,i,r,o,n,a,!0)}},"fill-extrusion":function(e,i,r,o){const n=r.paint.get("fill-extrusion-opacity");if(0!==n&&"translucent"===e.renderPass){const s=new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==n||r.paint.get("fill-extrusion-pattern").constantOr(1))fr(e,i,r,o,s,t.StencilMode.disabled,t.ColorMode.disabled),fr(e,i,r,o,s,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const n=e.colorModeForRenderPass();fr(e,i,r,o,s,t.StencilMode.disabled,n)}}},hillshade:function(e,i,r,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const n=e.context,s=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),a=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture,[c,u]="translucent"!==e.renderPass||l?[{},o]:e.stencilConfigForOverlap(o);for(const o of u){const n=i.getTile(o);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)fi(e,n,r,s,t.StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=l&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):c[o.overscaledZ];pi(e,o,n,r,s,t,a)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,i,r,o,n,s){if("translucent"!==e.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!o.length)return;const a=e.context,l=a.gl,c=i.getSource(),u=e.useProgram("raster"),h=e.colorModeForRenderPass(),p=e.terrain&&e.terrain.renderingToTexture,[d,f]=c instanceof zt||p?[{},o]:e.stencilConfigForOverlap(o),m=f[f.length-1].overscaledZ,_=!e.options.moving;for(const o of f){const n=p?t.DepthMode.disabled:e.depthModeForSublayer(o.overscaledZ-m,1===r.paint.get("raster-opacity")?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,l.LESS),f=o.toUnwrapped(),g=i.getTile(o);if(p&&(!g||!g.hasData()))continue;const y=p?o.projMatrix:e.transform.calculateProjMatrix(f,_),x=e.terrain&&p?e.terrain.stencilModeForRTTOverlap(o):d[o.overscaledZ],v=s?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(v);const b=i.findLoadedParent(o,0),w=Ti(g,b,i,e.transform,v);let T,E;e.terrain&&e.terrain.prepareDrawTile();const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),E=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(S,l.CLAMP_TO_EDGE);const C=Yi(y,E||[0,0],T||1,w,r,c instanceof zt?c.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,u,f),c instanceof zt)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,n,t.StencilMode.disabled,h,t.CullFaceMode.disabled,C,r.id,c.boundsBuffer,e.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:o,tileBoundsSegments:s}=e.getTileBoundsBuffers(g);u.draw(a,l.TRIANGLES,n,x,h,t.CullFaceMode.disabled,C,r.id,i,o,s)}}e.resetStencilClippingMasks()},background:function(e,i,r,o){const n=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(0===s)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=r.paint.get("background-pattern");if(e.isPatternMissing(h))return;const p=!h&&1===n.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==p)return;const d=t.StencilMode.disabled,f=e.depthModeForSublayer(0,"opaque"===p?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),m=e.colorModeForRenderPass(),_=e.useProgram(h?"backgroundPattern":"background");let g,y=o;y||(g=e.getBackgroundTiles(),y=Object.values(g).map((t=>t.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));const x=r.getCrossfadeParameters();for(const p of y){const y=p.toUnwrapped(),v=o?p.projMatrix:e.transform.calculateProjMatrix(y);e.prepareDrawTile();const b=i?i.getTile(p):g?g[p.key]:new t.Tile(p,u,c.zoom,e),w=h?rr(v,s,e,h,{tileID:p,tileSize:u},x):ir(v,s,n);e.prepareDrawProgram(a,_,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:E,tileBoundsSegments:S}=e.getTileBoundsBuffers(b);_.draw(a,l.TRIANGLES,f,d,m,t.CullFaceMode.disabled,w,r.id,T,E,S)}},sky:function(e,i,r){const o=e.transform,n="mercator"===o.projection.name||"globe"===o.projection.name?1:t.smoothstep(7,8,o.zoom),s=r.paint.get("sky-opacity")*n;if(0===s)return;const a=e.context,l=r.paint.get("sky-type"),c=new t.DepthMode(a.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===e.renderPass?r.needsSkyboxCapture(e)&&(function(e,i,r,o){const n=e.context,s=n.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=n.createFramebuffer(32,32,!1),i.skyboxGeometry=new Ar(n),i.skyboxTexture=n.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(a.framebuffer),n.viewport.set([0,0,32,32]);const l=i.getCenter(e,!0),c=e.useProgram("skyboxCapture"),u=new Float64Array(16);t.identity(u),t.rotateY(u,u,.5*-Math.PI),Ir(n,i,c,u,l,0),t.identity(u),t.rotateY(u,u,.5*Math.PI),Ir(n,i,c,u,l,1),t.identity(u),t.rotateX(u,u,.5*-Math.PI),Ir(n,i,c,u,l,2),t.identity(u),t.rotateX(u,u,.5*Math.PI),Ir(n,i,c,u,l,3),t.identity(u),Ir(n,i,c,u,l,4),t.identity(u),t.rotateY(u,u,Math.PI),Ir(n,i,c,u,l,5),n.viewport.set([0,0,e.width,e.height])}(e,r),r.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,i,r,o,n){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((t,e,i,r,o)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(e,!1),0,o,n);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,c,s,u):"gradient"===l&&"sky"===e.renderPass&&function(e,i,r,o,n){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ar(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new t.Texture(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,i,r,o,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:i,u_radius:t.degToRad(r),u_opacity:o,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(e,!1),i.paint.get("sky-gradient-radius"),o,n);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,r,c,s,u)},debug:function(t,e,i){for(let r=0;rr)return void(this.transform.fogCullDistSq=null);const o=i+.78*(r-i);this.transform.fogCullDistSq=o*o}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,i){if(this.width=e*t.exported.devicePixelRatio,this.height=i*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const e=this.context,i=new t.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(i,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const r=new t.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(t.EXTENT,0),r.emplaceBack(0,t.EXTENT),r.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=e.createVertexBuffer(r,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const o=new t.StructArrayLayout2i4;o.emplaceBack(-1,-1),o.emplaceBack(1,-1),o.emplaceBack(-1,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const n=new t.StructArrayLayout4i8;n.emplaceBack(0,0,0,0),n.emplaceBack(t.EXTENT,0,t.EXTENT,0),n.emplaceBack(0,t.EXTENT,0,t.EXTENT),n.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.mercatorBoundsBuffer=e.createVertexBuffer(n,t.boundsAttributes.members),this.mercatorBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new t.StructArrayLayout1ui2;for(const t of[0,1,3,2,0])a.emplaceBack(t);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new t.Texture(e,new t.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=t.create();const l=this.context.gl;this.stencilClearMode=new t.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.window.performance.now()),this.atmosphereBuffer=new kr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,i.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,wi(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,i,r){if(!i||this.currentStencilSource===i.id||!e.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let t=!1;for(const e of r)if(void 0===this._tileClippingMaskIDs[e.key]){t=!0;break}if(!t)return}this.currentStencilSource=i.id;const o=this.context,n=o.gl;this.nextStencilID+r.length>256&&this.clearStencil(),o.setColorMode(t.ColorMode.disabled),o.setDepthMode(t.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of r){const r=i.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(r);s.draw(o,n.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:n.ALWAYS,mask:0},a,255,n.KEEP,n.KEEP,n.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,wi(e.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,i=this.context.gl;return new t.StencilMode({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const i=this.context.gl;return new t.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(e){const i=this.context.gl,r=e.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),o=r[r.length-1].overscaledZ,n=r[0].overscaledZ-o+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let r=0;r=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky())continue;const o=i?s[i.id]:void 0;this._renderTileClippingMasks(t,i,o),this.renderLayer(this,i,t,o)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,i){const r=e.context,o=r.gl,n=e.transform,s=new t.DepthMode(o.LEQUAL,t.DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=t.globeToMercatorTransition(n.zoom),c=i.properties.get("color").toArray01(),u=i.properties.get("high-color").toArray01(),h=i.properties.get("space-color").toArray01PremultipliedAlpha(),p=t.identity$1([]);t.rotateY$1(p,p,-t.degToRad(n._center.lng)),t.rotateX$1(p,p,t.degToRad(n._center.lat)),t.rotateZ$1(p,p,n.angle),t.rotateX$1(p,p,-n._pitch);const d=t.fromQuat(new Float32Array(16),p),f=t.mapValue(i.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=t.mapValue(i.properties.get("horizon-blend"),0,1,m,.25),g=t.globeUseCustomAntiAliasing(e,r,n)&&_===m?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,y=e.frameCounter/1e3%1,x=t.length(n.globeCenterInViewSpace),v=Math.sqrt(Math.pow(x,2)-Math.pow(g,2)),b=Math.acos(v/x),w=((e,i,r,o,n,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:e,u_frustum_tr:i,u_frustum_br:r,u_frustum_bl:o,u_horizon:n,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*t.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,l,_,c,u,h,f,y,b,d);e.prepareDrawProgram(r,a);const T=e.atmosphereBuffer;T&&a.draw(r,o.TRIANGLES,s,t.StencilMode.disabled,t.ColorMode.alphaBlended,t.CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(t.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const r=e._getLayerSourceCache(t);r&&!t.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.style&&this.style.fog,i=[];return this.terrain&&!this.terrain.renderingToTexture&&i.push("TERRAIN"),e&&!t&&0!==e.getOpacity(this.transform.pitch)&&i.push("FOG"),t&&i.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&i.push("OVERDRAW_INSPECTOR"),i}useProgram(t,e,i){this.cache=this.cache||{};const r=i||[],o=this.currentGlobalDefines().concat(r),n=Ii.cacheKey(t,o,e);return this.cache[n]||(this.cache[n]=new Ii(this.context,t,li[t],e,or[t],o)),this.cache[n]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,i,r){if(this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const n=o.getOpacity(this.transform.pitch),s=((e,i,r,o,n,s,a,l,c,u,h)=>{const p=e.transform,d=i.properties.get("color").toArray01();d[3]=o;const f=e.frameCounter/1e3%1;return{u_fog_matrix:r?p.calculateFogTileMatrix(r):e.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:n,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:t.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,o,r,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*t.exported.devicePixelRatio,this.transform.height*t.exported.devicePixelRatio]);i.setFogUniformValues(e,s)}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,i=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const o of r)i[o.key]=e[o.key]||new t.Tile(o,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Lr{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.clamp((this.left+e-this.right)/2,0,e),o=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.pointGeometry(r,o)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Lr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Br(e,i){const r=t.getColumn(e,3);t.fromQuat(e,i),t.setColumn(e,3,r)}function Rr(e,i){const r=t.identity$1([]);return t.rotateZ$1(r,r,-i),t.rotateX$1(r,r,-e),r}function Fr(e,i){const r=[e[0],e[1],0],o=[i[0],i[1],0];if(t.length(r)>=1e-15){const e=t.normalize([],r);t.scale$2(o,e,t.dot(o,e)),i[0]=o[0],i[1]=o[1]}const n=t.cross([],i,e);if(t.len(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return Rr(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),s)}class Or{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(e){if(e){const i=e instanceof t.MercatorCoordinate?e:new t.MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(i.x=t.wrap(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(e,i){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(e)):0,o=this.position,n=t.MercatorCoordinate.fromLngLat(e,r),s=[n.x-o.x,n.y-o.y,n.z-o.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Fr(s,i)}setPitchBearing(e,i){this.orientation=Rr(t.degToRad(e),t.degToRad(-i))}}class Ur{constructor(e,i){this._transform=t.identity([]),this.orientation=i,this.position=e}get mercatorPosition(){const e=this.position;return new t.MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=t.getColumn(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var i;e&&t.setColumn(this._transform,3,[(i=e)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||t.identity$1([]),e&&Br(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=Rr(t,e),Br(this._transform,this._orientation)}forward(){const e=t.getColumn(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=t.getColumn(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=t.getColumn(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,i){const r=new Float64Array(16);return t.invert(r,this.getWorldToCamera(e,i)),r}getWorldToCameraPosition(e,i,r){const o=this.position;t.scale$2(o,o,-e);const n=new Float64Array(16);return t.fromScaling(n,[r,r,r]),t.translate(n,n,o),n[10]*=i,n}getWorldToCamera(e,i){const r=new Float64Array(16),o=new Float64Array(4),n=this.position;return t.conjugate(o,this._orientation),t.scale$2(n,n,-e),t.fromQuat(r,o),t.translate(r,r,n),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(e,i,r,o){const n=new Float64Array(16);return t.perspective(n,e,i,r,o),n}getDistanceToElevation(e){const i=0===e?0:t.mercatorZfromAltitude(e,this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new Ur([...this.position],[...this.orientation])}}function Vr(e,i){const r=Nr(e.projection,e.zoom,e.width,e.height),o=function(e,i,r,o,n){const s=new t.LngLat(r.lng-180*Gr,r.lat),a=new t.LngLat(r.lng+180*Gr,r.lat),l=e.project(s.lng,s.lat),c=e.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=t.MercatorCoordinate.fromLngLat(r);h.y=t.clamp(h.y,-.999975,.999975);const p=h.toLngLat(),d=e.project(p.lng,p.lat),f=t.MercatorCoordinate.fromLngLat(p);f.x+=Gr;const m=f.toLngLat(),_=e.project(m.lng,m.lat),g=$r(_.x-d.x,_.y-d.y,u),y=t.MercatorCoordinate.fromLngLat(p);y.y+=Gr;const x=y.toLngLat(),v=e.project(x.lng,x.lat),b=$r(v.x-d.x,v.y-d.y,u),w=Math.abs(g.x)/Math.abs(b.y),T=t.identity([]);t.rotateZ(T,T,-u*(1-(n?0:o)));const E=t.identity([]);return t.scale(E,E,[1,1-(1-w)*o,1]),E[4]=-b.x/b.y*o,t.rotateZ(E,E,u),t.multiply(E,T,E),E}(e.projection,0,e.center,r,i),n=jr(e);return t.scale(o,o,[n,n,1]),o}function jr(e){const i=e.projection,r=Nr(e.projection,e.zoom,e.width,e.height),o=Zr(i,e.center),n=Zr(i,t.LngLat.convert(i.center));return Math.pow(2,o*r+(1-r)*n)}function Nr(e,i,r,o,n=1/0){const s=e.range;if(!s)return 0;const a=Math.min(n,Math.max(r,o)),l=Math.log(a/1024)/Math.LN2;return t.smoothstep(s[0]+l,s[1]+l,i)}const Gr=1/4e4;function Zr(e,i){const r=t.clamp(i.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),o=new t.LngLat(i.lng-180*Gr,r),n=new t.LngLat(i.lng+180*Gr,r),s=e.project(o.lng,r),a=e.project(n.lng,r),l=t.MercatorCoordinate.fromLngLat(o),c=t.MercatorCoordinate.fromLngLat(n),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function $r(t,e,i){const r=Math.cos(i),o=Math.sin(i);return{x:t*r-e*o,y:t*o+e*r}}class qr{constructor(e,i,r,o,n,s,a){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==o?60:o,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Lr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Ur,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const t=new qr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t){const e=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||e)&&this._updateCameraOnTerrain(),(t||e)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return t.pick(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=t.getProjection(this.projectionOptions);const o=!e(r,this.getProjection());return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.pointGeometry(this.width,this.height)}get bearing(){return t.wrap(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const i=-e*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(t,e,i){var r=e[0],o=e[1],n=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*a,t[1]=o*l+s*a,t[2]=r*-a+n*l,t[3]=o*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const t=this._elevation;this._centerAltitude=t.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=t.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let o=0,n=0;for(let s=0;se.maxzoom&&(i=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<{const i=1/4e4,r=new t.MercatorCoordinate(e.x+i,e.y,e.z),o=new t.MercatorCoordinate(e.x,e.y+i,e.z),n=e.toLngLat(),s=r.toLngLat(),a=o.toLngLat(),l=this.locationCoordinate(n),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/i},T=e=>{const i=x,r=v;return{aabb:t.tileAABB(this,l,0,0,0,e,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:e,fullyVisible:!1}},E=[];let S=[];const C=i,M=e.reparseOverscaled?r:i,A=t=>t*t,I=A((m-this._centerAltitude)*f),z=t=>{if(!this._elevation||!t.tileID||!n)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=k(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},k=e=>{if(e.zoom=.9)return!0}else if(o&&(s=A(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,e.zoom),r=w(new t.MercatorCoordinate((e.x+.5)/i,(e.y+.5)/i));l=r>.85?1:r}const c=i*i+n*n+s;return c{if(e*A(.707)0;){const r=E.pop(),s=r.x,a=r.y;let h=r.fullyVisible;if(!h){const t=r.aabb.intersects(p);if(0===t)continue;h=2===t}if(r.zoom!==C&&k(r))for(let e=0;e<4;e++){const i=(s<<1)+e%2,c=(a<<1)+(e>>1),p={aabb:n?r.aabb.quadrant(e):t.tileAABB(this,l,r.zoom+1,i,c,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:c,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!u&&(p.tileID=new t.OverscaledTileID(r.zoom+1===C?M:r.zoom+1,r.wrap,r.zoom+1,i,c),z(p)),E.push(p)}else{const o=r.zoom===C?M:r.zoom;if(e.minzoom&&e.minzoom>o)continue;const n=c[0]-(.5+s+(r.wrap<{const n=[0,0,0,1],s=[t.EXTENT,t.EXTENT,0,1],a=this.calculateFogTileMatrix(o.tileID.toUnwrapped());t.transformMat4$1(n,n,a),t.transformMat4$1(s,s,a);const l=t.getAABBPointSquareDist(n,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>i&&0!==r){const i=this.calculateProjMatrix(o.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=u.getMinMaxForTile(o.tileID)),n||(n={min:v,max:x});const s=t.furthestTileCorner(this.rotation),a=[s[0]*t.EXTENT,s[1]*t.EXTENT,n.max];t.transformMat4(a,a,i),c=(1-a[1])*this.height*.5t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.clamp(e.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),r=this.projection.project(e.lng,i);return new t.pointGeometry(r.x*this.worldSize,r.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,i){let r,o;const n=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;r=(i.x-n.x)/t,o=(i.y-n.y)/t}else{const t=this.pointCoordinate(i),e=this.pointCoordinate(n);r=t.x-e.x,o=t.y-e.y}const s=this.locationCoordinate(e);this.setLocation(new t.MercatorCoordinate(s.x-r,s.y-o))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this.projection.locationPoint(this,t,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(e,i){const r=i?t.mercatorZfromAltitude(i,e.lat):void 0,o=this.projection.project(e.lng,e.lat);return new t.MercatorCoordinate(o.x,o.y,r)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(e,i){const r=null!=i?i:this._centerAltitude,o=[e.x,e.y,0,1],n=[e.x,e.y,1,1];t.transformMat4$1(o,o,this.pixelMatrixInverse),t.transformMat4$1(n,n,this.pixelMatrixInverse);const s=n[3];t.scale$1(o,o,1/o[3]),t.scale$1(n,n,1/s);const a=o[2],l=n[2];return{p0:o,p1:n,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(e){const i=[e.x,e.y,0,1],r=[e.x,e.y,1,1];return t.transformMat4$1(i,i,this.pixelMatrixInverse),t.transformMat4$1(r,r,this.pixelMatrixInverse),t.scale$1(i,i,1/i[3]),t.scale$1(r,r,1/r[3]),i[2]=t.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,r[2]=t.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,t.scale$1(i,i,1/this.worldSize),t.scale$1(r,r,1/this.worldSize),new t.Ray([i[0],i[1],i[2]],t.normalize([],t.sub([],r,i)))}rayIntersectionCoordinate(e){const{p0:i,p1:r,t:o}=e,n=t.mercatorZfromAltitude(i[2],this._center.lat),s=t.mercatorZfromAltitude(r[2],this._center.lat);return new t.MercatorCoordinate(t.number(i[0],r[0],o)/this.worldSize,t.number(i[1],r[1],o)/this.worldSize,t.number(n,s,o))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let i=this.projection.pointCoordinate3D(this,e.x,e.y);if(i)return new t.MercatorCoordinate(i[0],i[1],i[2]);let r=0,o=this.horizonLineFromTop();if(e.y>o)return this.pointCoordinate(e);const n=.02*o,s=e.clone();for(let e=0;e<10&&o-r>n;e++){s.y=t.number(r,o,.66);const e=this.projection.pointCoordinate3D(this,s.x,s.y);e?(o=s.y,i=e):r=s.y}return i?new t.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(e)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}_coordinatePoint(e,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,o=[e.x*this.worldSize,e.y*this.worldSize,r+e.toAltitude(),1];return t.transformMat4$1(o,o,this.pixelMatrix),o[3]>0?new t.pointGeometry(o[0]/o[3],o[1]/o[3]):new t.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(e,i){const r=new t.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),o=new t.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),n=new t.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new t.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(r,e),l=this.pointCoordinate(o,e);const c=this.pointCoordinate(n,i),u=this.pointCoordinate(s,i),h=(t,e)=>(e.y-t.y)/(e.x-t.x);return a.y>1&&l.y>=0?a=new t.MercatorCoordinate((1-u.y)/h(u,a)+u.x,1):a.y<0&&l.y<=1&&(a=new t.MercatorCoordinate(-u.y/h(u,a)+u.x,0)),l.y>1&&a.y>=0?l=new t.MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new t.MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new t.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const t=this.elevation;if(!t.visibleDemTiles.length)return this._getBounds(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBounds(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-t.MAX_MERCATOR_LATITUDE,this.maxLat=t.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLngu&&(s=u-l),u-ce&&(n=e-a),e-t.5?x-1:x,v>.5?v-1:v,0]),this.alignedProjMatrix=b,s=t.create(),t.scale(s,s,[this.width/2,-this.height/2,1]),t.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=t.create(),t.scale(s,s,[1,-1,1]),t.translate(s,s,[-1,-1,0]),t.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=t.invert(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=s,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=t.calculateGlobeMatrix(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=t.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,i=this.cameraPixelsPerMeter,r=this._camera.position,o=1/this.height/this._projectionScaler,n=[e,e,i];t.scale$2(n,n,o),t.scale$2(r,r,-1),t.multiply$2(r,r,n);const s=t.create();t.translate(s,s,r),t.scale(s,s,n),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,i,o)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,o=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*o,r.y/this.worldSize-i[1]*o,t/this.worldSize*this._centerAltitude-i[2]*o]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=e[2];let o=1;r>0&&(o=Math.min((i-this._camera.position[2])/r,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,e,o),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const e=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:o}=this._camera.getPitchBearing(),n=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),a=Math.max((e[2]-n)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);t.scaleAndAdd(e,e,i,a),this._pitch=t.clamp(r,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(o,-Math.PI,Math.PI),this._setZoom(t.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new t.MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(t.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,i){const r=Math.min(e.x,i.x),o=Math.max(e.x,i.x),n=Math.min(e.y,i.y),s=Math.max(e.y,i.y);if(nc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new t.pointGeometry(0,0),new t.pointGeometry(this.width,this.height))}zoomDeltaToMovement(e,i){const r=t.length(t.sub([],this._camera.position,e)),o=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(o)}getCameraPoint(){if("globe"===this.projection.name){const e=function(e,i){const r=[e[0],e[1],e[2],1];t.transformMat4$1(r,r,i);const o=Math.max(r[3],1e-6);return[r[0]/o,r[1]/o,r[2]/o,o]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new t.pointGeometry(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.pointGeometry(0,e))}}getCameraToCenterDistance(t){const e=Nr(t,this.zoom,this.width,this.height,1024),i=t.pixelSpaceConversion(this.center.lat,this.worldSize,e);return.5/Math.tan(.5*this._fov)*this.height*i}}function Xr(t,e){let i=!1,r=null;const o=()=>{r=null,i&&(t(),r=setTimeout(o,e),i=!1)};return()=>(i=!0,r||o(),r)}class Wr{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Xr(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(e){const i=this._map;if(!i)return"";const r=i.getCenter(),o=Math.round(100*i.getZoom())/100,n=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,n),a=Math.round(r.lng*s)/s,l=Math.round(r.lat*s)/s,c=i.getBearing(),u=i.getPitch();let h="";if(h+=e?`/${a}/${l}/${o}`:`${o}/${l}/${a}`,(c||u)&&(h+="/"+Math.round(10*c)/10),u&&(h+=`/${Math.round(u)}`),this._hashName){const e=this._hashName;let i=!1;const r=t.window.location.hash.slice(1).split("&").map((t=>{const r=t.split("=")[0];return r===e?(i=!0,`${r}=${h}`):t})).filter((t=>t));return i||r.push(`${e}=${h}`),`#${r.join("&")}`}return`#${h}`}_getCurrentHash(){const e=t.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((t=>t.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const i=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:i,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,e)}}const Hr={linearity:.3,easing:t.bezier(0,0,.3,1)},Yr=t.extend({deceleration:2500,maxSpeed:1400},Hr),Kr=t.extend({deceleration:20,maxSpeed:1400},Hr),Jr=t.extend({deceleration:1e3,maxSpeed:360},Hr),Qr=t.extend({deceleration:1e3,maxSpeed:90},Hr);class to{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(i.pan.mag()){const n=io(i.pan.mag(),r,t.extend({},Yr,e||{}));o.offset=i.pan.mult(n.amount/i.pan.mag()),o.center=this._map.transform.center,eo(o,n)}if(i.zoom){const t=io(i.zoom,r,Kr);o.zoom=this._map.transform.zoom+t.amount,eo(o,t)}if(i.bearing){const e=io(i.bearing,r,Jr);o.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),eo(o,e)}if(i.pitch){const t=io(i.pitch,r,Qr);o.pitch=this._map.transform.pitch+t.amount,eo(o,t)}if(o.zoom||o.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;o.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),o.noMoveStart=!0,o}}function eo(t,e){(!t.duration||t.durationi.unproject(t))),a=n.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new t.pointGeometry(0,0));super(e,{points:n,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class no extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class so{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new no(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ro(t.type,this._map,t))}mouseup(t){this._map.fire(new ro(t.type,this._map,t))}preclick(e){const i=t.extend({},e);i.type="preclick",this._map.fire(new ro(i.type,this._map,i))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new ro(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new ro(t.type,this._map,t))}mouseover(t){this._map.fire(new ro(t.type,this._map,t))}mouseout(t){this._map.fire(new ro(t.type,this._map,t))}touchstart(t){return this._firePreventable(new oo(t.type,this._map,t))}touchmove(t){this._map.fire(new oo(t.type,this._map,t))}touchend(t){this._map.fire(new oo(t.type,this._map,t))}touchcancel(t){this._map.fire(new oo(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ao{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new ro(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ro("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new ro(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class lo{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(u(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const r=this._startPos,o=i;if(this.reset(),d(),r.x!==o.x||r.y!==o.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(r,o,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function co(t,e){const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.pointGeometry(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=co(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=co(i,e);for(const t in this.touches){const e=this.touches[t],i=r[t];(!i||i.dist(e)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class ho{constructor(t){this.singleTap=new uo(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class po{constructor(){this._zoomIn=new ho({numTouches:1,numTaps:2}),this._zoomOut=new ho({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),o=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):o?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(o)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fo={0:1,2:2};class mo{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=_(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const i=fo[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)0&&(this._active=!0);const o=co(r,i),n=new t.pointGeometry(0,0),s=new t.pointGeometry(0,0);let a=0;for(const t in o){const e=o[t],i=this._touches[t];i&&(n._add(e),s._add(e.sub(i)),a++,o[t]=e)}if(this._touches=o,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class vo{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){const r=this._firstTwoTouches;if(!r)return;t.preventDefault();const[o,n]=r,s=bo(i,e,o),a=bo(i,e,n);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[r,o]=this._firstTwoTouches,n=bo(i,e,r),s=bo(i,e,o);n&&s||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function bo(t,e,i){for(let r=0;rMath.abs(t.x)}class Mo extends vo{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Co(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){const r=this._lastPoints;if(!r)return;const o=t[0].sub(r[0]),n=t[1].sub(r[1]);return this._map._cooperativeGestures&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(o,n,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+n.y)/2*-.5})}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,o=e.mag()>=2;if(!r&&!o)return;if(!r||!o)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=t.y>0==e.y>0;return Co(t)&&Co(e)&&n}}const Ao={panStep:100,bearingStep:15,pitchStep:10};class Io{constructor(){const t=Ao;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,o=0,n=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),o=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),o=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:zo,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-o*this._panStep,-n*this._panStep],center:s.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function zo(t){return t*(2-t)}const ko=4.000244140625;class Po{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=t.exported.now(),o=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%ko==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const e=f(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform,i=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>ko?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==r&&(r=1/r);const o=i(),n=Math.pow(2,o),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):n;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),o=this._startZoom,n=this._easing;let s,a=!1;if("wheel"===this._type&&o&&n){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),i=n(e);s=t.number(o,r,i),e<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,r=(t.exported.now()-e.start)/e.duration,o=e.easing(r+.01)-e.easing(r),n=.27/Math.sqrt(o*o+1e-4)*.01,s=Math.sqrt(.0729-n*n);i=t.bezier(n,s,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=n("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!t.window.document.fullscreenElement||!!t.window.document.webkitFullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class Do{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Lo{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Bo{constructor(){this._tap=new ho({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],o=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:o/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ro{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Fo{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Oo{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Uo=t=>t.zoom||t.drag||t.pitch||t.rotate;class Vo extends t.Event{}class jo{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,i){const r=t.sub([],i,e);this.radius=t.length(r[2]<0?t.div([],r,this.constants):[r[0],r[1],0])}projectRay(e){t.div(e,e,this.constants),t.normalize(e,e),t.mul$1(e,e,this.constants);const i=t.scale$2([],e,this.radius);if(i[2]>0){const e=t.scale$2([],[0,0,1],t.dot(i,[0,0,1])),r=t.scale$2([],t.normalize([],[i[0],i[1],0]),this.radius),o=t.add([],i,t.scale$2([],t.sub([],t.add([],r,e),i),2));i[0]=o[0],i[1]=o[1]}return i}}function No(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Go{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new to(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new jo,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[e,i,r]of this._listeners)e.addEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[e,i,r]of this._listeners)e.removeEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new so(e,t));const r=e.boxZoom=new lo(e,t);this._add("boxZoom",r);const o=new po,n=new Lo;e.doubleClickZoom=new Do(n,o),this._add("tapZoom",o),this._add("clickZoom",n);const s=new Bo;this._add("tapDragZoom",s);const a=e.touchPitch=new Mo(e);this._add("touchPitch",a);const l=new go(t),c=new yo(t);e.dragRotate=new Fo(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new _o(t),h=new xo(e,t);e.dragPan=new Ro(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new So,d=new To;e.touchZoomRotate=new Oo(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ao(e));const f=e.scrollZoom=new Po(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new Io;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Uo(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){this._updatingCamera=!0;const i="renderFrame"===t.type,r=i?void 0:t,o={needsRenderFrame:!1},n={},s={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?m(this._el,a):i?void 0:f(this._el,t);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[e||t.type]&&(h=c[e||t.type](t,l,a),this.mergeHandlerResult(o,n,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const t in this._previousActiveHandlers)s[t]||(c[t]=r);this._previousActiveHandlers=s,(Object.keys(c).length||No(o))&&(this._changes.push([o,n,c]),this._triggerRenderFrame()),(Object.keys(s).length||No(o))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=o;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,r,o,n){if(!r)return;t.extend(e,r);const s={handlerName:o,originalEvent:r.originalEvent||n};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},r={};for(const[o,n,s]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new t.pointGeometry(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),void 0!==o.around&&(e.around=o.around),void 0!==o.aroundCoord&&(e.aroundCoord=o.aroundCoord),void 0!==o.pinchAround&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),t.extend(i,n),t.extend(r,s);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,i,r){const o=this._map,n=o.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!No(e)){const t=n.zoom;n.cameraElevationReference="sea",n.recenterOnTerrain(),n.cameraElevationReference="ground",t!==n.zoom&&this._map._update(!0)}if(!No(e))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=e;void 0!==d&&(h=d),(t=>i.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(n.pointCoordinate3D(h)),this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",o._stop(!0),h=h||o.transform.centerPoint,c&&(n.bearing+=c),u&&(n.pitch+=u),n._updateCameraState();const f=[0,0,0];if(a){const e=n.pointCoordinate(h);if("globe"===n.projection.name){const i=t.latFromMercatorY(e.y),r=n.center.lat,o=Math.min(t.mercatorZfromAltitude(1,i)/t.mercatorZfromAltitude(1,r),2);a=a.rotate(-n.angle),f[0]=-a.x/n.worldSize*o,f[1]=-a.y/n.worldSize*o}else{const t=n.pointCoordinate(h.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const m=n.zoom,_=[0,0,0];if(l){const e=s(p||n.pointCoordinate3D(h)),i={dir:t.normalize([],t.sub([],e,n._camera.position))};if(i.dir[2]<0){const r=n.zoomDeltaToMovement(e,l);t.scale$2(_,i.dir,r)}}const g=t.add(f,f,_);n._translateCameraConstrained(g),l&&Math.abs(n.zoom-m)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,r,!0)}_fireEvents(e,i,r){const o=Uo(this._eventsInProgress),n=Uo(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!o&&n&&this._fireEvent("movestart",n.originalEvent);for(const t in s)this._fireEvent(t,s[t]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||r,a[`${t}end`]=l)}for(const t in a)this._fireEvent(t,a[t]);const c=Uo(this._eventsInProgress);if(r&&(o||n)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Vo("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Zo="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class $o extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,r){return e=t.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.extend({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,r){return this.easeTo(t.extend({zoom:e},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,r){return this.easeTo(t.extend({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())T=>{if(x&&(r.zoom=t.number(o,l,T)),v&&(r.bearing=t.number(n,c,T)),b&&(r.pitch=t.number(s,u,T)),w&&(r.interpolatePadding(a,h,T),d=r.centerPoint.add(p)),g)r.setLocationAtPoint(g,y);else{const t=r.zoomScale(r.zoom-o),e=l>o?Math.min(2,_):Math.max(.5,_),i=Math.pow(e,1-T),n=r.unproject(f.add(m.mult(T*i)).mult(t));r.setLocationAtPoint(r.renderWorldCopies?n.wrap():n,d)}return e.preloadOnly||this._fireMoveEvents(i),r};if(e.preloadOnly){const t=this._emulate(T,e.duration,r);return this._preloadTiles(t),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,E),this._ease(T(r),(t=>{r.recenterOnTerrain(),this._afterEase(i,t)}),e),this}_prepareEase(e,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,o=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),o&&this.fire(new t.Event("rotateend",e)),n&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(!e.essential&&t.exported.prefersReducedMotion){const r=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const r=this.transform,o=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,r.minZoom,r.maxZoom):o,c="bearing"in e?this._normalizeBearing(e.bearing,n):n,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:r.padding,p=r.zoomScale(l-o),d=t.pointGeometry.convert(e.offset);let f=r.centerPoint.add(d);const m=r.pointLocation(f),_=t.LngLat.convert(e.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=e.curve;const v=Math.max(r.width,r.height),b=v/p,w=y.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,o,l),r.minZoom,r.maxZoom),n=v/r.zoomScale(i-o);x=Math.sqrt(n/w*2)}const T=x*x;function E(t){const e=(b*b-v*v+(t?-1:1)*T*T*w*w)/(2*(t?b:v)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function C(t){return(Math.exp(t)+Math.exp(-t))/2}const M=E(0);let A=function(t){return C(M)/C(M+x*t)},I=function(t){return v*((C(M)*(S(e=M+x*t)/C(e))-S(M))/T)/w;var e},z=(E(1)-M)/x;if(Math.abs(w)<1e-6||!isFinite(z)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,i);const t=be.maxDuration&&(e.duration=0);const k=n!==c,P=u!==s,D=!r.isPaddingEqual(h),L=r=>p=>{const m=p*z,x=1/A(m);r.zoom=1===p?l:o+r.scaleZoom(x),k&&(r.bearing=t.number(n,c,p)),P&&(r.pitch=t.number(s,u,p)),D&&(r.interpolatePadding(a,h,p),f=r.centerPoint.add(d));const v=1===p?_:r.unproject(g.add(y.mult(I(m))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(i),r};if(e.preloadOnly){const t=this._emulate(L,e.duration,r);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=k,this._pitching=P,this._padding=D,this._prepareEase(i,!1),this._ease(L(r),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,r){!1===r.animate||0===r.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)180?-360:i<-180?360:0}_emulate(t,e,i){const r=Math.ceil(15*e/1e3),o=[],n=t(i.clone());for(let t=0;t<=r;t++){const e=n(t/r);o.push(e.clone())}return o}}class qo{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=n("button","mapboxgl-ctrl-attrib-button",this._container),n("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=n("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===e&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",i),t.removeAttribute("title"),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){const r=i.reduce(((t,e,r)=>(e.value&&(t+=`${e.key}=${e.value}${rt.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Xo{constructor(){t.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=n("div","mapboxgl-ctrl");const e=n("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class Wo{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ho(e,i,r){if(e=new t.LngLat(e.lng,e.lat),i){const o=new t.LngLat(e.lng-360,e.lat),n=new t.LngLat(e.lng+360,e.lat),s=360*Math.ceil(Math.abs(e.lng-r.center.lng)/360),a=r.locationPoint(e).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(o).distSqr(i)180;){const t=r.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e}const Yo={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Ko extends t.Evented{constructor(e,i){if(super(),(e instanceof t.window.HTMLElement||i)&&(e=t.extend({element:e},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),e&&e.element)this._element=e.element,this._offset=t.pointGeometry.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=n("div");const i=41,r=27,o=s("svg",{display:"block",height:i*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},o));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},o),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},o),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),this._offset=t.pointGeometry.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const r=this._element.classList;for(const t in Yo)r.remove(`mapboxgl-marker-anchor-${t}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,t._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const t=this._map;if(!t)return!1;const e=t.unproject(this._pos),i=t.getFreeCameraOptions();if(!i.position)return!1;const r=i.position.toLngLat();return r.distanceTo(e)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const i=this._pos;if(!i||i.x<0||i.x>e.transform.width||i.y<0||i.y>e.transform.height)return void this._clearFadeTimer();const r=e.unproject(i);let o;e._usingGlobe()&&t.isLngLatBehindGlobe(e.transform,this._lngLat)?o=0:(o=1-e._queryFogOpacity(r),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(o*=.2)),this._element.style.opacity=`${o}`,this._element.style.pointerEvents=o>0?"auto":"none",this._popup&&this._popup._setOpacity(o),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t||!this._map)return;const e=this._calculateXYTransform()+this._calculateZTransform(),i=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${t.x}px,${t.y}px) ${Yo[this._anchor]}\n ${e}\n translate(${i.x}px,${i.y}px)\n `}_calculateXYTransform(){const e=this._pos,i=this._map;if("map"!==this.getPitchAlignment()||!i||!e)return"";if(!i._usingGlobe()){const t=i.getPitch();return t?`rotateX(${t}deg)`:""}const r=t.radToDeg(t.globeTiltAtLngLat(i.transform,this._lngLat)),o=e.sub(t.globeCenterToScreenPoint(i.transform)),n=r/(Math.abs(o.x)+Math.abs(o.y)),s=o.x*n,a=-o.y*n;return a||s?`rotateX(${a}deg) rotateY(${s}deg)`:""}_calculateZTransform(){const t=this._calculateRotation();return t?`rotateZ(${t}deg)`:""}_calculateRotation(){if("viewport"===this._rotationAlignment||"auto"===this._rotationAlignment)return this._rotation;if(this._map&&"map"===this._rotationAlignment){const e=this._map;if(this._pos&&e&&e._usingGlobe()){const i=e.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=e.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(i);return this._rotation+t.radToDeg(Math.atan2(r.y,r.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(e){t.window.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=Ho(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===e?this._updateFrameId=t.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._usingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=t.pointGeometry.convert(e),this._update(),this}_onMove(e){const i=this._map;if(i){if(!this._isDragging){const t=this._clickTolerance||i._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(t){const e=this._map;e&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos),this._pointerdownPos=t.point,this._state="pending",e.on("mousemove",this._onMove),e.on("touchmove",this._onMove),e.once("mouseup",this._onUp),e.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;const e=this._map;return e&&(t?(e.on("mousedown",this._addDragHandler),e.on("touchstart",this._addDragHandler)):(e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class Jo{constructor(t){this.jumpTo(t)}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const i=t.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const Qo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},tn={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function en(t){t.parentNode&&t.parentNode.removeChild(t)}const rn={showCompass:!0,showZoom:!0,visualizePitch:!1};class on{constructor(e,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new go({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,r&&(this.mousePitch=new yo({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),u()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e),o=r&&r.bearingDelta;if(o&&i.setBearing(i.getBearing()+o),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e),o=r&&r.pitchDelta;o&&i.setPitch(i.getPitch()+o)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),t.window.removeEventListener("mousemove",this.mousemove),t.window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),f(this.element,e)),t.window.addEventListener("mousemove",this.mousemove),t.window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,f(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=m(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._container.style.width=t*o+"px",this._container.innerHTML=`${r} ${n}`}))}function ln(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}const cn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},un=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function hn(e=new t.pointGeometry(0,0),i="bottom"){if("number"==typeof e){const r=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(i){case"top":return new t.pointGeometry(0,e);case"top-left":return new t.pointGeometry(r,r);case"top-right":return new t.pointGeometry(-r,r);case"bottom":return new t.pointGeometry(0,-e);case"bottom-left":return new t.pointGeometry(r,-r);case"bottom-right":return new t.pointGeometry(-r,-r);case"left":return new t.pointGeometry(e,0);case"right":return new t.pointGeometry(-e,0)}return new t.pointGeometry(0,0)}return e instanceof t.pointGeometry||Array.isArray(e)?t.pointGeometry.convert(e):t.pointGeometry.convert(e[i]||[0,0])}const pn={version:t.version,supported:i,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends $o{constructor(e){if(null!=(e=t.extend({},tn,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&t.isSafariWithAntialiasingBug(t.window)&&(e.antialias=!1,t.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new qr(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._language="auto"===e.language?t.window.navigator.language:e.language,this._worldview=e.worldview,this._renderTaskQueue=new Wo,this._domRenderTaskQueue=new Wo,this._controls=[],this._markers=[],this._mapId=t.uniqueId(),this._locale=t.extend({},Qo,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Jo(0),this._explicitProjection=null,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"string"==typeof e.container){if(this._container=t.window.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof t.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&t.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t.window&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1),t.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new Go(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),this._hash=e.hash&&new Wr("string"==typeof e.hash&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,t.extend({},e.fitBoundsOptions,{duration:0})))),this.resize(),e.attributionControl&&this.addControl(new qo({customAttribution:e.customAttribution})),this._logoControl=new Xo,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new t.Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const o=this._controlPositions[i];return-1!==i.indexOf("bottom")?o.insertBefore(r,o.firstChild):o.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)),this.fire(new t.Event("resize",e)),i&&this.fire(new t.Event("moveend",e)),this}getBounds(){return"globe"===this.transform.projection.name&&t.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}getLanguage(){return this._language}setLanguage(e){if(this._language="auto"===e?t.window.navigator.language:e,this.style)for(const t in this.style._sourceCaches){const e=this.style._sourceCaches[t]._source;e._setLanguage&&e._setLanguage(this._language)}for(const t of this._controls)t._setLanguage&&t._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(t){if(this._worldview=t,this.style)for(const e in this.style._sourceCaches){const i=this.style._sourceCaches[e]._source;i._setWorldview&&i._setWorldview(t)}return this}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}_usingGlobe(){return"globe"===this.transform.projection.name}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._updateProjection(t)}_updateProjection(e){const i=this.getProjection();null===e&&(this._explicitProjection=null);const r=e||this.getProjection();let o;if(r&&"globe"===r.name&&this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?(o=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(o=this.transform.setProjection(r),this.transform.mercatorFromTransition=!1),e&&(this._explicitProjection="globe"===e.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),o){if("globe"===i.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles()}this._update(!0)}return this}project(e){return this.transform.locationPoint3D(t.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(t.pointGeometry.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const o=o=>{const n=e.filter((t=>this.getLayer(t))),s=n.length?this.queryRenderedFeatures(o.point,{layers:n}):[];s.length?r||(r=!0,i.call(this,new ro(t,this,o.originalEvent,{features:s}))):r=!1},n=()=>{r=!1};return{layers:new Set(e),listener:i,delegates:{mousemove:o,mouseout:n}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const o=o=>{const n=e.filter((t=>this.getLayer(t)));(n.length?this.queryRenderedFeatures(o.point,{layers:n}):[]).length?r=!0:r&&(r=!1,i.call(this,new ro(t,this,o.originalEvent)))},n=e=>{r&&(r=!1,i.call(this,new ro(t,this,e.originalEvent)))};return{layers:new Set(e),listener:i,delegates:{mousemove:o,mouseout:n}}}{const r=t=>{const r=e.filter((t=>this.getLayer(t))),o=r.length?this.queryRenderedFeatures(t.point,{layers:r}):[];o.length&&(t.features=o,i.call(this,t),delete t.features)};return{layers:new Set(e),listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);Array.isArray(e)||(e=[e]);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){if(void 0===i)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const r=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},o=this._delegatedListeners?this._delegatedListeners[t]:void 0;return o&&(t=>{for(let o=0;o{e?this.fire(new t.ErrorEvent(e)):r&&this._updateDiff(r,i)}))}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e)&&this._update(!0)}catch(r){t.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(t.warnOnce("There is no style added to the map."),!1)}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return!!this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,{pixelRatio:r=1,sdf:o=!1,stretchX:n,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap){const{width:l,height:c,data:u}=t.exported.getImageData(i);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},u),pixelRatio:r,stretchX:n,stretchY:s,content:a,sdf:o,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=i,u=i;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:r,stretchX:n,stretchY:s,content:a,sdf:o,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return void this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap?t.exported.getImageData(i):i,{width:n,height:s}=o;void 0!==n&&void 0!==s?n===r.data.width&&s===r.data.height?(r.data.replace(o.data,!(i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new t.ErrorEvent(new Error(`The width and height of the updated image (${n}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,i){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),((e,r)=>{i(e,r instanceof t.window.HTMLImageElement?t.exported.getImageData(r):r)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(e),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,o,n,s=this._container;for(;s&&(!o||!n);){const e=t.window.getComputedStyle(s).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(o=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(n=r[3])),s=s.parentElement}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=n?Math.abs(i/n):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&t.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=n("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=n("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=n("canvas","mapboxgl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=n("div","mapboxgl-control-container",t),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{r[t]=n("div",`mapboxgl-ctrl-${t}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,i){const r=t.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(e),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${i}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_setupPainter(){const e=t.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);r?(t.storeAuthState(r,!0),this.painter=new Dr(r,this.transform),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(e){let i;const r=this.painter.context.extTimerQuery,o=t.exported.now();if(this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let n=!1;const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=this.transform.pitch,r=t.exported.now();this.style.zoomHistory.update(e,r);const o=new t.EvaluationParameters(e,{now:r,fadeDuration:s,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=o.crossFadingFactor();1===a&&a===this._crossFadingFactor||(n=!0,this._crossFadingFactor=a),this.style.update(o)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(o),this.style._updateSources(this.transform),this._forceMarkerUpdate()):a=this._updateAverageElevation(o),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const e=t.exported.now()-o;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout((()=>{const n=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:n})),t.window.performance.mark("frame-gpu",{startTime:o,detail:{gpuTime:n}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(e);this.fire(new t.Event("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(a=this._updateAverageElevation(o,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const t of this._markers)t._update()}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),o=!1;this.transform.elevation&&(o=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=t;const n=Math.abs(e-r);if(n>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,t,300)}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===t.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;t.storeAuthState(e,!1),this._logoControl instanceof Xo&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function o(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(o(t),e.canvasCopies.map(o),e.timeStamps)}_canvasPixelComparison(t,e,i){let r=i[1]-i[0];const o=t.length/4;for(let n=0;n{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(e){const i=this.style?Object.values(this.style._sourceCaches):[];return t.asyncAll(i,((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}_setCacheLimits(e,i){t.setCacheLimits(e,i)}get version(){return t.version}},NavigationControl:class{constructor(e){this.options=t.extend({},rn,e),this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),n("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),n("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=n("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),i=e===t.getMaxZoom(),r=e===t.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new on(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const i=n("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",i),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({geolocation:t.window.navigator.geolocation},nn,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Xr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(t){return this._map=t,this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((t=>{this._supportsGeolocation="denied"!==t.state,e(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.options.geolocation,e(this._supportsGeolocation))}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return!!e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,o=this._map.getBearing(),n=t.extend({bearing:o},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),n,{geolocateSource:!0})}_updateMarker(e){if(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,i=t.mercatorZfromAltitude(1,e._center.lat)*e.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=n("button","mapboxgl-ctrl-geolocate",this._container),n("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=n("div","mapboxgl-user-location"),this._dotElement.appendChild(n("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(n("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ko({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=n("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ko({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{t.window.addEventListener("ondeviceorientationabsolute"in t.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==t.window.DeviceMotionEvent&&"function"==typeof t.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.window.removeEventListener("deviceorientation",this._onDeviceOrientation),t.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:qo,ScaleControl:class{constructor(e){this.options=t.extend({},sn,e),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(t){return!1}}()||(this._setScale=an.bind(this)),t.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const t=this.options.maxWidth||100,e=this._map,i=e._containerHeight/2,r=e._containerWidth/2-t/2,o=e.unproject([r,i]),n=e.unproject([r+t,i]),s=o.distanceTo(n);if("imperial"===this.options.unit){const e=3.2808*s;e>5280?this._setScale(t,e/5280,"mile"):this._setScale(t,e,"foot")}else"nautical"===this.options.unit?this._setScale(t,s/1852,"nautical-mile"):s>=1e3?this._setScale(t,s/1e3,"kilometer"):this._setScale(t,s,"meter")}_setScale(t,e,i){const r=ln(e),o=r/e;this._map._requestDomTask((()=>{this._container.style.width=t*o+"px",this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:i}).format(r):`${r} nm`}))}onAdd(t){return this._map=t,this._language=t.getLanguage(),this._container=n("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(t){this._language=t,this._update()}setUnit(t){this.options.unit=t,this._update()}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.window.HTMLElement?this._container=e.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=n("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=n("button","mapboxgl-ctrl-fullscreen",this._controlContainer);n("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(cn),e),t.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.window.document.createTextNode(e))}setHTML(e){const i=t.window.document.createDocumentFragment(),r=t.window.document.createElement("body");let o;for(r.innerHTML=e;o=r.firstChild,o;)i.appendChild(o);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=n("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=n("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="×",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,i=this._container,r=this._pos;if(!e||!i||!r)return"bottom";const o=i.offsetWidth,n=i.offsetHeight,s=r.xe.transform.width-o/2;if(r.y+te.transform.height-n){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(e){const i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let o=this._container;if(o||(o=this._container=n("div","mapboxgl-popup",i.getContainer()),this._tip=n("div","mapboxgl-popup-tip",o),o.appendChild(r)),this.options.maxWidth&&o.style.maxWidth!==this.options.maxWidth&&(o.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ho(this._lngLat,this._pos,i.transform)),!this._trackPointer||e){const t=this._pos=this._trackPointer&&e?e:i.project(this._lngLat),r=hn(this.options.offset),o=this._anchor=this._getAnchor(r.y),n=hn(this.options.offset,o),s=t.add(n).round();i._requestDomTask((()=>{this._container&&o&&(this._container.style.transform=`${Yo[o]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._usingGlobe()){const e=t.isLngLatBehindGlobe(i.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(un);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._container&&(this._container.style.opacity=`${t}`),this._content&&(this._content.style.pointerEvents=t?"auto":"none")}},Marker:Ko,Style:ti,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.pointGeometry,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:Or,Evented:t.Evented,config:t.config,prewarm:function(){jt().acquire(Ot)},clearPrewarmedResources:function(){const t=Vt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Ot),Vt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(e){t.config.ACCESS_TOKEN=e},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(e){t.config.API_URL=e},get workerCount(){return Ut.workerCount},set workerCount(t){Ut.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return pn})),i}()},155:t=>{var e,i,r=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===o||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(i){try{return e.call(null,t,0)}catch(i){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:o}catch(t){e=o}try{i="function"==typeof clearTimeout?clearTimeout:n}catch(t){i=n}}();var a,l=[],c=!1,u=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):u=-1,l.length&&p())}function p(){if(!c){var t=s(h);c=!0;for(var e=l.length;e;){for(a=l,l=[];++u1)for(var i=1;i{"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},n=function(){var t={};return function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}t[e]=i}return t[e]}}(),s=[];function a(t){for(var e=-1,i=0;i{"use strict";e.Z=(t,e)=>{const i=t.__vccOpts||t;for(const[t,r]of e)i[t]=r;return i}}},e={};function i(r){var o=e[r];if(void 0!==o)return o.exports;var n=e[r]={id:r,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.nc=void 0,(()=>{"use strict";const t=Vue;var e=function(e){return(0,t.pushScopeId)("data-v-2055c4ea"),e=e(),(0,t.popScopeId)(),e}((function(){return(0,t.createElementVNode)("div",{id:"mapContainer",class:"basemap"},null,-1)}));var r=i(158),o=i.n(r);const n={props:["index","resource","resourceName","resourceId","field"],data:function(){return{map:null,draw:null,geoJsonSource:{type:"geojson",data:{type:"Feature",geometry:this.field.geoJson}}}},mounted:function(){var t=this;o().accessToken=this.field.accessToken;var e=this.field.longitude,i=this.field.latitude,r={container:"mapContainer",style:"mapbox://styles/mapbox/streets-v11",center:[e,i],zoom:this.field.zoom||10};this.map=new(o().Map)(r),this.map.addControl(new(o().NavigationControl)({showCompass:!1}),"top-left"),this.map.on("load",(function(){t.map.addSource("layer",t.geoJsonSource),t.map.addLayer({id:"layer",type:"fill",source:"layer",layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5}}),(new(o().Marker)).setLngLat([e,i]).addTo(t.map)}))}};var s=i(379),a=i.n(s),l=i(349),c={insert:"head",singleton:!1};a()(l.Z,c);l.Z.locals;const u=(0,i(744).Z)(n,[["render",function(i,r,o,n,s,a){var l=(0,t.resolveComponent)("PanelItem");return(0,t.openBlock)(),(0,t.createBlock)(l,{index:o.index,field:o.field},{value:(0,t.withCtx)((function(){return[e]})),_:1},8,["index","field"])}],["__scopeId","data-v-2055c4ea"]]);Nova.booting((function(t,e){t.component("detail-nova-mapbox-marker-field",u)}))})()})(); \ No newline at end of file diff --git a/resources/js/components/DetailField.vue b/resources/js/components/DetailField.vue index 310ef04..305090e 100644 --- a/resources/js/components/DetailField.vue +++ b/resources/js/components/DetailField.vue @@ -69,6 +69,6 @@ export default { @import "~mapbox-gl/dist/mapbox-gl.css"; #mapContainer { - height: 600px; + height: 450px; }