diff --git a/assets/data/cdn/jsdelivr.yml b/assets/data/cdn/jsdelivr.yml index d4747fee..394f7f74 100644 --- a/assets/data/cdn/jsdelivr.yml +++ b/assets/data/cdn/jsdelivr.yml @@ -44,9 +44,9 @@ libFiles: lightgalleryJS: lightgallery@2.9.0/lightgallery.min.js lightgalleryThumbnailJS: lightgallery@2.9.0/plugins/thumbnail/lg-thumbnail.min.js lightgalleryZoomJS: lightgallery@2.9.0/plugins/zoom/lg-zoom.min.js - # mapbox-gl@3.25.0 https://docs.mapbox.com/mapbox-gl-js - mapboxGLCSS: mapbox-gl@3.25.0/dist/mapbox-gl.css - mapboxGLJS: mapbox-gl@3.25.0/dist/mapbox-gl.js + # mapbox-gl@3.27.0 https://docs.mapbox.com/mapbox-gl-js + mapboxGLCSS: mapbox-gl@3.27.0/dist/mapbox-gl.css + mapboxGLJS: mapbox-gl@3.27.0/dist/mapbox-gl.js # meting@2.0.2 https://github.com/metowolf/MetingJS metingJS: meting@2.0.2/dist/Meting.min.js # object-fit-images@3.2.4 https://github.com/fregante/object-fit-images diff --git a/assets/data/cdn/unpkg.yml b/assets/data/cdn/unpkg.yml index 48f1c6af..6a46e61f 100644 --- a/assets/data/cdn/unpkg.yml +++ b/assets/data/cdn/unpkg.yml @@ -44,9 +44,9 @@ libFiles: lightgalleryJS: lightgallery@2.9.0/lightgallery.min.js lightgalleryThumbnailJS: lightgallery@2.9.0/plugins/thumbnail/lg-thumbnail.min.js lightgalleryZoomJS: lightgallery@2.9.0/plugins/zoom/lg-zoom.min.js - # mapbox-gl@3.25.0 https://docs.mapbox.com/mapbox-gl-js - mapboxGLCSS: mapbox-gl@3.25.0/dist/mapbox-gl.css - mapboxGLJS: mapbox-gl@3.25.0/dist/mapbox-gl.js + # mapbox-gl@3.27.0 https://docs.mapbox.com/mapbox-gl-js + mapboxGLCSS: mapbox-gl@3.27.0/dist/mapbox-gl.css + mapboxGLJS: mapbox-gl@3.27.0/dist/mapbox-gl.js # meting@2.0.2 https://github.com/metowolf/MetingJS metingJS: meting@2.0.2/dist/Meting.min.js # object-fit-images@3.2.4 https://github.com/fregante/object-fit-images diff --git a/assets/lib/mapbox-gl/mapbox-gl.css b/assets/lib/mapbox-gl/mapbox-gl.css index f7d6eecc..84ea4665 100644 --- a/assets/lib/mapbox-gl/mapbox-gl.css +++ b/assets/lib/mapbox-gl/mapbox-gl.css @@ -1 +1 @@ -.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,.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-left,.mapboxgl-ctrl-right,.mapboxgl-ctrl-top,.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{top:0;left:50%;transform:translateX(-50%)}.mapboxgl-ctrl-top-right{top:0;right:0}.mapboxgl-ctrl-right{top:50%;transform:translateY(-50%);right:0}.mapboxgl-ctrl-bottom-right{right:0;bottom:0}.mapboxgl-ctrl-bottom{bottom:0;left:50%;transform:translateX(-50%)}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-left{top:50%;transform:translateY(-50%);left: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 .mapboxgl-ctrl{margin:10px 0;float:left}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{margin:10px 10px 0 0;float:right}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl,.mapboxgl-ctrl-right .mapboxgl-ctrl{margin:0 10px 10px 0;float:right}.mapboxgl-ctrl-bottom .mapboxgl-ctrl{margin:10px 0;float:left}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,.mapboxgl-ctrl-left .mapboxgl-ctrl{margin:0 0 10px 10px;float:left}.mapboxgl-ctrl-group{border-radius:4px;background:#fff}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px #0000001a}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{width:32px;height:32px;display:block;padding:0;outline:none;border:0;box-sizing:border-box;background-color:initial;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:initial}.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 #0096ff}.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:#eee}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-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 xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%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-arrow-up .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23333' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.29289 11.7071C4.68342 12.0976 5.31658 12.0976 5.70711 11.7071L9 8.41421L12.2929 11.7071C12.6834 12.0976 13.3166 12.0976 13.7071 11.7071C14.0976 11.3166 14.0976 10.6834 13.7071 10.2929L9.70711 6.29289C9.31658 5.90237 8.68342 5.90237 8.29289 6.29289L4.29289 10.2929C3.90237 10.6834 3.90237 11.3166 4.29289 11.7071Z' fill='%23333333'/%3E%3C/svg%3E");background-size:18px 18px}.mapboxgl-ctrl button.mapboxgl-ctrl-arrow-down .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23333' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.29289 6.29289C4.68342 5.90237 5.31658 5.90237 5.70711 6.29289L9 9.58579L12.2929 6.29289C12.6834 5.90237 13.3166 5.90237 13.7071 6.29289C14.0976 6.68342 14.0976 7.31658 13.7071 7.70711L9.70711 11.7071C9.31658 12.0976 8.68342 12.0976 8.29289 11.7071L4.29289 7.70711C3.90237 7.31658 3.90237 6.68342 4.29289 6.29289Z' fill='%23333333'/%3E%3C/svg%3E");background-size:18px 18px}.mapboxgl-ctrl button.mapboxgl-ctrl-indoor-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23333' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.0017 3.0017L4.0017 15.0017L10.0017 15.0017V12.0017H12.0017V15.0017H14.0017L14.0017 3.0017C14.0097 2.86829 13.9894 2.73469 13.9419 2.60973C13.8945 2.48477 13.8211 2.37129 13.7266 2.27678C13.6321 2.18228 13.5186 2.10889 13.3937 2.06147C13.2687 2.01405 13.1351 1.99368 13.0017 2.0017L5.0017 2.0017C4.86829 1.99368 4.73469 2.01405 4.60973 2.06147C4.48477 2.10889 4.37129 2.18228 4.27678 2.27678C4.18228 2.37129 4.10889 2.48477 4.06147 2.60973C4.01405 2.73469 3.99368 2.86829 4.0017 3.0017ZM8.0017 14.0017H6.0017V12.0017H8.0017V14.0017ZM8.0017 10.0017H6.0017L6.0017 8.0017H8.0017V10.0017ZM8.0017 6.0017L6.0017 6.0017V4.0017H8.0017V6.0017ZM12.0017 10.0017H10.0017V8.0017H12.0017V10.0017ZM12.0017 6.0017H10.0017V4.0017L12.0017 4.0017V6.0017Z' fill='%23333333'/%3E%3C/svg%3E");background-size:18px 18px}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-indoor-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23fff' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.0017 3.0017L4.0017 15.0017L10.0017 15.0017V12.0017H12.0017V15.0017H14.0017L14.0017 3.0017C14.0097 2.86829 13.9894 2.73469 13.9419 2.60973C13.8945 2.48477 13.8211 2.37129 13.7266 2.27678C13.6321 2.18228 13.5186 2.10889 13.3937 2.06147C13.2687 2.01405 13.1351 1.99368 13.0017 2.0017L5.0017 2.0017C4.86829 1.99368 4.73469 2.01405 4.60973 2.06147C4.48477 2.10889 4.37129 2.18228 4.27678 2.27678C4.18228 2.37129 4.10889 2.48477 4.06147 2.60973C4.01405 2.73469 3.99368 2.86829 4.0017 3.0017ZM8.0017 14.0017H6.0017V12.0017H8.0017V14.0017ZM8.0017 10.0017H6.0017L6.0017 8.0017H8.0017V10.0017ZM8.0017 6.0017L6.0017 6.0017V4.0017H8.0017V6.0017ZM12.0017 10.0017H10.0017V8.0017H12.0017V10.0017ZM12.0017 6.0017H10.0017V4.0017L12.0017 4.0017V6.0017Z' fill='%23333333'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-indoor-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23000' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.0017 3.0017L4.0017 15.0017L10.0017 15.0017V12.0017H12.0017V15.0017H14.0017L14.0017 3.0017C14.0097 2.86829 13.9894 2.73469 13.9419 2.60973C13.8945 2.48477 13.8211 2.37129 13.7266 2.27678C13.6321 2.18228 13.5186 2.10889 13.3937 2.06147C13.2687 2.01405 13.1351 1.99368 13.0017 2.0017L5.0017 2.0017C4.86829 1.99368 4.73469 2.01405 4.60973 2.06147C4.48477 2.10889 4.37129 2.18228 4.27678 2.27678C4.18228 2.37129 4.10889 2.48477 4.06147 2.60973C4.01405 2.73469 3.99368 2.86829 4.0017 3.0017ZM8.0017 14.0017H6.0017V12.0017H8.0017V14.0017ZM8.0017 10.0017H6.0017L6.0017 8.0017H8.0017V10.0017ZM8.0017 6.0017L6.0017 6.0017V4.0017H8.0017V6.0017ZM12.0017 10.0017H10.0017V8.0017H12.0017V10.0017ZM12.0017 6.0017H10.0017V4.0017L12.0017 4.0017V6.0017Z' fill='%23333333'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg 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 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='%23f00'/%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 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 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 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 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 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 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='%23f00'/%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 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 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 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 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 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 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='%23f00'/%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 xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%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:initial;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%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 xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%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:#ffffff80;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;box-sizing:initial}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}:is(.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-left,.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 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:#ffffff80;width:24px;height:24px;box-sizing:border-box;border-radius:12px;outline:none;top:0;right:0;border:0}:is(.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-left,.mapboxgl-ctrl-top-left) .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:#0000000d}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{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}.mapboxgl-ctrl-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{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 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 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:#000000bf;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:#ffffffbf;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 #0000;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:initial}.mapboxgl-popup-close-button:hover{background-color:#eee}.mapboxgl-popup-content{position:relative;background:#fff;border-radius:3px;box-shadow:0 1px 2px #0000001a;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 #00000059}.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 #0000;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid #0000;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:#1da1f233;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:#000000b3;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}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button{font-weight:600;font-size:14px;text-align:center}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button-selected{background-color:#bccbd7;color:#000}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button-selected:hover{background-color:#ccc} \ No newline at end of file +.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,.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-left,.mapboxgl-ctrl-right,.mapboxgl-ctrl-top,.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{top:0;left:50%;transform:translateX(-50%)}.mapboxgl-ctrl-top-right{top:0;right:0}.mapboxgl-ctrl-right{top:50%;transform:translateY(-50%);right:0}.mapboxgl-ctrl-bottom-right{right:0;bottom:0}.mapboxgl-ctrl-bottom{bottom:0;left:50%;transform:translateX(-50%)}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-left{top:50%;transform:translateY(-50%);left:0}.mapboxgl-ctrl{clear:both;pointer-events:auto}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:10px 0 0 10px;float:left}.mapboxgl-ctrl-top .mapboxgl-ctrl{margin:10px 0;float:left}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{margin:10px 10px 0 0;float:right}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl,.mapboxgl-ctrl-right .mapboxgl-ctrl{margin:0 10px 10px 0;float:right}.mapboxgl-ctrl-bottom .mapboxgl-ctrl{margin:10px 0;float:left}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,.mapboxgl-ctrl-left .mapboxgl-ctrl{margin:0 0 10px 10px;float:left}.mapboxgl-ctrl-group{border-radius:4px;background:#fff}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px #0000001a}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{width:32px;height:32px;display:block;padding:0;outline:none;border:0;box-sizing:border-box;background-color:initial;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:initial}.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 #0096ff}.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:#eee}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-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 xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-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 xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%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 xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%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 xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%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-arrow-up .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23333' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.29289 11.7071C4.68342 12.0976 5.31658 12.0976 5.70711 11.7071L9 8.41421L12.2929 11.7071C12.6834 12.0976 13.3166 12.0976 13.7071 11.7071C14.0976 11.3166 14.0976 10.6834 13.7071 10.2929L9.70711 6.29289C9.31658 5.90237 8.68342 5.90237 8.29289 6.29289L4.29289 10.2929C3.90237 10.6834 3.90237 11.3166 4.29289 11.7071Z' fill='%23333333'/%3E%3C/svg%3E");background-size:18px 18px}.mapboxgl-ctrl button.mapboxgl-ctrl-arrow-down .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23333' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M4.29289 6.29289C4.68342 5.90237 5.31658 5.90237 5.70711 6.29289L9 9.58579L12.2929 6.29289C12.6834 5.90237 13.3166 5.90237 13.7071 6.29289C14.0976 6.68342 14.0976 7.31658 13.7071 7.70711L9.70711 11.7071C9.31658 12.0976 8.68342 12.0976 8.29289 11.7071L4.29289 7.70711C3.90237 7.31658 3.90237 6.68342 4.29289 6.29289Z' fill='%23333333'/%3E%3C/svg%3E");background-size:18px 18px}.mapboxgl-ctrl button.mapboxgl-ctrl-indoor-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23333' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.0017 3.0017L4.0017 15.0017L10.0017 15.0017V12.0017H12.0017V15.0017H14.0017L14.0017 3.0017C14.0097 2.86829 13.9894 2.73469 13.9419 2.60973C13.8945 2.48477 13.8211 2.37129 13.7266 2.27678C13.6321 2.18228 13.5186 2.10889 13.3937 2.06147C13.2687 2.01405 13.1351 1.99368 13.0017 2.0017L5.0017 2.0017C4.86829 1.99368 4.73469 2.01405 4.60973 2.06147C4.48477 2.10889 4.37129 2.18228 4.27678 2.27678C4.18228 2.37129 4.10889 2.48477 4.06147 2.60973C4.01405 2.73469 3.99368 2.86829 4.0017 3.0017ZM8.0017 14.0017H6.0017V12.0017H8.0017V14.0017ZM8.0017 10.0017H6.0017L6.0017 8.0017H8.0017V10.0017ZM8.0017 6.0017L6.0017 6.0017V4.0017H8.0017V6.0017ZM12.0017 10.0017H10.0017V8.0017H12.0017V10.0017ZM12.0017 6.0017H10.0017V4.0017L12.0017 4.0017V6.0017Z' fill='%23333333'/%3E%3C/svg%3E");background-size:18px 18px}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-indoor-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23fff' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.0017 3.0017L4.0017 15.0017L10.0017 15.0017V12.0017H12.0017V15.0017H14.0017L14.0017 3.0017C14.0097 2.86829 13.9894 2.73469 13.9419 2.60973C13.8945 2.48477 13.8211 2.37129 13.7266 2.27678C13.6321 2.18228 13.5186 2.10889 13.3937 2.06147C13.2687 2.01405 13.1351 1.99368 13.0017 2.0017L5.0017 2.0017C4.86829 1.99368 4.73469 2.01405 4.60973 2.06147C4.48477 2.10889 4.37129 2.18228 4.27678 2.27678C4.18228 2.37129 4.10889 2.48477 4.06147 2.60973C4.01405 2.73469 3.99368 2.86829 4.0017 3.0017ZM8.0017 14.0017H6.0017V12.0017H8.0017V14.0017ZM8.0017 10.0017H6.0017L6.0017 8.0017H8.0017V10.0017ZM8.0017 6.0017L6.0017 6.0017V4.0017H8.0017V6.0017ZM12.0017 10.0017H10.0017V8.0017H12.0017V10.0017ZM12.0017 6.0017H10.0017V4.0017L12.0017 4.0017V6.0017Z' fill='%23333333'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-indoor-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='%23000' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.0017 3.0017L4.0017 15.0017L10.0017 15.0017V12.0017H12.0017V15.0017H14.0017L14.0017 3.0017C14.0097 2.86829 13.9894 2.73469 13.9419 2.60973C13.8945 2.48477 13.8211 2.37129 13.7266 2.27678C13.6321 2.18228 13.5186 2.10889 13.3937 2.06147C13.2687 2.01405 13.1351 1.99368 13.0017 2.0017L5.0017 2.0017C4.86829 1.99368 4.73469 2.01405 4.60973 2.06147C4.48477 2.10889 4.37129 2.18228 4.27678 2.27678C4.18228 2.37129 4.10889 2.48477 4.06147 2.60973C4.01405 2.73469 3.99368 2.86829 4.0017 3.0017ZM8.0017 14.0017H6.0017V12.0017H8.0017V14.0017ZM8.0017 10.0017H6.0017L6.0017 8.0017H8.0017V10.0017ZM8.0017 6.0017L6.0017 6.0017V4.0017H8.0017V6.0017ZM12.0017 10.0017H10.0017V8.0017H12.0017V10.0017ZM12.0017 6.0017H10.0017V4.0017L12.0017 4.0017V6.0017Z' fill='%23333333'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg 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 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='%23f00'/%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 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 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 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 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 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 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='%23f00'/%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 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 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 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 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 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 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='%23f00'/%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 xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%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:initial;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%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 xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%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:#ffffff80;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;box-sizing:initial}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}:is(.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-left,.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 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:#ffffff80;width:24px;height:24px;box-sizing:border-box;border-radius:12px;outline:none;top:0;right:0;border:0}:is(.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-left,.mapboxgl-ctrl-top-left) .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:#0000000d}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{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}.mapboxgl-ctrl-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{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 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 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:#000000bf;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:#ffffffbf;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 #0000;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:initial}.mapboxgl-popup-close-button:hover{background-color:#eee}.mapboxgl-popup-content{position:relative;background:#fff;border-radius:3px;box-shadow:0 1px 2px #0000001a;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 #00000059}.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 #0000;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid #0000;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:#1da1f233;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:#000000b3;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}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button{font-weight:600;font-size:14px;text-align:center}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button-selected{background-color:#bccbd7;color:#000}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button-selected:hover{background-color:#ccc} \ No newline at end of file diff --git a/assets/lib/mapbox-gl/mapbox-gl.js b/assets/lib/mapbox-gl/mapbox-gl.js index 2b12f38c..88695beb 100644 --- a/assets/lib/mapbox-gl/mapbox-gl.js +++ b/assets/lib/mapbox-gl/mapbox-gl.js @@ -5,20 +5,40 @@ typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory()); })(this, (function () { 'use strict'; -let shared,worker,mapboxgl;function define(o,e){if(!shared)shared=e;else if(!worker)worker=e;else{const r={};shared(void 0,r),mapboxgl=e(r);const n="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+shared+")(undefined, sharedChunk); ("+worker+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(mapboxgl.workerUrl=window.URL.createObjectURL(new Blob([n],{type:"text/javascript"})))}} +let shared, worker, mapboxgl; +if (typeof self !== "undefined") self.__mapboxImport = (u) => import( + /* webpackIgnore: true */ + /* @vite-ignore */ + u +); +function define(_, chunk) { + if (!shared) { + shared = chunk; + } else if (!worker) { + worker = chunk; + } else { + const sharedChunk = {}; + shared(void 0, sharedChunk); + mapboxgl = chunk(sharedChunk); + const workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; self.__mapboxImport = (u) => import(u); (" + shared + ")(undefined, sharedChunk); (" + worker + ")(undefined, sharedChunk); self.onerror = null;"; + if (typeof window !== "undefined" && window && window.URL && window.URL.createObjectURL) { + mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: "text/javascript" })); + } + } +} -define(["require","exports"],function(e,t){var r=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*s-i*n;return a?(e[0]=s*(a=1/a),e[1]=-n*a,e[2]=-i*a,e[3]=r*a,e):null}function s(){var e=new n(9);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function a(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-o*u,e[1]=i*u-n*c,e[2]=n*o-i*a,e[3]=o*l-s*c,e[4]=r*c-i*l,e[5]=i*s-r*o,e[6]=s*u-a*l,e[7]=n*l-r*u,e[8]=r*a-n*s,e}function o(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=r[0],p=r[1],f=r[2],m=r[3],y=r[4],g=r[5],x=r[6],b=r[7],v=r[8];return e[0]=d*n+p*a+f*u,e[1]=d*i+p*o+f*c,e[2]=d*s+p*l+f*h,e[3]=m*n+y*a+g*u,e[4]=m*i+y*o+g*c,e[5]=m*s+y*l+g*h,e[6]=x*n+b*a+v*u,e[7]=x*i+b*o+v*c,e[8]=x*s+b*l+v*h,e}function l(){var e=new n(16);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function u(e){var t=new n(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function c(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function h(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],y=t[14],g=t[15],x=r*o-n*a,b=r*l-i*a,v=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,I=c*m-h*f,M=c*y-d*f,S=c*g-p*f,B=h*y-d*m,T=h*g-p*m,P=d*g-p*y,z=x*P-b*T+v*B+w*S-_*M+A*I;return z?(e[0]=(o*P-l*T+u*B)*(z=1/z),e[1]=(i*T-n*P-s*B)*z,e[2]=(m*A-y*_+g*w)*z,e[3]=(d*_-h*A-p*w)*z,e[4]=(l*S-a*P-u*M)*z,e[5]=(r*P-i*S+s*M)*z,e[6]=(y*v-f*A-g*b)*z,e[7]=(c*A-d*v+p*b)*z,e[8]=(a*T-o*S+u*I)*z,e[9]=(n*S-r*T-s*I)*z,e[10]=(f*_-m*v+g*x)*z,e[11]=(h*v-c*_-p*x)*z,e[12]=(o*M-a*B-l*I)*z,e[13]=(r*B-n*M+i*I)*z,e[14]=(m*b-f*w-y*x)*z,e[15]=(c*w-h*b+d*x)*z,e):null}function d(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],y=t[13],g=t[14],x=t[15],b=r[0],v=r[1],w=r[2],_=r[3];return e[0]=b*n+v*o+w*h+_*m,e[1]=b*i+v*l+w*d+_*y,e[2]=b*s+v*u+w*p+_*g,e[3]=b*a+v*c+w*f+_*x,e[4]=(b=r[4])*n+(v=r[5])*o+(w=r[6])*h+(_=r[7])*m,e[5]=b*i+v*l+w*d+_*y,e[6]=b*s+v*u+w*p+_*g,e[7]=b*a+v*c+w*f+_*x,e[8]=(b=r[8])*n+(v=r[9])*o+(w=r[10])*h+(_=r[11])*m,e[9]=b*i+v*l+w*d+_*y,e[10]=b*s+v*u+w*p+_*g,e[11]=b*a+v*c+w*f+_*x,e[12]=(b=r[12])*n+(v=r[13])*o+(w=r[14])*h+(_=r[15])*m,e[13]=b*i+v*l+w*d+_*y,e[14]=b*s+v*u+w*p+_*g,e[15]=b*a+v*c+w*f+_*x,e}function p(e,t,r){var n,i,s,a,o,l,u,c,h,d,p,f,m=r[0],y=r[1],g=r[2];return t===e?(e[12]=t[0]*m+t[4]*y+t[8]*g+t[12],e[13]=t[1]*m+t[5]*y+t[9]*g+t[13],e[14]=t[2]*m+t[6]*y+t[10]*g+t[14],e[15]=t[3]*m+t[7]*y+t[11]*g+t[15]):(i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=i,e[2]=s,e[3]=a,e[4]=o,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+o*y+h*g+t[12],e[13]=i*m+l*y+d*g+t[13],e[14]=s*m+u*y+p*g+t[14],e[15]=a*m+c*y+f*g+t[15]),e}function f(e,t,r){var n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function m(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[4],a=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+u*n,e[5]=a*i+c*n,e[6]=o*i+h*n,e[7]=l*i+d*n,e[8]=u*i-s*n,e[9]=c*i-a*n,e[10]=h*i-o*n,e[11]=d*i-l*n,e}function y(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-u*n,e[1]=a*i-c*n,e[2]=o*i-h*n,e[3]=l*i-d*n,e[8]=s*n+u*i,e[9]=a*n+c*i,e[10]=o*n+h*i,e[11]=l*n+d*i,e}function g(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=s*i+u*n,e[1]=a*i+c*n,e[2]=o*i+h*n,e[3]=l*i+d*n,e[4]=u*i-s*n,e[5]=c*i-a*n,e[6]=h*i-o*n,e[7]=d*i-l*n,e}function x(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function b(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function v(e,t,n){var i,s,a,o=n[0],l=n[1],u=n[2],c=Math.sqrt(o*o+l*l+u*u);return c0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function N(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function j(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[0],o=r[1],l=r[2];return e[0]=i*l-s*o,e[1]=s*a-n*l,e[2]=n*o-i*a,e}function G(e,t,r,n){var i=t[0],s=t[1],a=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e}function $(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,e}function q(e,t,r){var n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function H(e,t,r){var n=r[0],i=r[1],s=r[2],a=r[3],o=t[0],l=t[1],u=t[2],c=i*u-s*l,h=s*o-n*u,d=n*l-i*o;return e[0]=o+a*(c+=c)+i*(d+=d)-s*(h+=h),e[1]=l+a*h+s*c-n*d,e[2]=u+a*d+n*h-i*c,e}function X(e){return e[0]=0,e[1]=0,e[2]=0,e}function Z(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var W=z,Y=E,K=S;function J(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Q(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function ee(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*r+n*n+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=i*a,e[3]=s*a,e}function te(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*a,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*a,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*a,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*a,e}function re(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ne(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ie(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+a*o,e[1]=i*l+s*o,e[2]=s*l-i*o,e[3]=a*l-n*o,e}function se(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l-s*o,e[1]=i*l+a*o,e[2]=s*l+n*o,e[3]=a*l-i*o,e}I(),J();var ae,oe,le,ue=ee,ce=(ae=I(),oe=B(1,0,0),le=B(0,1,0),function(e,t,r){var n=N(t,r);return n<-.999999?(j(ae,oe,t),K(ae)<1e-6&&j(ae,le,t),U(ae,ae),function(e,t,r){r*=.5;var n=Math.sin(r);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r);}(e,ae,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(j(ae,t,r),e[0]=ae[0],e[1]=ae[1],e[2]=ae[2],e[3]=1+n,ue(e,e))});function he(){var e=new n(2);return n!=Float32Array&&(e[0]=0,e[1]=0),e}function de(e,t){var r=new n(2);return r[0]=e,r[1]=t,r}function pe(e,t,r){return e[0]=t,e[1]=r,e}function fe(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function me(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function ye(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function ge(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function xe(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function be(e,t){return e[0]*t[0]+e[1]*t[1]}re(),re(),s();var ve=me;function we(e,t,r,n){const i=3*e,s=3*(r-e)-i,a=1-i-s,o=3*t,l=3*(n-t)-o,u=1-o-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let r=e;for(let n=0;n<8;n++){const n=((a*r+s)*r+i)*r-e;if(Math.abs(n)o?n=r:c=r,r=.5*(n+c);}return ((u*r+l)*r+o)*r}}function _e(e,t){this.x=e,this.y=t;}function Ae(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return !1;for(let r=0;rr;){if(n-r>600){const s=n-r+1,a=t-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Ie(e,t,Math.max(r,Math.floor(t-a*l/s+u)),Math.min(n,Math.floor(t+(s-a)*l/s+u)),i);}const s=e[t];let a=r,o=n;for(Me(e,r,t),i(e[n],s)>0&&Me(e,r,n);a0;)o--;}0===i(e[r],s)?Me(e,r,o):(o++,Me(e,o,n)),o<=t&&(r=o+1),t<=o&&(n=o-1);}}function Me(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function Se(e,t){return et?1:0}function Be(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i1)for(let e=0;e=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ke(e,t,r){const n=e[0]-t[0],i=e[1]-t[1],s=e[0]-r[0],a=e[1]-r[1];return n*a-s*i===0&&n*s<=0&&i*a<=0}function Ve(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function Fe(e,t,r=!1){let n=!1;for(let i=0,s=t.length;i0&&o<0||a<0&&o>0}function Ce(e,t,r,n){return 0!==(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*s[0]&&!(!De(e,t,r,n)||!De(r,n,e,t));var i,s;}function Re(e){const t=new _e(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new _e(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),r.x=1)return 1;const t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}const Xe=we(.25,.1,.25,1);function Ze(e,t,r){return Math.min(r,Math.max(t,e))}function We(e,t,r){return (r=Ze((r-e)/(t-e),0,1))*r*(3-2*r)}function Ye(e,t,r){const n=r-t,i=((e-t)%n+n)%n+t;return i===t?r:i}function Ke(e,t,r){if(!e.length)return r(null,[]);let n=e.length;const i=new Array(e.length);let s=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(s=e),i[a]=t,0===--n&&r(s,i);});});}function Je(e,t){const r={};for(let n=0;n{t[e]&&(t[e]=t[e].bind(t));});}function nt(e,t,r){const n={};for(const r in e)n[r]=t.call(this,e[r],r,e);return n}function it(e,t,r){const n={};for(const r in e)t.call(this,e[r],r,e)&&(n[r]=e[r]);return n}function st(e){return Array.isArray(e)?e.map(st):"object"==typeof e&&e?nt(e,st):e}function at(e,t){for(let r=0;r(t.y-e.y)*(r.x-e.x)}function ct([e,t,r]){const n=Ge(t+90),i=Ge(r);return {x:e*Math.cos(n)*Math.sin(i),y:e*Math.sin(n)*Math.sin(i),z:e*Math.cos(i),azimuthal:t,polar:r}}function ht(e){return ("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function dt(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,n,i)=>{const s=n||i;return t[r]=!s||s.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e;}return t}let pt,ft,mt,yt,gt,xt,bt,vt=null;function wt(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function _t(e,t,r,n){for(;t>1;e[i]>1;e[i]<=n?t=i+1:r=i;}return t}function It(e){return e>0?1/(1.001-e):1+e}function Mt(e){return e>0?1-1/(1.001-e):-e}function St(e,t,r){return (e-t.min)*(r.max-r.min)/(t.max-t.min)+r.min}function Bt(){return null==ft&&(ft=self.OffscreenCanvas&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),ft}const Tt={requestIdleCallback:e=>{if("undefined"!=typeof requestIdleCallback)return requestIdleCallback(e);setTimeout(()=>e({didTimeout:!1,timeRemaining:()=>50}),0);},now:()=>void 0!==gt?gt:performance.now(),setNow(e){gt=e;},restoreNow(){gt=void 0;},frame(e){const t=requestAnimationFrame(e);return {cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:n}=e;xt||(xt=document.createElement("canvas"));const i=xt.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>xt.width||n>xt.height)&&(xt.width=r,xt.height=n),i.clearRect(-t,-t,r+2*t,n+2*t),i.drawImage(e,0,0,r,n),i.getImageData(-t,-t,r+2*t,n+2*t)},resolveURL:e=>(mt||(mt=document.createElement("a")),mt.href=e,mt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==yt&&(yt=window.matchMedia("(prefers-reduced-motion: reduce)")),yt.matches)},hasCanvasFingerprintNoise(){if(void 0!==bt)return bt;if(!Bt())return bt=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n0?`?${s}`:""}`}const Rt="mapbox-tiles";let Lt=500,Ot=50;const Ut=["language","worldview","jobid"];let Nt;function jt(){try{return caches}catch(e){}}function Gt(){const e=jt();e&&null==Nt&&(Nt=e.open(Rt));}let $t=1/0;const qt={supported:!1,testSupport:function(e){!Zt&&Xt&&(Wt?Kt(e):Ht=e);}};let Ht,Xt,Zt=!1,Wt=!1;const Yt="undefined"!=typeof self?self:{};function Kt(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,Xt),e.isContextLost())return;qt.supported=!0;}catch(e){}e.deleteTexture(t),Zt=!0;}Yt.document&&(Xt=Yt.document.createElement("img"),Xt.onload=function(){Ht&&Kt(Ht),Ht=null,Wt=!0;},Xt.onerror=function(){Zt=!0,Ht=null;},Xt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Jt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(Jt);class Qt extends Error{constructor(e,t,r){401===t&&Vt(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=r;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}function er(e){return "object"==typeof e&&null!==e&&"status"in e&&404===e.status}const tr=ht()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,rr=/^\w+:/,nr=/[\r\n]+/;const ir=function(e,t){return (r=e.url).startsWith("file:")||tr().startsWith("file:")&&!rr.test(r)?function(e,t){const r=new XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return "json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response);}catch(e){return t(e)}const i=new Headers;r.getAllResponseHeaders().trim().split(nr).forEach(e=>{const t=e.split(": "),r=t.shift(),n=t.join(": ");i.append(r,n);}),t(null,n,i);}else t(new Qt(r.statusText,r.status,e.url));},r.send(e.body),{cancel:()=>r.abort()}}(e,t):function(e,t){const r=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:tr(),referrerPolicy:e.referrerPolicy,signal:r.signal});let i=!1,s=!1;const a=(o=n.url).indexOf("sku=")>0&&Vt(o);var o;"json"===e.type&&n.headers.set("Accept","application/json");const l=(r,i,o)=>{if(s)return;if(r&&"SecurityError"!==r.message&<(r.toString()),i&&o)return u(i);const l=Date.now();fetch(n).then(r=>{if(r.ok){const e=a?r.clone():null;return u(r,e,l)}return t(new Qt(r.statusText,r.status,e.url))}).catch(r=>{"AbortError"!==r.name&&t(new Error(`${r.message} ${e.url}`));});},u=(r,a,o)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{s||(a&&o&&function(e,t,r){if(Gt(),null==Nt)return;const n=dt(t.headers.get("cache-control")||"");if(n["no-store"])return;const i={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((e,t)=>i.headers.set(t,e)),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const s=i.headers.get("expires");if(!s)return;if(new Date(s).getTime()-r<42e4)return;let a=Ct(e.url,{persistentParams:Ut});if(206===t.status){const t=e.headers.get("Range");if(!t)return;i.status=200,a=Dt(a,{range:t});}const o=new Response(200!==(l=t.status)&&404!==l&&[101,103,204,205,304].includes(l)?null:t.body,i);var l;Gt(),null!=Nt&&Nt.then(e=>e.put(a,o)).catch(e=>lt(e.message));}(n,a,o),i=!0,t(null,e,r.headers));}).catch(e=>{s||t(new Error(e.message));});};return a?function(e,t){if(Gt(),null==Nt)return t(null);Nt.then(r=>{let n=Ct(e.url,{persistentParams:Ut});const i=e.headers.get("Range");i&&(n=Dt(n,{range:i})),r.match(n).then(e=>{const i=function(e){if(!e)return !1;const t=new Date(e.headers.get("expires")||0),r=dt(e.headers.get("cache-control")||"");return Number(t)>Date.now()&&!r["no-cache"]}(e);r.delete(n).catch(t),i&&r.put(n,e.clone()).catch(t),t(null,e,i);}).catch(t);}).catch(t);}(n,l):l(null,null),{cancel:()=>{s=!0,i||r.abort();}}}(e,t);var r;},sr=function(e,t){return ir(Object.assign(e,{type:"json"}),t)},ar=function(e,t){return ir(Object.assign(e,{type:"arrayBuffer"}),t)};function or(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}let lr,ur;lr=[],ur=0;const cr=function(e,t){if(qt.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),ur>=Pt.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0;}};return lr.push(r),r}ur++;let r=!1;const n=()=>{if(!r)for(r=!0,ur--;lr.length&&ur{n(),e?t(e):r&&function(e,t){const r=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(r).then(e=>{t(null,e);}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));});}(r,(e,r)=>t(e,r,i));});return {cancel:()=>{i.cancel(),n();}}};function hr(e,t=0){const r=3432918353,n=461845907,i=e.length,s=i-(3&i);let a,o=0|t,l=0;for(;l>>17,a=Math.imul(a,n),o^=a,o=o<<13|o>>>19,o=Math.imul(o,5)+3864292196|0;a=0;const u=3&i;return u>0&&(u>=3&&(a^=(255&e.charCodeAt(l+2))<<16),u>=2&&(a^=(255&e.charCodeAt(l+1))<<8),a^=255&e.charCodeAt(l),a=Math.imul(a,r),a=a<<15|a>>>17,a=Math.imul(a,n),o^=a),o^=i,o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),o^=o>>>16,o>>>0}class dr{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e;}}class pr extends dr{constructor(e,t={}){super("error",Object.assign({error:e},t));}}function fr(e,t,r){r[e]&&r[e].includes(t)||(r[e]=r[e]||[],r[e].push(t));}function mr(e,t,r){if(r&&r[e]){const n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1);}}class yr{on(e,t){return this._listeners=this._listeners||{},fr(e,t,this._listeners),this}off(e,t){return mr(e,t,this._listeners),mr(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},fr(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t);})}fire(e,t){const r="string"==typeof e?new dr(e,t):e,n=r.type;if(this.listens(n)){r.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,r);const t=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)mr(n,e,this._oneTimeListeners),e.call(this,r);const i=this._eventedParent;if(i){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(r,e),i.fire(r);}}else r instanceof pr&&console.error(r.error);return this}listens(e){return !!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class gr{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId);}static from(e){return new gr(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,r]=e.split("");return new gr({name:t,iconsetId:r})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return gr.toString(this)}serialize(){return {name:this.name,iconsetId:this.iconsetId}}}var xr,br={},vr=function(){if(xr)return br;xr=1;var e={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 t(e){return (e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function i(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{br.parseCSSColor=function(s){var a,o=s.replace(/ /g,"").toLowerCase();if(o in e)return e[o].slice();if("#"===o[0])return 4===o.length?(a=parseInt(o.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===o.length&&(a=parseInt(o.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=o.indexOf("("),u=o.indexOf(")");if(-1!==l&&u+1===o.length){var c=o.substr(0,l),h=o.substr(l+1,u-(l+1)).split(","),d=1;switch(c){case "rgba":if(4!==h.length)return null;d=n(h.pop());case "rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),d];case "hsla":if(4!==h.length)return null;d=n(h.pop());case "hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),y=m<=.5?m*(f+1):m+f-m*f,g=2*m-y;return [t(255*i(g,y,p+1/3)),t(255*i(g,y,p)),t(255*i(g,y,p-1/3)),d];default:return null}}return null};}catch(e){}return br}();function wr(e,t,r){return e*(1-r)+t*r}const _r=new Map;class Ar{constructor(e,t,r,n=1){this.r=e,this.g=t,this.b=r,this.a=n;}static parse(e){if(!e)return;if(e instanceof Ar)return e;if("string"!=typeof e)return;const t=_r.get(e);if(t)return t;const r=vr.parseCSSColor(e);if(!r)return;const n=new Ar(r[0]/255,r[1]/255,r[2]/255,r[3]);return _r.set(e,n),n}toString(){const{r:e,g:t,b:r,a:n}=this;return `rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new Mr(e,t,r,n,i)}toPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new Sr(e,t*i,r*i,n*i,i)}clone(){return new Ar(this.r,this.g,this.b,this.a)}}class Ir{constructor(e,t,r,n,i,s=!1){if(this.premultiplied=!1,this.premultiplied=s,e){const s=e.image.height,a=s*s;this.premultiplied?(t=0===i?0:t/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1)):(t*=s-1,r*=s-1,n*=s-1),t=Math.max(0,Math.min(s-1,t)),r=Math.max(0,Math.min(s-1,r)),n=Math.max(0,Math.min(s-1,n));const o=Math.floor(t),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(t),h=Math.ceil(r),d=Math.ceil(n),p=t-o,f=r-l,m=n-u,y=e.image.data,g=4*(o+l*a+u*s),x=4*(o+l*a+d*s),b=4*(o+h*a+u*s),v=4*(o+h*a+d*s),w=4*(c+l*a+u*s),_=4*(c+l*a+d*s),A=4*(c+h*a+u*s),I=4*(c+h*a+d*s);this.r=wr(wr(wr(y[g],y[x],m),wr(y[b],y[v],m),f),wr(wr(y[w],y[_],m),wr(y[A],y[I],m),f),p)/255*(this.premultiplied?i:1),this.g=wr(wr(wr(y[g+1],y[x+1],m),wr(y[b+1],y[v+1],m),f),wr(wr(y[w+1],y[_+1],m),wr(y[A+1],y[I+1],m),f),p)/255*(this.premultiplied?i:1),this.b=wr(wr(wr(y[g+2],y[x+2],m),wr(y[b+2],y[v+2],m),f),wr(wr(y[w+2],y[_+2],m),wr(y[A+2],y[I+2],m),f),p)/255*(this.premultiplied?i:1),this.a=i;}else this.r=t,this.g=r,this.b=n,this.a=i;}toArray(){const{r:e,g:t,b:r,a:n}=this;return [255*e,255*t,255*r,n]}toHslaArray(){let{r:e,g:t,b:r,a:n}=this;if(this.premultiplied){if(0===n)return [0,0,0,0];const i=1/n;e*=i,t*=i,r*=i;}const i=Math.min(Math.max(e,0),1),s=Math.min(Math.max(t,0),1),a=Math.min(Math.max(r,0),1),o=Math.min(i,s,a),l=Math.max(i,s,a),u=l-o,c=.5*(o+l);if(0===u)return [0,0,100*c,n];const h=c>.5?u/(2-l-o):u/(l+o);let d;switch(l){case i:d=60*((s-a)/u+(swr(e,t[n],r))}Ar.black=new Ar(0,0,0,1),Ar.white=new Ar(1,1,1,1),Ar.transparent=new Ar(0,0,0,0),Ar.red=new Ar(1,0,0,1),Ar.blue=new Ar(0,0,1,1);var Tr=Object.freeze({__proto__:null,array:Br,color:function(e,t,r){return new Ar(wr(e.r,t.r,r),wr(e.g,t.g,r),wr(e.b,t.b,r),wr(e.a,t.a,r))},number:wr});class Pr extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}class zr{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,r]of t)this.bindings[e]=r;}concat(e){return new zr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return !!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Er={kind:"null"},kr={kind:"number"},Vr={kind:"string"},Fr={kind:"boolean"},Dr={kind:"color"},Cr={kind:"object"},Rr={kind:"value"},Lr={kind:"collator"},Or={kind:"formatted"},Ur={kind:"resolvedImage"};function Nr(e,t){return {kind:"array",itemType:e,N:t}}function jr(e){if("array"===e.kind){const t=jr(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Gr=[Er,kr,Vr,Fr,Dr,Or,Cr,Nr(Rr),Ur];function $r(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!$r(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else {if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Gr)if(!$r(e,t))return null}return `Expected ${jr(e)} but found ${jr(t)} instead.`}function qr(e,t){return t.some(t=>t.kind===e.kind)}function Hr(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Xr(e,t){return "array"===e.kind&&"array"===t.kind?e.N===t.N&&Xr(e.itemType,t.itemType):e.kind===t.kind}class Zr{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Wr{constructor(e,t,r,n,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=i;}}class Yr{constructor(e){this.sections=e;}static fromString(e){return new Yr([new Wr(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof Yr?e:Yr.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const r=t.image.getPrimary().id.toString();e.push(["image",r]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r);}return e}}class Kr{constructor(e,t={}){this.id=gr.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1;}toString(){return JSON.stringify(this)}static parse(e){let t,r,n,i;try{({id:t,params:r,sx:n,sy:i}=JSON.parse(e)||{});}catch(e){return null}return t?new Kr(t,{params:r,sx:n,sy:i}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class Jr{constructor(e,t,r,n,i=!1){this.primaryId=gr.from(e),this.primaryOptions=t,r&&(this.secondaryId=gr.from(r)),this.secondaryOptions=n,this.available=i;}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return !!this.primaryId}getPrimary(){return new Kr(this.primaryId,this.primaryOptions)}hasSecondary(){return !!this.secondaryId}getSecondary(){return this.secondaryId?new Kr(this.secondaryId,this.secondaryOptions):null}static from(e){return "string"==typeof e?Jr.build({name:e}):e}static build(e,t,r,n){return !e||"object"==typeof e&&!("name"in e)?null:new Jr(e,r,t,n)}}function Qr(e,t,r,n){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function en(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof Ar)return !0;if(e instanceof Zr)return !0;if(e instanceof Yr)return !0;if(e instanceof Jr)return !0;if(Array.isArray(e)){for(const t of e)if(!en(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!en(e[t]))return !1;return !0}return !1}function tn(e){if(null===e)return Er;if("string"==typeof e)return Vr;if("boolean"==typeof e)return Fr;if("number"==typeof e)return kr;if(e instanceof Ar)return Dr;if(e instanceof Zr)return Lr;if(e instanceof Yr)return Or;if(e instanceof Jr)return Ur;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=tn(t);if(r){if(r===e)continue;r=Rr;break}r=e;}return Nr(r||Rr,t)}return Cr}function rn(e){return null===e?"":"string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):e instanceof Yr||e instanceof Jr||e instanceof Ar?e.toString():JSON.stringify(e)}class nn{constructor(e,t){this.type=e,this.value=t;}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!en(e[1]))return t.error("invalid value");const r=e[1];let n=tn(r);const i=t.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new nn(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ar?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Yr?this.value.serialize():this.value}}class sn{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}}const an={string:Vr,number:kr,boolean:Fr,object:Cr};class on{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const i=e[0];if("array"===i){let i,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in an)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=an[r],n++;}else i=Rr;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++;}r=Nr(i,s);}else r=an[i];const s=[];for(;ne.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){t.push(r.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n);}}return t.concat(this.args.map(e=>e.serialize()))}}class ln{constructor(e){this.type=Or,this.sections=e;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=e.length-1;++r){const s=e[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let e=null;if(s["font-scale"]&&(e=t.parseObjectValue(s["font-scale"],r,"font-scale",kr),!e))return null;let a=null;if(s["text-font"]&&(a=t.parseObjectValue(s["text-font"],r,"text-font",Nr(Vr)),!a))return null;let o=null;if(s["text-color"]&&(o=t.parseObjectValue(s["text-color"],r,"text-color",Dr),!o))return null;const l=n.at(-1);l.scale=e,l.font=a,l.textColor=o;}else {const s=t.parse(e[r],r,Rr);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new ln(n)}evaluate(e){return new Yr(this.sections.map(t=>{const r=t.content.evaluate(e);return Xr(tn(r),Ur)?new Wr("",r,null,null,null):new Wr(rn(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r);}return e}}class un{constructor(e,t,r,n){this._imageWarnHistory={},this.type=Ur,this.namePrimary=e,this.nameSecondary=t,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0);}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(rgr.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>gr.isEqual(e,t)));}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t]);}outputDefined(){return !1}serializeOptions(e,t){const r={};if(t&&(r.iconset={id:t}),e){r.params={};for(const t in e)e[t]&&(r.params[t]=e[t].serialize());}return Object.keys(r).length>0?r:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t);}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t);}return e}}function cn(e){return dn(e)?"string":pn(e)?"number":fn(e)?"boolean":Array.isArray(e)?"array":null===e?"null":hn(e)?"object":typeof e}function hn(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function dn(e){return "string"==typeof e||e instanceof String}function pn(e){return "number"==typeof e||e instanceof Number}function fn(e){return "boolean"==typeof e||e instanceof Boolean}const mn={"to-boolean":Fr,"to-color":Dr,"to-number":kr,"to-string":Vr};class yn{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0],n=[];let i=Er;if("to-array"===r){if(!Array.isArray(e[1]))return null;const r=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);i=Nr(t.expectedType.itemType,r);}else {if(!(r>0&&en(e[1][0])))return null;i=Nr(tn(e[1][0]),r);}for(let s=0;s4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Qr(t[0],t[1],t[2],t[3]),!r))return new Ar(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new sn(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new sn(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?Yr.fromString(rn(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Jr.build(rn(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):rn(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new ln([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new un(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize());}),e}}const gn=["Unknown","Point","LineString","Polygon"];class xn{constructor(e,t,r){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=r;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?gn[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){return Ar.parse(e)}getConfig(e){return this.options?this.options.get(e):null}}class bn{constructor(e,t,r,n,i){this.name=e,this.type=t,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(e){if(!this._evaluate){const e=bn.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1];}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const r=e[0],n=bn.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==e.length-1)continue;a.push(n),l++,null===o?o=new Ti(t.registry,t.path,null,t.scope,[],t._scope,t.options,t.iconImageUseTheme):o.errors.length=0;const s=[];let c=!1;for(let t=1;te)).map(vn).join(" | "),n=[];for(let r=1;rr[2]){const t=.5*n;let i=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===i&&(i=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=i;}ze(t,e);}function Dn(e,t,r,n){const i=Math.pow(2,n.z)*Sn,s=[n.x*Sn,n.y*Sn],a=[];if(!e)return a;for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];Fn(n,t,r,i),a.push(n);}return a}function Cn(e,t,r,n){const i=Math.pow(2,n.z)*Sn,s=[n.x*Sn,n.y*Sn],a=[];if(!e)return a;for(const r of e){const e=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];ze(t,r),e.push(r);}a.push(e);}if(t[2]-t[0]<=i/2){(o=t)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const e of a)for(const n of e)Fn(n,t,r,i);}var o;return a}class Rn{constructor(e,t){this.type=Fr,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(en(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;et)return $n(i,s,(t-(r-a))/a)}return e[e.length-1]}pointToSegmentDistance(e,t,r){let[n,i]=t,s=qn(r[0]-n)*this.kx,a=(r[1]-i)*this.ky;if(0!==s||0!==a){const t=(qn(e[0]-n)*this.kx*s+(e[1]-i)*this.ky*a)/(s*s+a*a);t>1?(n=r[0],i=r[1]):t>0&&(n+=s/this.kx*t,i+=a/this.ky*t);}return s=qn(e[0]-n)*this.kx,a=(e[1]-i)*this.ky,Math.sqrt(s*s+a*a)}pointOnLine(e,t){let r=1/0,n=e[0][0],i=e[0][1],s=0,a=0;for(let o=0;o1?(l=e[o+1][0],u=e[o+1][1]):d>0&&(l+=c/this.kx*d,u+=h/this.ky*d)),c=qn(t[0]-l)*this.kx,h=(t[1]-u)*this.ky;const p=c*c+h*h;pi.index||n.index===i.index&&n.t>i.t){const e=n;n=i,i=e;}const s=[n.point],a=n.index+1,o=i.index;!Gn(r[a],s[0])&&a<=o&&s.push(r[a]);for(let e=a+1;e<=o;e++)s.push(r[e]);return Gn(r[o],i.point)||s.push(i.point),s}lineSliceAlong(e,t,r){let n=0;const i=[];for(let s=0;se&&0===i.length&&i.push($n(a,o,(e-(n-l))/l)),n>=t)return i.push($n(a,o,(t-(n-l))/l)),i;n>e&&i.push(o);}return i}bufferPoint(e,t){const r=t/this.ky,n=t/this.kx;return [e[0]-n,e[1]-r,e[0]+n,e[1]+r]}bufferBBox(e,t){const r=t/this.ky,n=t/this.kx;return [e[0]-n,e[1]-r,e[2]+n,e[3]+r]}insideBBox(e,t){return qn(e[0]-t[0])>=0&&qn(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Gn(e,t){return e[0]===t[0]&&e[1]===t[1]}function $n(e,t,r){const n=qn(t[0]-e[0]);return [e[0]+n*r,e[1]+(t[1]-e[1])*r]}function qn(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class Hn{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e);}push(e){this.data.push(e),this._up(this.length++);}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return --this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i;}t[e]=n;}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[n],e=n;}t[e]=i;}}var Xn=8192;function Zn(e,t){return t.dist-e.dist}function Wn(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let r=0;r=e[0]&&e[1]e[1])return [null,null];const r=Yn(e);if(t){if(2===r)return [e,null];const t=Math.floor(r/2);return [[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===r)return [e,null];const t=Math.floor(r/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function Qn(e,t){const r=[1/0,1/0,-1/0,-1/0];if(!Kn(t,e.length))return r;for(let n=t[0];n<=t[1];++n)ze(r,e[n]);return r}function ei(e){const t=[1/0,1/0,-1/0,-1/0];for(let r=0;rt[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=n)return n;if(Ee(i,s)){if(hi(e,t))return 0}else if(hi(t,e))return 0;let a=n;for(const n of e)for(let e=0,i=n.length,s=i-1;e=s)continue;const u=i.range1;if(Yn(u)<=o){if(!Kn(u,e.length))return NaN;if(t){const t=ci(e,u,r,n);if(0===(s=Math.min(s,t)))return s}else for(let t=u[0];t<=u[1];++t){const i=ui(e[t],r,n);if(0===(s=Math.min(s,i)))return s}}else {const r=Jn(u,t);if(null!==r[0]){const t=ti(Qn(e,r[0]),l,n);t=a)continue;const c=s.range1,h=s.range2;if(Yn(c)<=l&&Yn(h)<=u){if(!Kn(c,e.length)||!Kn(h,r.length))return NaN;if(t&&n?a=Math.min(a,oi(e,c,r,h,i)):t||n?t&&!n?a=Math.min(a,si(r,h,e,c,i)):!t&&n&&(a=Math.min(a,si(e,c,r,h,i))):a=Math.min(a,li(e,c,r,h,i)),0===a)return a}else {const s=Jn(c,t),l=Jn(h,n);pi(o,a,i,e,r,s[0],l[0]),pi(o,a,i,e,r,s[0],l[1]),pi(o,a,i,e,r,s[1],l[0]),pi(o,a,i,e,r,s[1],l[1]);}}return a}function yi(e,t,r,n,i=1/0){let s=i;const a=Qn(e,[0,e.length-1]);for(const i of r)if(!(s!==1/0&&ti(a,Qn(i,[0,i.length-1]),n)>=s)&&(s=Math.min(s,mi(e,t,i,!0,n,s)),0===s))return s;return s}function gi(e,t,r,n,i=1/0){let s=i;const a=Qn(e,[0,e.length-1]);for(const i of r){if(s!==1/0&&ti(a,ei(i),n)>=s)continue;const r=fi(e,t,i,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))return s}return s}function xi(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class bi{constructor(e,t){this.type=kr,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(en(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!vi(e)&&(t=!1);}),t}function wi(e){if(e instanceof bn&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild(e=>{t&&!wi(e)&&(t=!1);}),t}function _i(e,t){if(e instanceof bn&&t.includes(e.name))return !1;let r=!0;return e.eachChild(e=>{r&&!_i(e,t)&&(r=!1);}),r}function Ai(e,t,r){return [e,t,r].filter(Boolean).join("")}function Ii(e,t){switch(e){case "string":return rn(t);case "number":return +t;case "boolean":return !!t;case "color":return Ar.parse(t);case "formatted":return Yr.fromString(rn(t));case "resolvedImage":return Jr.build(rn(t))}return t}function Mi(e,t,r,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&er&&(e=r),e}class Si{constructor(e,t,r,n=!1){this.type=e,this.key=t,this.scope=r,this.featureConstant=n;}static parse(e,t){let r=t.expectedType;if(null==r&&(r=Rr),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const n=t.parse(e[1],1);if(!(n instanceof nn))return t.error("Key name of 'config' expression must be a string literal.");let i,s=!0;const a=rn(n.value);if(e.length>=3){const r=t.parse(e[2],2);if(!(r instanceof nn))return t.error("Scope of 'config' expression must be a string literal.");i=rn(r.value);}if(t.options){const e=Ai(a,i,t._scope),r=t.options.get(e);r&&(s=vi(r.value||r.default));}return new Si(r,a,i,s)}evaluate(e){const t=Ai(this.key,this.scope,e.scope),r=e.getConfig(t);if(!r)return null;const{type:n,value:i,values:s,minValue:a,maxValue:o,stepValue:l}=r,u=r.default.evaluate(e);let c=u;if(i){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),c=i.evaluate(e),e.scope=t;}return n&&(c=Ii(n,c)),void 0===c||void 0===a&&void 0===o&&void 0===l||("number"==typeof c?c=Mi(c,a,o,l):Array.isArray(c)&&(c=c.map(e=>"number"==typeof e?Mi(e,a,o,l):e))),void 0!==i&&void 0!==c&&s&&!s.includes(c)&&(c=u,n&&(c=Ii(n,c))),(n&&n!==this.type||void 0!==c&&!Xr(tn(c),this.type))&&(c=Ii(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Bi{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t;}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const r=e[1];return t.scope.has(r)?new Bi(r,t.scope.get(r)):t.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}class Ti{constructor(e,t=[],r,n=new zr,i=[],s,a,o){this.registry=e,this.path=t,this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=a,this.iconImageUseTheme=o;}get key(){if(void 0===this._key){const e=this.path;let t="";for(let r=0;r`[${e}]`).join("")}`;this.errors.push(new Pr(r,e));}checkSubtype(e,t,r){const n=$r(e,t);return n&&this.error(n,..."number"==typeof r?[r]:[]),n}}function Pi(e){if(e instanceof Bi)return Pi(e.boundExpression);if(e instanceof bn&&"error"===e.name)return !1;if(e instanceof wn)return !1;if(e instanceof Rn)return !1;if(e instanceof bi)return !1;if(e instanceof Si)return !1;const t=e instanceof yn||e instanceof on;let r=!0;return e.eachChild(e=>{r=t?r&&Pi(e):r&&e instanceof nn;}),!!r&&vi(e)&&_i(e,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function zi(e,t){const r=e.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=e[o],i=e[o+1],n<=t){if(o===r||tt))throw new sn("Input is not a number.");a=o-1;}return 0}class Ei{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t);}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,kr);if(!r)return null;const n=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let r=1;r=s)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Ei(i,r,n)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;return n>=t[i-1]?r[i-1].evaluate(e):r[zi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const ki=.95047,Vi=1.08883,Fi=4/29,Di=6/29,Ci=3*Di*Di,Ri=Di*Di*Di,Li=Math.PI/180,Oi=180/Math.PI;function Ui(e){return e>Ri?Math.pow(e,1/3):e/Ci+Fi}function Ni(e){return e>Di?e*e*e:Ci*(e-Fi)}function ji(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Gi(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function $i(e){const t=Gi(e.r),r=Gi(e.g),n=Gi(e.b),i=Ui((.4124564*t+.3575761*r+.1804375*n)/ki),s=Ui((.2126729*t+.7151522*r+.072175*n)/1);return {l:116*s-16,a:500*(i-s),b:200*(s-Ui((.0193339*t+.119192*r+.9503041*n)/Vi)),alpha:e.a}}function qi(e){let t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Ni(t),r=ki*Ni(r),n=Vi*Ni(n),new Ar(ji(3.2404542*r-1.5371385*t-.4985314*n),ji(-.969266*r+1.8760108*t+.041556*n),ji(.0556434*r-.2040259*t+1.0572252*n),e.alpha)}function Hi(e,t,r){const n=t-e;return e+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const Xi={forward:$i,reverse:qi,interpolate:function(e,t,r){return {l:wr(e.l,t.l,r),a:wr(e.a,t.a,r),b:wr(e.b,t.b,r),alpha:wr(e.alpha,t.alpha,r)}}},Zi={forward:function(e){const{l:t,a:r,b:n}=$i(e),i=Math.atan2(n,r)*Oi;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Li,r=e.c;return qi({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return {h:Hi(e.h,t.h,r),c:wr(e.c,t.c,r),l:wr(e.l,t.l,r),alpha:wr(e.alpha,t.alpha,r)}}};var Wi=Object.freeze({__proto__:null,hcl:Zi,lab:Xi});class Yi{constructor(e,t,r,n,i){this.type=e,this.operator=t,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,r,n){let i=0;if("exponential"===e.name)i=Ki(t,e.base,r,n);else if("linear"===e.name)i=Ki(t,1,r,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;i=we(s[0],s[1],s[2],s[3])(Ki(t,1,r,n));}return i}static parse(e,t){let[r,n,i,...s]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e};}else {if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e};}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,kr),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Dr:t.expectedType&&"value"!==t.expectedType.kind&&(o=t.expectedType);for(let e=0;e=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return "number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new Yi(o,r,n,i,a):t.error(`Type ${jr(o)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;if(n>=t[i-1])return r[i-1].evaluate(e);const s=zi(t,n),a=Yi.interpolationFactor(this.interpolation,n,t[s],t[s+1]),o=r[s].evaluate(e),l=r[s+1].evaluate(e);return "interpolate"===this.operator?Tr[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?Zi.reverse(Zi.interpolate(Zi.forward(o),Zi.forward(l),a)):Xi.reverse(Xi.interpolate(Xi.forward(o),Xi.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let e=0;e$r(n,e.type));return new Ji(s?Rr:r,i)}evaluate(e){let t,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(e),r&&r instanceof Jr&&!r.available&&(t||(t=r),r=null,n===this.args.length))return t;if(null!==r)break}return r}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize());}),e}}const Qi=/[^a-zA-Z0-9_]/;class es{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t;}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result);}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new sn("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new sn("Array index must be an integer. Use at-interpolated for fractional indices");return r[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class rs{constructor(e,t,r){this.type=e,this.index=t,this.input=r;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,kr),n=t.parse(e[2],2,Nr(t.expectedType||Rr));return r&&n?new rs(n.type.itemType,r,n):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new sn(`Array index out of bounds: ${t} < 0.`);if(t>r.length-1)throw new sn(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t===Math.floor(t))return r[t];const n=Math.floor(t),i=Math.ceil(t),s=r[n],a=r[i];if("number"!=typeof s||"number"!=typeof a)throw new sn(`Cannot interpolate between non-number values at index ${t}.`);return wr(s,a,t-n)}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at-interpolated",this.index.serialize(),this.input.serialize()]}}class ns{constructor(e,t){this.type=Fr,this.needle=e,this.haystack=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Rr),n=t.parse(e[2],2,Rr);return r&&n?qr(r.type,[Fr,Vr,kr,Er,Rr])?new ns(r,n):(t.error(`Expected first argument to be of type boolean, string, number or null, but found ${jr(r.type)} instead`),null):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return !1;if(!Hr(t,["boolean","string","number","null"]))throw new sn(`Expected first argument to be of type boolean, string, number or null, but found ${jr(tn(t))} instead.`);if(!Hr(r,["string","array"]))throw new sn(`Expected second argument to be of type array or string, but found ${jr(tn(r))} instead.`);return r.includes(t)}eachChild(e){e(this.needle),e(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}class is{constructor(e,t,r){this.type=kr,this.needle=e,this.haystack=t,this.fromIndex=r;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Rr),n=t.parse(e[2],2,Rr);if(!r||!n)return null;if(!qr(r.type,[Fr,Vr,kr,Er,Rr]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${jr(r.type)} instead`),null;if(4===e.length){const i=t.parse(e[3],3,kr);return i?new is(r,n,i):null}return new is(r,n)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Hr(t,["boolean","string","number","null"]))throw new sn(`Expected first argument to be of type boolean, string, number or null, but found ${jr(tn(t))} instead.`);if(!Hr(r,["string","array"]))throw new sn(`Expected second argument to be of type array or string, but found ${jr(tn(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return r.indexOf(t,n)}return r.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}class ss{constructor(e,t,r,n,i,s){this.inputType=e,this.type=t,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,tn(e)))return null}else r=tn(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=s.length;}const c=t.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=t.parse(e[1],1,Rr);if(!a)return null;const o=t.parse(e.at(-1),e.length-1,n);return o?"value"!==a.type.kind&&t.concat(1).checkSubtype(r,a.type)?null:new ss(r,n,a,i,s,o):null}evaluate(e){const t=this.input.evaluate(e);return (Xr(tn(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise);}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),r=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=r.length,r.push([this.cases[e],[e]])):r[t][1].push(e);}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of r)e.push(1===n.length?i(n[0]):n.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class as{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r;}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class os{constructor(e,t,r,n){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=n;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Rr),n=t.parse(e[2],2,kr);if(!r||!n)return null;if(!qr(r.type,[Nr(Rr),Vr,Rr]))return t.error(`Expected first argument to be of type array or string, but found ${jr(r.type)} instead`),null;if(4===e.length){const i=t.parse(e[3],3,kr);return i?new os(r.type,r,n,i):null}return new os(r.type,r,n)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!Hr(t,["string","array"]))throw new sn(`Expected first argument to be of type array or string, but found ${jr(tn(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(r,n)}return t.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}class ls{constructor(e,t){this.type=Nr(Vr),this.str=e,this.delimiter=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Vr),n=t.parse(e[2],2,Vr);return r&&n?new ls(r,n):void 0}evaluate(e){const t=this.str.evaluate(e),r=this.delimiter.evaluate(e);return t.split(r)}eachChild(e){e(this.str),e(this.delimiter);}outputDefined(){return !1}serialize(){return ["split",this.str.serialize(),this.delimiter.serialize()]}}function us(e,t){return "=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function cs(e,t,r,n){return 0===n.compare(t,r)}function hs(e,t,r){const n="=="!==e&&"!="!==e;return class i{constructor(e,t,r){this.type=Fr,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind;}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let s=t.parse(e[1],1,Rr);if(!s)return null;if(!us(r,s.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${jr(s.type)}'.`);let a=t.parse(e[2],2,Rr);if(!a)return null;if(!us(r,a.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${jr(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${jr(s.type)}' and '${jr(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new on(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new on(s.type,[a])));let o=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(o=t.parse(e[3],3,Lr),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const t=tn(s),r=tn(a);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new sn(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=tn(s),r=tn(a);if("string"!==e.kind||"string"!==r.kind)return t(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):t(i,s,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize());}),t}}}const ds=hs("==",function(e,t,r){return t===r},cs),ps=hs("!=",function(e,t,r){return t!==r},function(e,t,r,n){return !cs(0,t,r,n)}),fs=hs("<",function(e,t,r){return t",function(e,t,r){return t>r},function(e,t,r,n){return n.compare(t,r)>0}),ys=hs("<=",function(e,t,r){return t<=r},function(e,t,r,n){return n.compare(t,r)<=0}),gs=hs(">=",function(e,t,r){return t>=r},function(e,t,r,n){return n.compare(t,r)>=0});class xs{constructor(e,t,r,n,i,s){this.type=Vr,this.number=e,this.locale=t,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,kr);if(!r)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=t.parseObjectValue(n.locale,2,"locale",Vr),!i))return null;let s=null;if(n.currency&&(s=t.parseObjectValue(n.currency,2,"currency",Vr),!s))return null;let a=null;if(n.unit&&(a=t.parseObjectValue(n.unit,2,"unit",Vr),!a))return null;let o=null;if(n["min-fraction-digits"]&&(o=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",kr),!o))return null;let l=null;return n["max-fraction-digits"]&&(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",kr),!l)?null:new xs(r,i,s,a,o,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class bs{constructor(e){this.type=kr,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?(t.error(`Expected argument of type string or array, but found ${jr(r.type)} instead.`),null):new bs(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new sn(`Expected value to be of type string or array, but found ${jr(tn(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize());}),e}}function vs(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const ws={"==":ds,"!=":ps,">":ms,"<":fs,">=":gs,"<=":ys,array:on,at:ts,"at-interpolated":rs,boolean:on,case:as,coalesce:Ji,collator:wn,format:ln,image:un,in:ns,"index-of":is,interpolate:Yi,"interpolate-hcl":Yi,"interpolate-lab":Yi,length:bs,let:es,literal:nn,match:ss,number:on,"number-format":xs,object:on,slice:os,step:Ei,string:on,"to-boolean":yn,"to-color":yn,"to-number":yn,"to-string":yn,var:Bi,within:Rn,distance:bi,config:Si,split:ls};function _s(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,a=Qr(t,r,n,s);if(a)throw new sn(a);return new Ar(t/255,r/255,n/255,s)}function As(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,a=function(e,t,r,n){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'h' must be between 0 and 360.`}(t,r,n,s);if(a)throw new sn(a);const o=`hsla(${t}, ${r}%, ${n}%, ${s})`,l=Ar.parse(o);if(!l)throw new sn(`Failed to parse HSLA color: ${o}`);return l}function Is(e,t){return e in t}function Ms(e,t){const r=t[e];return void 0===r?null:r}function Ss(e){return {type:e}}function Bs(e){if(e instanceof Si)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...Bs(e)]);}),t}function Ts(e){if(e instanceof bn&&"is-active-floor"===e.name)return !0;let t=!1;return e.eachChild(e=>{!t&&Ts(e)&&(t=!0);}),t}function Ps(e){return {result:"success",value:e}}function zs(e){return {result:"error",value:e}}function Es(e,t){return !!e&&!!e.parameters&&e.parameters.includes(t)}function ks(e){return "data-driven"===e["property-type"]}function Vs(e){return Es(e.expression,"measure-light")}function Fs(e){return Es(e.expression,"zoom")}function Ds(e){return !!e.expression&&e.expression.interpolated}function Cs(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function Rs(e){return e}function Ls(e,t){const r="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],i=n||!(n||void 0!==e.property),s=e.type||(Ds(t)?"exponential":"interval");if(r&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],Ar.parse(e[1])])),e.default=Ar.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Wi[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let a,o,l;if("exponential"===s)a=js;else if("interval"===s)a=Ns;else if("categorical"===s){a=Us,o=Object.create(null);for(const t of e.stops)o[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);a=Gs;}if(n){const r={},n=[];for(let t=0;te[0]),evaluate:({zoom:r},n)=>js({stops:i,base:e.base},t,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:Yi.interpolationFactor.bind(void 0,r),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:r})=>a(e,t,r,o,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[e.property]:void 0;return void 0===i?Os(e.default,t.default):a(e,t,i,o,l)}}}function Os(e,t,r){return void 0!==e?e:void 0!==t?t:void 0!==r?r:void 0}function Us(e,t,r,n,i){return Os(typeof r===i?n[r]:void 0,e.default,t.default)}function Ns(e,t,r){if(!pn(r))return Os(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];const i=zi(e.stops.map(e=>e[0]),r);return e.stops[i][1]}function js(e,t,r){const n=void 0!==e.base?e.base:1;if(!pn(r))return Os(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];const s=zi(e.stops.map(e=>e[0]),r),a=function(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}(r,n,e.stops[s][0],e.stops[s+1][0]),o=e.stops[s][1],l=e.stops[s+1][1];let u=Tr[t.type]||Rs;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Wi[e.colorSpace];u=(e,r)=>t.reverse(t.interpolate(t.forward(e),t.forward(r),a));}return "function"==typeof o.evaluate?{evaluate(...e){const t=o.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==r)return u(t,r,a)}}:u(o,l,a)}function Gs(e,t,r){return "color"===t.type?r=Ar.parse(r):"formatted"===t.type?r=Yr.fromString(r.toString()):"resolvedImage"===t.type?r=Jr.build(r.toString()):cn(r)===t.type||"enum"===t.type&&t.values[r]||(r=void 0),Os(r,e.default,t.default)}bn.register(ws,{error:[{kind:"error"},[Vr],(e,[t])=>{throw new sn(t.evaluate(e))}],typeof:[Vr,[Rr],(e,[t])=>jr(tn(t.evaluate(e)))],"to-rgba":[Nr(kr,4),[Dr],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Nr(kr,4),[Dr],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Dr,[kr,kr,kr],_s],rgba:[Dr,[kr,kr,kr,kr],_s],hsl:[Dr,[kr,kr,kr],As],hsla:[Dr,[kr,kr,kr,kr],As],has:{type:Fr,overloads:[[[Vr],(e,[t])=>Is(t.evaluate(e),e.properties())],[[Vr,Cr],(e,[t,r])=>Is(t.evaluate(e),r.evaluate(e))]]},get:{type:Rr,overloads:[[[Vr],(e,[t])=>Ms(t.evaluate(e),e.properties())],[[Vr,Cr],(e,[t,r])=>Ms(t.evaluate(e),r.evaluate(e))]]},"feature-state":[Rr,[Vr],(e,[t])=>Ms(t.evaluate(e),e.featureState||{})],properties:[Cr,[],e=>e.properties()],"geometry-type":[Vr,[],e=>e.geometryType()],worldview:[Vr,[],e=>e.globals.worldview||""],"is-active-floor":[Fr,Ss(Vr),(e,t)=>{if(!(e.globals&&e.globals.activeFloors&&e.globals.activeFloors.size>0))return !1;if(0===t.length)return !0;const r=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return r.has(n)})}],id:[Rr,[],e=>e.id()],zoom:[kr,[],e=>e.globals.zoom],pitch:[kr,[],e=>e.globals.pitch||0],"distance-from-center":[kr,[],e=>e.distanceFromCenter()],"measure-light":[kr,[Vr],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[kr,[],e=>e.globals.heatmapDensity||0],"line-progress":[kr,[],e=>e.globals.lineProgress||0],"raster-value":[kr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[kr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[kr,[],e=>e.globals.skyRadialProgress||0],accumulated:[Rr,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[kr,Ss(kr),(e,t)=>{let r=0;for(const n of t)r+=n.evaluate(e);return r}],"*":[kr,Ss(kr),(e,t)=>{let r=1;for(const n of t)r*=n.evaluate(e);return r}],"-":{type:kr,overloads:[[[kr,kr],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[kr],(e,[t])=>-t.evaluate(e)]]},"/":[kr,[kr,kr],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[kr,[kr,kr],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[kr,[],()=>Math.LN2],pi:[kr,[],()=>Math.PI],e:[kr,[],()=>Math.E],"^":[kr,[kr,kr],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[kr,[kr],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[kr,[kr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[kr,[kr],(e,[t])=>Math.log(t.evaluate(e))],log2:[kr,[kr],(e,[t])=>Math.log2(t.evaluate(e))],sin:[kr,[kr],(e,[t])=>Math.sin(t.evaluate(e))],cos:[kr,[kr],(e,[t])=>Math.cos(t.evaluate(e))],tan:[kr,[kr],(e,[t])=>Math.tan(t.evaluate(e))],asin:[kr,[kr],(e,[t])=>Math.asin(t.evaluate(e))],acos:[kr,[kr],(e,[t])=>Math.acos(t.evaluate(e))],atan:[kr,[kr],(e,[t])=>Math.atan(t.evaluate(e))],min:[kr,Ss(kr),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[kr,Ss(kr),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[kr,[kr],(e,[t])=>Math.abs(t.evaluate(e))],round:[kr,[kr],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[kr,[kr],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[kr,[kr],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Fr,[Vr,Rr],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[Fr,[Rr],(e,[t])=>e.id()===t.value],"filter-type-==":[Fr,[Vr],(e,[t])=>e.geometryType()===t.value],"filter-<":[Fr,[Vr,Rr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n{const r=e.id(),n=t.value;return typeof r==typeof n&&r":[Fr,[Vr,Rr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Fr,[Rr],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>n}],"filter-<=":[Fr,[Vr,Rr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Fr,[Rr],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<=n}],"filter->=":[Fr,[Vr,Rr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Fr,[Rr],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>=n}],"filter-has":[Fr,[Rr],(e,[t])=>t.value in e.properties()],"filter-has-id":[Fr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Fr,[Nr(Vr)],(e,[t])=>t.value.includes(e.geometryType())],"filter-id-in":[Fr,[Nr(Rr)],(e,[t])=>t.value.includes(e.id())],"filter-in-small":[Fr,[Vr,Nr(Rr)],(e,[t,r])=>r.value.includes(e.properties()[t.value])],"filter-in-large":[Fr,[Vr,Nr(Rr)],(e,[t,r])=>function(e,t,r,n){for(;r<=n;){const i=r+n>>1;if(t[i]===e)return !0;t[i]>e?n=i-1:r=i+1;}return !1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:Fr,overloads:[[[Fr,Fr],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[Ss(Fr),(e,t)=>{for(const r of t)if(!r.evaluate(e))return !1;return !0}]]},any:{type:Fr,overloads:[[[Fr,Fr],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[Ss(Fr),(e,t)=>{for(const r of t)if(r.evaluate(e))return !0;return !1}]]},"!":[Fr,[Fr],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Fr,[Vr],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return !r||r(t.evaluate(e))}],upcase:[Vr,[Vr],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Vr,[Vr],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Vr,Ss(Rr),(e,t)=>t.map(t=>rn(t.evaluate(e))).join("")],"resolved-locale":[Vr,[Lr],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[kr,[kr,kr,Rr],(e,t)=>{const[r,n,i]=t.map(t=>t.evaluate(e));if(r>n)return r;if(r===n)return r;let s;if("string"==typeof i)s=function(e){let t=0;if(0===e.length)return t;for(let r=0;rJSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){const t=e;return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function qs(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ws}function Hs(e,t,r,n,i){const s=new Ti(ws,[],t?function(e){const t={color:Dr,string:Vr,number:kr,enum:Vr,boolean:Fr,formatted:Or,resolvedImage:Ur};return "array"===e.type?Nr(t[e.value]||Rr,e.length):t[e.type]}(t):void 0,void 0,void 0,r,n,i),a=s.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return a?Ps(new $s(a,t,r,n,i)):zs(s.errors)}class Xs{constructor(e,t,r,n){this.kind=e,this._styleExpression=t,this.isLightConstant=r,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!wi(t.expression),this.configDependencies=Bs(t.expression),this.isIndoorDependent=Ts(t.expression);}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s,a){return this._styleExpression.evaluate(e,t,r,n,i,s,void 0,void 0,a)}}class Zs{constructor(e,t,r,n,i,s){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!wi(t.expression),this.isIndoorDependent=Ts(t.expression),this.isLightConstant=i,this.isLineProgressConstant=s,this.configDependencies=Bs(t.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s){return this._styleExpression.evaluate(e,t,r,n,i,s)}interpolationFactor(e,t,r){return this.interpolationType?Yi.interpolationFactor(this.interpolationType,e,t,r):0}}function Ws(e,t,r,n,i){if("error"===(e=Hs(e,t,r,n,i)).result)return e;const s=e.value.expression,a=vi(s);if(!a&&!ks(t))return zs([new Pr("","data expressions not supported")]);const o=_i(s,["zoom","pitch","distance-from-center"]);if(!o&&!Fs(t))return zs([new Pr("","zoom expressions not supported")]);const l=_i(s,["measure-light"]);if(!l&&!Vs(t))return zs([new Pr("","measure-light expression not supported")]);const u=_i(s,["line-progress"]);if(!u&&!function(e){return Es(e.expression,"line-progress")}(t))return zs([new Pr("","line-progress expression not supported")]);const c=t.expression&&t.expression.relaxZoomRestriction,h=Ks(s);return h||o||c?h instanceof Pr?zs([h]):h instanceof Yi&&!Ds(t)?zs([new Pr("",'"interpolate" expressions cannot be used with this property')]):Ps(h?new Zs(a&&u?"camera":"composite",e.value,h.labels,h instanceof Yi?h.interpolation:void 0,l,u):new Xs(a&&u?"constant":"source",e.value,l,u)):zs([new Pr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Ys{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,Ls(this._parameters,this._specification));}static deserialize(e){return new Ys(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function Ks(e){let t=null;if(e instanceof es)t=Ks(e.result);else if(e instanceof Ji){for(const r of e.args)if(t=Ks(r),t)break}else (e instanceof Ei||e instanceof Yi)&&e.input instanceof bn&&"zoom"===e.input.name&&(t=e);return t instanceof Pr||e.eachChild(e=>{const r=Ks(e);r instanceof Pr?t=r:t&&r&&t!==r&&(t=new Pr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));}),t}class Js{constructor(e,t,r){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){const t=new Int32Array(e);this.width=t[0],this.height=t[1],this.xCellCount=t[2],this.yCellCount=t[3],this.boxUid=t[4],this.circleUid=t[5];const r=this.xCellCount*this.yCellCount,n=[];for(let e=0;ethis.width||n<0||t>this.height)return s;const a=this._nextGen(),{boxCells:o,circleCells:l,boxKeys:u,circleKeys:c,bboxes:h,circles:d,boxSeen:p,circleSeen:f,xCellCount:m}=this,y=this._xCell(e),g=this._yCell(t),x=this._xCell(r),b=this._yCell(n);for(let v=y;v<=x;v++)for(let y=g;y<=b;y++){const g=m*y+v,x=o[g];if(x)for(let o=0;o=d&&n>=f&&(!i||i(u[l]))&&s.push({key:u[l],x1:d,y1:f,x2:m,y2:y});}const b=l[g];if(b)for(let o=0;othis.width||n<0||t>this.height)return s;const a=this._nextGen(),{boxCells:o,boxKeys:l,bboxes:u,boxSeen:c,xCellCount:h,xScale:d,yScale:p}=this,f=this._xCell(e),m=this._yCell(t),y=this._xCell(r),g=this._yCell(n);for(let x=f;x<=y;x++)for(let f=m;f<=g;f++){if(i&&!i(x/d,f/p,(x+1)/d,(f+1)/p))continue;const m=o[h*f+x];if(m)for(let o=0;o=p&&n>=f)&&s.push(l[h]);}}return s}hitTest(e,t,r,n,i){if(r<0||e>this.width||n<0||t>this.height)return !1;const s=this._nextGen(),{boxCells:a,circleCells:o,boxKeys:l,circleKeys:u,bboxes:c,circles:h,boxSeen:d,circleSeen:p,xCellCount:f}=this,m=this._xCell(e),y=this._yCell(t),g=this._xCell(r),x=this._yCell(n);for(let b=m;b<=g;b++)for(let m=y;m<=x;m++){const y=f*m+b,g=a[y];if(g)for(let a=0;a=c[u]&&n>=c[u+1]&&(!i||i(l[o])))return !0}const x=o[y];if(x)for(let a=0;athis.width||o<0||s>this.height)return !1;const l=this._nextGen(),{boxCells:u,circleCells:c,boxKeys:h,circleKeys:d,bboxes:p,circles:f,boxSeen:m,circleSeen:y,xCellCount:g}=this,x=this._xCell(i),b=this._yCell(s),v=this._xCell(a),w=this._yCell(o);for(let i=x;i<=v;i++)for(let s=b;s<=w;s++){const a=g*s+i,o=u[a];if(o)for(let i=0;i>>0,0===this.generation&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}_circlesCollide(e,t,r,n,i,s){const a=n-e,o=i-t,l=r+s;return l*l>a*a+o*o}_circleAndRectCollide(e,t,r,n,i,s,a){const o=(s-n)/2,l=Math.abs(e-(n+o));if(l>o+r)return !1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+r)return !1;if(l<=o||c<=u)return !0;const h=l-o,d=c-u;return h*h+d*d<=r*r}}const Qs={};function ea(e,t,r={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),Qs[t]={klass:e,omit:r.omit||[]};}ea(Object,"Object"),ea(Js,"Grid"),delete _e.prototype.constructor,ea(Ar,"Color"),ea(Error,"Error"),ea(Yr,"Formatted"),ea(Wr,"FormattedSection"),ea(Qt,"AJAXError"),ea(Jr,"ResolvedImage"),ea(Ys,"StylePropertyFunction"),ea($s,"StyleExpression",{omit:["_evaluator"]}),ea(gr,"ImageId"),ea(Kr,"ImageVariant"),ea(Zs,"ZoomDependentExpression"),ea(Xs,"ZoomConstantExpression"),ea(bn,"CompoundExpression",{omit:["_evaluate"]});for(const e in ws)Qs[ws[e]._classRegistryKey]||ea(ws[e],`Expression${e}`);function ta(e){return e&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function ra(e,t){if(null===e)return null;const r=typeof e;if("object"!==r)return "bigint"===r?{$name:"BigInt",value:e.toString()}:e;if(Array.isArray(e)){const r=e.length,n=[];n.length=r;for(let i=0;ie>=1536&&e<=1791,sa=e=>e>=1872&&e<=1919,aa=e=>e>=2208&&e<=2303,oa=e=>e>=11904&&e<=12031,la=e=>e>=12032&&e<=12255,ua=e=>e>=12272&&e<=12287,ca=e=>e>=12288&&e<=12351,ha=e=>e>=12352&&e<=12447,da=e=>e>=12448&&e<=12543,pa=e=>e>=12544&&e<=12591,fa=e=>e>=12704&&e<=12735,ma=e=>e>=12736&&e<=12783,ya=e=>e>=12784&&e<=12799,ga=e=>e>=12800&&e<=13055,xa=e=>e>=13056&&e<=13311,ba=e=>e>=13312&&e<=19903,va=e=>e>=19968&&e<=40959,wa=e=>e>=40960&&e<=42127,_a=e=>e>=42128&&e<=42191,Aa=e=>e>=44032&&e<=55215,Ia=e=>e>=63744&&e<=64255,Ma=e=>e>=64336&&e<=65023,Sa=e=>e>=65040&&e<=65055,Ba=e=>e>=65072&&e<=65103,Ta=e=>e>=65104&&e<=65135,Pa=e=>e>=65136&&e<=65279,za=e=>e>=65280&&e<=65519;function Ea(e){for(const t of e)if(Da(t.charCodeAt(0)))return !0;return !1}function ka(e){for(const t of e)if(!Va(t.charCodeAt(0)))return !1;return !0}function Va(e){return !(ia(e)||sa(e)||aa(e)||Ma(e)||Pa(e))}function Fa(e){return !(e<11904||!(fa(e)||pa(e)||Ba(e)||Ia(e)||xa(e)||oa(e)||ma(e)||ca(e)||ba(e)||va(e)||ga(e)||za(e)||ha(e)||ua(e)||la(e)||ya(e)||da(e)||Sa(e)||_a(e)||wa(e)))}function Da(e){return !(746!==e&&747!==e&&(e<4352||!(fa(e)||pa(e)||Ba(e)&&!(e>=65097&&e<=65103)||Ia(e)||xa(e)||oa(e)||ma(e)||!(!ca(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||ba(e)||va(e)||ga(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||Aa(e)||ha(e)||ua(e)||(e=>e>=12688&&e<=12703)(e)||la(e)||ya(e)||da(e)&&12540!==e||!(!za(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Ta(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||Sa(e)||(e=>e>=19904&&e<=19967)(e)||wa(e)||_a(e))))}function Ca(e){return 12312===e||12313===e||12316===e||12540===e||12448===e}function Ra(e){return !(Da(e)||function(e){return !!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||ca(e)||da(e)||(e=>e>=57344&&e<=63743)(e)||Ba(e)||Ta(e)||za(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function La(e){return ia(e)||sa(e)||aa(e)||Ma(e)||Pa(e)}function Oa(e){return e>=1424&&e<=2303||Ma(e)||Pa(e)}function Ua(e,t){return !(!t&&Oa(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Na(e){for(const t of e)if(Oa(t.charCodeAt(0)))return !0;return !1}const ja={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Ga=null,$a=ja.unavailable,qa=null;const Ha=function(e){e&&($a=ja.error),Ga&&Ga(e);};function Xa(){Za.fire(new dr("pluginStateChange",{pluginStatus:$a,pluginURL:qa}));}const Za=new yr,Wa=function(){return $a},Ya=function(){if($a!==ja.deferred||!qa)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");$a=ja.loading,Xa(),qa&&ar({url:qa},e=>{e?Ha(e):($a=ja.loaded,Xa());});},Ka={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>$a===ja.loaded||null!=Ka.applyArabicShaping,isLoading:()=>$a===ja.loading,setState(e){$a=e.pluginStatus,qa=e.pluginURL;},isParsing:()=>$a===ja.parsing,isParsed:()=>$a===ja.parsed,getPluginURL:()=>qa},Ja=function(){Ka.isLoading()||Ka.isLoaded()||"deferred"!==Wa()||Ya();};class Qa{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const r of e)if(!Ua(r.charCodeAt(0),t))return !1;return !0}(e,Ka.isLoaded())}}class eo{constructor(e,t,r,n,i){this.property=e,this.value=t,this.expression=function(e,t,r,n,i){if(Cs(e))return new Ys(e,t);if(qs(e)||Array.isArray(e)&&e.length>0){const s=Ws(e,t,r,n,i);if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));return s.value}{let r=e;return "string"==typeof e&&"color"===t.type&&(r=Ar.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>r}}}(void 0===t?e.specification.default:t,e.specification,r,n,i);}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,r,n){return this.property.possiblyEvaluate(this,e,t,r,n)}}class to{constructor(e,t,r,n){this.property=e,this.value=new eo(e,void 0,t,r,n);}transitioned(e,t){return new no(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new no(this.property,this.value,null,{},0)}}class ro{constructor(e,t,r,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return st(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new to(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new eo(this._values[e].property,null===t?void 0:st(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent());}setTransitionOrValue(e,t){t&&(this._options=t);const r=this._properties.properties;if(e)for(const t in e){const n=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);r[e]&&this.setTransition(e,n);}else Object.hasOwn(r,t)&&this.setValue(t,n);}}getTransition(e){return st(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new to(this._values[e].property)),this._values[e].transition=st(t)||void 0;}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);const n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n);}return e}transitioned(e,t){const r=new io(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(e,t._values[n]);return r}untransitioned(){const e=new io(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class no{constructor(e,t,r,n,i){const s=n.delay||0,a=n.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+s,this.end=this.begin+a,e.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(e,t,r){const n=e.now||0,i=this.value.possiblyEvaluate(e,t,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function_stop":{"type":"array","minimum":0,"maximum":24,"length":2,"value":["number","color"]},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"camera":{"camera-projection":{"type":"enum","default":"perspective","values":{"perspective":1,"orthographic":1},"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"colorTheme":{"data":{"type":"string","expression":1}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"projection":{"name":{"type":"enum","default":"mercator","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1}},"center":{"type":"array","minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"parallels":{"type":"array","minimum":[-90,-90],"maximum":[90,90],"length":2,"value":"number"}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-outline-color":{"type":"color","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","default":"flat","values":{"terrain":1,"flat":1}},"fill-extrusion-base-alignment":{"type":"enum","default":"terrain","values":{"terrain":1,"flat":1}},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-extrusion-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"fill-extrusion-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":1},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"use-theme":1,"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"building-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"building-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-dasharray":{"type":"array","minimum":0,"value":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-trim-offset":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number"},"line-trim-fade-range":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-trim-color":{"type":"color","default":"transparent","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-blend-mode":{"type":"enum","default":"default","values":{"default":1,"multiply":1,"additive":1},"expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"circle-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"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"],"expression":{"interpolated":1,"parameters":["heatmap-density"]},"use-theme":1},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"icon-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1,"overridable":1},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"text-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"text-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":1},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven","appearance":1}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-value"]},"use-theme":1},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-range":{"type":"array","length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-hue-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-resampling":{"type":"enum","default":"linear","values":{"linear":1,"nearest":1},"expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-elevation-reference":{"type":"enum","default":"sea","values":{"sea":1,"ground":1},"expression":1}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-particle-speed"]},"use-theme":1},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":1,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"hillshade-shadow-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-accent-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_background":{"background-pitch-alignment":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_sky":{"sky-type":{"type":"enum","default":"atmosphere","values":{"gradient":1,"atmosphere":1},"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":1,"parameters":["sky-radial-progress"]},"use-theme":1},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":1},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":1},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-rotation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-scale":{"type":"array","default":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-translation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"model-color-mix-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-type":{"type":"enum","default":"common-3d","values":{"common-3d":1,"location-indicator":1}},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"model-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"model-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"model-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"model-line-cutout-mode":{"type":"enum","default":"enabled","values":{"enabled":1,"disabled":1,"enabled-above-cutout":1},"expression":1}},"promoteId":{"*":{"type":"*"}}}');function fo(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function mo(e){if(Array.isArray(e))return e.map(mo);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={},r=e;for(const e in r)t[e]=mo(r[e]);return t}return fo(e)}function yo(e){if(!0===e||!1===e)return !0;if(!Array.isArray(e)||0===e.length)return !1;switch(e[0]){case "has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case "in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case "any":case "all":for(const t of e.slice(1))if(!yo(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function go(e,t="",r=null,n="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};yo(e)||(e=Io(e));const i=e;let s=!0;try{s=function(e){if(!vo(e))return e;let t=mo(e);return bo(t),t=xo(t),t}(i);}catch(e){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 `);}let a=null,o=null;if("background"!==n&&"sky"!==n&&"slot"!==n){o=po[`filter_${n}`];const e=Hs(s,o,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(t,r,n)=>e.value.evaluate(t,r,{},n);}let l=null,u=null;if(s!==i){const e=Hs(i,o,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,r,n,i,s)=>e.value.evaluate(t,r,{},n,void 0,void 0,i,s),u=!vi(e.value.expression);}return {filter:a,dynamicFilter:l||void 0,needGeometry:Ao(s),needFeature:!!u}}function xo(e){if(!Array.isArray(e))return e;const t=function(e){if(wo.has(e[0]))for(let t=1;txo(e))}function bo(e){let t=!1;const r=[];if("case"===e[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function _o(e,t){return et?1:0}function Ao(e){if(!Array.isArray(e))return !1;if("within"===e[0]||"distance"===e[0])return !0;for(let t=1;t"===t||"<="===t||">="===t?Mo(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(Io))):"all"===t?["all"].concat(e.slice(1).map(Io)):"none"===t?["all"].concat(e.slice(1).map(Io).map(To)):"in"===t?So(e[1],e.slice(2)):"!in"===t?To(So(e[1],e.slice(2))):"has"===t?Bo(e[1]):"!has"!==t||To(Bo(e[1]));var r;}function Mo(e,t,r){switch(e){case "$type":return [`filter-type-${r}`,t];case "$id":return [`filter-id-${r}`,t];default:return [`filter-${r}`,e,t]}}function So(e,t){if(0===t.length)return !1;switch(e){case "$type":return ["filter-type-in",["literal",t]];case "$id":return ["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(_o)]]:["filter-in-small",e,["literal",t]]}}function Bo(e){switch(e){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",e]}}function To(e){return ["!",e]}const Po="";function zo(e,t){return t?`${e}${Po}${t}`:e}function Eo(e){const t=e.indexOf(Po);return t>=0?e.slice(t+1):""}let ko;const Vo=()=>ko||(ko=new ho({"icon-size":new uo(po.layout_symbol["icon-size"]),"icon-image":new uo(po.layout_symbol["icon-image"]),"icon-rotate":new uo(po.layout_symbol["icon-rotate"]),"icon-offset":new uo(po.layout_symbol["icon-offset"]),"text-size":new uo(po.layout_symbol["text-size"]),"text-rotate":new uo(po.layout_symbol["text-rotate"]),"text-offset":new uo(po.layout_symbol["text-offset"])}));let Fo;const Do=()=>Fo||(Fo=new ho({"icon-opacity":new uo(po.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new uo(po.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new uo(po.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new uo(po.paint_symbol["text-emissive-strength"]),"icon-color":new uo(po.paint_symbol["icon-color"]),"icon-halo-color":new uo(po.paint_symbol["icon-halo-color"]),"icon-halo-width":new uo(po.paint_symbol["icon-halo-width"]),"icon-halo-blur":new uo(po.paint_symbol["icon-halo-blur"]),"icon-translate":new uo(po.paint_symbol["icon-translate"]),"text-opacity":new uo(po.paint_symbol["text-opacity"]),"text-occlusion-opacity":new uo(po.paint_symbol["text-occlusion-opacity"]),"text-color":new uo(po.paint_symbol["text-color"],{runtimeType:Dr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new uo(po.paint_symbol["text-halo-color"]),"text-halo-width":new uo(po.paint_symbol["text-halo-width"]),"text-halo-blur":new uo(po.paint_symbol["text-halo-blur"]),"text-translate":new uo(po.paint_symbol["text-translate"]),"symbol-z-offset":new uo(po.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}));class Co{constructor(e,t,r,n,i,s){this._conditionSpec=e,this._propertiesSpec=r;const a=Hs(e,po.appearance.condition);if("success"===a.result&&(this.condition=a.value),this.name=t,r){this.layoutProperties=new oo(Vo()),this.unevaluatedLayout=new so(Vo(),n,i,s),this.paintProperties=new oo(Do()),this.unevaluatedPaint=new so(Do(),n,i,"");for(const e in r)e in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(e,r[e]):e in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(e,r[e]);}}isActive(e){return !(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,t,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""));}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},r=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},n=Object.assign({},t,r);return Object.keys(n).length>0&&(e.properties=n),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),n=this.hasLayoutProperty("icon-rotate");return e||t||r||n}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return e||t||r}hasIconPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasTextPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&void 0!==this.unevaluatedLayout._values[e].value}hasPaintProperty(e){return this.unevaluatedPaint&&void 0!==this.unevaluatedPaint._values[e].value}}const Ro="-transition",Lo=new Set(["fill","line","background","hillshade","raster"]);class Oo extends yr{constructor(e,t,r,n,i,s){if(super(),this.id=e.id,this.fqid=zo(this.id,r),this.type=e.type,this.scope=r,this.lut=n,this.options=i,this.iconImageUseTheme=s,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==e.type){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;const t=Hs(this.filter,po[`filter_${e.type}`]);"error"!==t.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...t.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||t.value.isIndoorDependent);}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new so(t.layout,this.scope,i,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new ro(t.paint,this.scope,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new oo(t.paint);}}}onAdd(e){}onRemove(e){}isDraped(e){return !this.is3D(!0)&&Lo.has(this.type)}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility());}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new Co(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme));}),this.appearancesVersion++;}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}));}getPaintProperty(e){return e.endsWith(Ro)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return !!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const r=this._transitionablePaint,n=r._properties.properties;if(e.endsWith(Ro)){const i=e.slice(0,-11);return n[i]&&r.setTransition(i,t||void 0),!1}if(!n[e])return !1;const i=r._values[e],s=i.value.isDataDriven(),a=i.value;r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const o=r._values[e].value,l=o.isDataDriven(),u=e.endsWith("pattern")||"line-dasharray"===e;return l||s||u||this._handleOverridablePaintPropertyUpdate(e,a,o)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,r){return null}_handleOverridablePaintPropertyUpdate(e,t,r){return !1}isHidden(e){return !!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){const e={id:this.id,type:this.type,slot:this.slot,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 0!==this.appearances.length&&(e.appearances=this.appearances.map(e=>e.serialize())),it(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}is3D(e){return !1}hasElevation(){return !1}mayUse(e){return !1}prepare(){return Promise.resolve()}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof ao&&ks(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}for(const e of this.appearances)if(!wi(e.condition.expression))return !0;return !1}compileFilter(e){this._filterCompiled||(this._featureFilter=go(this.filter,this.scope,e),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,r){return {}}queryRadius(e){}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){}}function Uo(e,t,r){if(!e._unevaluatedLayout)return !1;const n=e._unevaluatedLayout.getValue(t);return void 0!==n&&("string"!=typeof n||r(n))}function No(e,t,r=2){const n=t&&t.length,i=n?t[0]*r:e.length;let s=jo(e,0,i,r,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,u;if(n&&(s=function(e,t,r,n){const i=[];for(let r=0,s=t.length;r80*r){o=e[0],l=e[1];let t=o,n=l;for(let s=r;st&&(t=r),i>n&&(n=i);}u=Math.max(t-o,n-l),u=0!==u?32767/u:0;}return $o(s,a,r,o,l,u,0),a}function jo(e,t,r,n,i){let s;if(i===function(e,t,r,n){let i=0;for(let s=t,a=r-n;s0)for(let i=t;i=t;i-=n)s=cl(i/n|0,e[i],e[i+1],s);return s&&il(s,s.next)&&(hl(s),s=s.next),s}function Go(e,t){if(!e)return e;t||(t=e);let r,n=e;do{if(r=!1,n.steiner||!il(n,n.next)&&0!==nl(n.prev,n,n.next))n=n.next;else {if(hl(n),n=t=n.prev,n===n.next)break;r=!0;}}while(r||n!==t);return t}function $o(e,t,r,n,i,s,a){if(!e)return;!a&&s&&function(e,t,r,n){let i=e;do{0===i.z&&(i.z=Jo(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,r=1;do{let n,i=e;e=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let e=0;e0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(t>1)}(i);}(e,n,i,s);let o=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(s?Ho(e,n,i,s):qo(e))t.push(l.i,e.i,u.i),hl(e),e=u.next,o=u.next;else if((e=u)===o){a?1===a?$o(e=Xo(Go(e),t),t,r,n,i,s,2):2===a&&Zo(e,t,r,n,i,s):$o(Go(e),t,r,n,i,s,1);break}}}function qo(e){const t=e.prev,r=e,n=e.next;if(nl(t,r,n)>=0)return !1;const i=t.x,s=r.x,a=n.x,o=t.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),d=Math.max(i,s,a),p=Math.max(o,l,u);let f=n.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&tl(i,o,s,l,a,u,f.x,f.y)&&nl(f.prev,f,f.next)>=0)return !1;f=f.next;}return !0}function Ho(e,t,r,n){const i=e.prev,s=e,a=e.next;if(nl(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,d=a.y,p=Math.min(o,l,u),f=Math.min(c,h,d),m=Math.max(o,l,u),y=Math.max(c,h,d),g=Jo(p,f,t,r,n),x=Jo(m,y,t,r,n);let b=e.prevZ,v=e.nextZ;for(;b&&b.z>=g&&v&&v.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==a&&tl(o,c,l,h,u,d,b.x,b.y)&&nl(b.prev,b,b.next)>=0)return !1;if(b=b.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==a&&tl(o,c,l,h,u,d,v.x,v.y)&&nl(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;b&&b.z>=g;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==a&&tl(o,c,l,h,u,d,b.x,b.y)&&nl(b.prev,b,b.next)>=0)return !1;b=b.prevZ;}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==a&&tl(o,c,l,h,u,d,v.x,v.y)&&nl(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function Xo(e,t){let r=e;do{const n=r.prev,i=r.next.next;!il(n,i)&&sl(n,r,r.next,i)&&ll(n,i)&&ll(i,n)&&(t.push(n.i,r.i,i.i),hl(r),hl(r.next),r=e=i),r=r.next;}while(r!==e);return Go(r)}function Zo(e,t,r,n,i,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&rl(a,e)){let o=ul(a,e);return a=Go(a,a.next),o=Go(o,o.next),$o(a,t,r,n,i,s,0),void $o(o,t,r,n,i,s,0)}e=e.next;}a=a.next;}while(a!==e)}function Wo(e,t){let r=e.x-t.x;return 0===r&&(r=e.y-t.y,0===r)&&(r=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),r}function Yo(e,t){const r=function(e,t){let r=t;const n=e.x,i=e.y;let s,a=-1/0;if(il(e,r))return r;do{if(il(e,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const e=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=n&&e>a&&(a=e,s=r.x=r.x&&r.x>=l&&n!==r.x&&el(is.x||r.x===s.x&&Ko(s,r)))&&(s=r,c=t);}r=r.next;}while(r!==o);return s}(e,t);if(!r)return t;const n=ul(r,e);return Go(n,n.next),Go(r,r.next)}function Ko(e,t){return nl(e.prev,e,t.prev)<0&&nl(t.next,e,e.next)<0}function Jo(e,t,r,n,i){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Qo(e){let t=e,r=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(n-o)>=(r-a)*(t-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function tl(e,t,r,n,i,s,a,o){return !(e===a&&t===o)&&el(e,t,r,n,i,s,a,o)}function rl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&sl(r,r.next,e,t))return !0;r=r.next;}while(r!==e);return !1}(e,t)&&(ll(e,t)&&ll(t,e)&&function(e,t){let r=e,n=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==e);return n}(e,t)&&(nl(e.prev,e,t.prev)||nl(e,t.prev,t))||il(e,t)&&nl(e.prev,e,e.next)>0&&nl(t.prev,t,t.next)>0)}function nl(e,t,r){return (t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function il(e,t){return e.x===t.x&&e.y===t.y}function sl(e,t,r,n){const i=ol(nl(e,t,r)),s=ol(nl(e,t,n)),a=ol(nl(r,n,e)),o=ol(nl(r,n,t));return i!==s&&a!==o||!(0!==i||!al(e,r,t))||!(0!==s||!al(e,n,t))||!(0!==a||!al(r,e,n))||!(0!==o||!al(r,t,n))}function al(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function ol(e){return e>0?1:e<0?-1:0}function ll(e,t){return nl(e.prev,e,e.next)<0?nl(e,t,e.next)>=0&&nl(e,e.prev,t)>=0:nl(e,t,e.prev)<0||nl(e,e.next,t)<0}function ul(e,t){const r=dl(e.i,e.x,e.y),n=dl(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function cl(e,t,r,n){const i=dl(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function hl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function dl(e,t,r){return {i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function pl(e,t,r=1){if(!e)return null;const n="string"==typeof e?Jr.from(e).getPrimary():e.getPrimary(),i="string"==typeof e?null:e.getSecondary();for(const e of [n,i]){if(!e)continue;const n=e.id.toString();t.has(n)||t.set(n,[]),e.scaleSelf(r),t.get(n).push(e);}return {primary:n.toString(),secondary:i?i.toString():null}}function fl(e,t,r,n){const i=n.patternDependencies;let s=!1;for(const n of t){const t=n.paint.get(`${e}-pattern`);t.isConstant()||(s=!0),pl(t.constantOr(null),i,r)&&(s=!0);}return s}function ml(e,t,r,n,i,s){const a=s.patternDependencies;for(const o of t){const t=o.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){const e=pl(t.evaluate({zoom:n},r,{},void 0,s.availableImages),a,i);if(!e)continue;const{primary:l,secondary:u}=e;l&&(r.patterns[o.id]=[l,u].filter(Boolean));}}return r}const yl=Xn/Math.PI/2,gl=64,xl=[gl,32,16],bl=-yl,vl=yl;function wl(e,t,r,n=yl){return r=Ge(r),[e*Math.sin(r)*n,-t*n,e*Math.cos(r)*n]}function _l(e,t,r){return wl(Math.cos(Ge(e)),Math.sin(Ge(e)),t,r)}const Al=6371008.8,Il=2*Math.PI*Al;class Ml{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ml(Ye(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,n=e.lat*t,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Al*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,r=t/Math.cos(Math.PI/180*this.lat);return new Sl({lng:this.lng-r,lat:this.lat-t},{lng:this.lng+r,lat:this.lat+t})}toEcef(e){return _l(this.lat,this.lng,yl+e*yl/Al)}static convert(e){if(e instanceof Ml)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Ml(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Ml(Number("lng"in e?e.lng:e.lon),Number(e.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 [, ]")}}class Sl{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]));}setNorthEast(e){return this._ne=e instanceof Ml?new Ml(e.lng,e.lat):Ml.convert(e),this}setSouthWest(e){return this._sw=e instanceof Ml?new Ml(e.lng,e.lat):Ml.convert(e),this}extend(e){const t=this._sw,r=this._ne;let n,i;if(e instanceof Ml)n=e,i=e;else {if(!(e instanceof Sl))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Sl.convert(e)):this.extend(Ml.convert(e)):"object"==typeof e&&null!==e&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(Ml.convert(e)):this;if(n=e._sw,i=e._ne,!n||!i)return this}return t||r?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new Ml(n.lng,n.lat),this._ne=new Ml(i.lng,i.lat)),this}getCenter(){return new Ml((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 Ml(this.getWest(),this.getNorth())}getSouthEast(){return new Ml(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:t,lat:r}=Ml.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(e){if(e)return e instanceof Sl?e:new Sl(e)}}function Bl(e){return Il*Math.cos(e*Math.PI/180)}function Tl(e,t){return e/Bl(t)}function Pl(e,t){return e*Bl(Mn(t))}const zl=85.051129;function El(e){return Math.cos(Ge(Ze(e,-85.051129,zl)))}function kl(e,t){const r=Ze(t,0,25.5),n=Math.pow(2,r);return El(e)*Il/(512*n)}function Vl(e){return 1/Math.cos(e*Math.PI/180)}function Fl(e,t=0){const r=Math.exp(Math.PI*(1-(e.y+t/Xn)/(1<=l?(Cl(e,t,r,u,c,s,h,o,l),Cl(e,u,c,n,i,h,a,o,l)):e.push(a);}function Rl(e,t,r){let n=e[0],i=n.x,s=n.y;t(n);const a=[n];for(let o=1;oe.x+1||ne.y+1)&<("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Gl(e,t,r){const n=e.loadGeometry(),i=e.extent,s=Xn/i;if(t&&r&&r.projection.isReprojectedInTileSpace){const s=1<{const r=In((t.x+e.x/i)/s),n=Mn((t.y+e.y/i)/s),c=u.project(r,n);e.x=(c.x*a-o)*i,e.y=(c.y*a-l)*i;};for(let t=0;t=i||r.y<0||r.y>=i||(c(r),e.push(r));n[t]=e;}}for(const e of n)for(const t of e)jl(t,s);return n}function $l(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?Gl(e):[]}}const ql={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Hl{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}const Xl=new ArrayBuffer(0);class Zl{constructor(){this._reallocCount=0,this.capacity=0,this.length=0;}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=Xl),t._refreshViews(),t}_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(e){this.reserve(e),this.length=e;}resizeExact(e){this.reserveExact(e),this.length=e;}reserve(e){e>this.capacity&&this._allocate(Math.max(e,Math.floor(5*this.capacity),128));}reserveExact(e){(e>this.capacity||!this.arrayBuffer)&&this._allocate(e);}_allocate(e){this._reallocCount++,this.capacity=e,this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}reserveForAdditional(e){this.reserve(this.length+e);}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() 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 Wl(e,t=1){let r=0,n=0;return {members:e.map(e=>{const i=ql[e.type].BYTES_PER_ELEMENT,s=r=Yl(r,Math.max(t,i)),a=e.components||1;return n=Math.max(n,i),r+=i*a,{name:e.name,type:e.type,components:a,offset:s}}),size:Yl(r,Math.max(n,t)),alignment:t}}function Yl(e,t){return Math.ceil(e/t)*t}class Kl extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=r,e}}Kl.prototype.bytesPerElement=4,ea(Kl,"StructArrayLayout2i4");class Jl extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}Jl.prototype.bytesPerElement=6,ea(Jl,"StructArrayLayout3i6");class Ql extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}Ql.prototype.bytesPerElement=8,ea(Ql,"StructArrayLayout2i2ui8");class eu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}eu.prototype.bytesPerElement=4,ea(eu,"StructArrayLayout1f4");class tu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e,s=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.float32[s+1]=n,e}}tu.prototype.bytesPerElement=8,ea(tu,"StructArrayLayout2i1f8");class ru extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}ru.prototype.bytesPerElement=8,ea(ru,"StructArrayLayout3i8");class nu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,e}}nu.prototype.bytesPerElement=8,ea(nu,"StructArrayLayout4i8");class iu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=5*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,e}}iu.prototype.bytesPerElement=10,ea(iu,"StructArrayLayout5i10");class su extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=s,this.uint8[u+7]=a,this.float32[c+2]=o,e}}su.prototype.bytesPerElement=12,ea(su,"StructArrayLayout2i4ub1f12");class au extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=r,this.float32[i+2]=n,e}}au.prototype.bytesPerElement=12,ea(au,"StructArrayLayout3f12");class ou extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=6*e,o=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,this.float32[o+2]=s,e}}ou.prototype.bytesPerElement=12,ea(ou,"StructArrayLayout4ui1f12");class lu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.uint16[s+0]=t,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}lu.prototype.bytesPerElement=8,ea(lu,"StructArrayLayout4ui8");class uu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=6*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,e}}uu.prototype.bytesPerElement=12,ea(uu,"StructArrayLayout6i12");class cu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,n,i,s,a,o,l,u,c,h)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=r,this.int16[p+2]=n,this.int16[p+3]=i,this.uint16[p+4]=s,this.uint16[p+5]=a,this.uint16[p+6]=o,this.uint16[p+7]=l,this.int16[p+8]=u,this.int16[p+9]=c,this.int16[p+10]=h,this.int16[p+11]=d,e}}cu.prototype.bytesPerElement=24,ea(cu,"StructArrayLayout4i4ui4i24");class hu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=10*e,l=5*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,e}}hu.prototype.bytesPerElement=20,ea(hu,"StructArrayLayout3i3f20");class du extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,e}}du.prototype.bytesPerElement=16,ea(du,"StructArrayLayout4f16");class pu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}pu.prototype.bytesPerElement=4,ea(pu,"StructArrayLayout1ul4");class fu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,e}}fu.prototype.bytesPerElement=4,ea(fu,"StructArrayLayout2ui4");class mu extends Zl{_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(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,r,n,i,s,a,o,l,u,c,h,d)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.int16[f+4]=s,this.float32[m+3]=a,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[f+14]=c,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}mu.prototype.bytesPerElement=40,ea(mu,"StructArrayLayout5i4f1i1ul2ui40");class yu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=s,this.int16[l+6]=a,this.int16[l+7]=o,e}}yu.prototype.bytesPerElement=16,ea(yu,"StructArrayLayout3i2i2i16");class gu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=4*e,o=8*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,e}}gu.prototype.bytesPerElement=16,ea(gu,"StructArrayLayout2f1f2i16");class xu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=20*e,l=5*e;return this.uint8[o+0]=t,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,e}}xu.prototype.bytesPerElement=20,ea(xu,"StructArrayLayout2ub4f20");class bu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,this.uint16[i+2]=n,e}}bu.prototype.bytesPerElement=6,ea(bu,"StructArrayLayout3ui6");class vu extends Zl{_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(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v){const w=this.length;return this.resize(w+1),this.emplace(w,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v,w){const _=30*e,A=15*e,I=60*e;return this.int16[_+0]=t,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[A+2]=i,this.float32[A+3]=s,this.uint16[_+8]=a,this.uint16[_+9]=o,this.uint32[A+5]=l,this.uint32[A+6]=u,this.uint32[A+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=d,this.uint16[_+18]=p,this.float32[A+10]=f,this.float32[A+11]=m,this.uint8[I+48]=y,this.uint8[I+49]=g,this.uint8[I+50]=x,this.uint32[A+13]=b,this.int16[_+28]=v,this.uint8[I+58]=w,e}}vu.prototype.bytesPerElement=60,ea(vu,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class wu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v,w,_,A,I,M,S,B,T,P,z,E,k){const V=this.length;return this.resize(V+1),this.emplace(V,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v,w,_,A,I,M,S,B,T,P,z,E,k)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v,w,_,A,I,M,S,B,T,P,z,E,k,V){const F=20*e,D=40*e,C=80*e;return this.float32[F+0]=t,this.float32[F+1]=r,this.int16[D+4]=n,this.int16[D+5]=i,this.int16[D+6]=s,this.int16[D+7]=a,this.int16[D+8]=o,this.int16[D+9]=l,this.int16[D+10]=u,this.int16[D+11]=c,this.int16[D+12]=h,this.uint16[D+13]=d,this.uint16[D+14]=p,this.uint16[D+15]=f,this.uint16[D+16]=m,this.uint16[D+17]=y,this.uint16[D+18]=g,this.uint16[D+19]=x,this.uint16[D+20]=b,this.uint16[D+21]=v,this.uint16[D+22]=w,this.uint16[D+23]=_,this.uint16[D+24]=A,this.uint16[D+25]=I,this.uint16[D+26]=M,this.uint16[D+27]=S,this.uint32[F+14]=B,this.float32[F+15]=T,this.float32[F+16]=P,this.float32[F+17]=z,this.float32[F+18]=E,this.uint8[C+76]=k,this.uint16[D+39]=V,e}}wu.prototype.bytesPerElement=80,ea(wu,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class _u extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=6*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=n,this.float32[o+3]=i,this.float32[o+4]=s,this.float32[o+5]=a,e}}_u.prototype.bytesPerElement=24,ea(_u,"StructArrayLayout6f24");class Au extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=s,e}}Au.prototype.bytesPerElement=20,ea(Au,"StructArrayLayout5f20");class Iu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=s,this.float32[l+5]=a,this.float32[l+6]=o,e}}Iu.prototype.bytesPerElement=28,ea(Iu,"StructArrayLayout7f28");class Mu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,n,i,s,a,o,l,u,c)}emplace(e,t,r,n,i,s,a,o,l,u,c,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=r,this.float32[d+2]=n,this.float32[d+3]=i,this.float32[d+4]=s,this.float32[d+5]=a,this.float32[d+6]=o,this.float32[d+7]=l,this.float32[d+8]=u,this.float32[d+9]=c,this.float32[d+10]=h,e}}Mu.prototype.bytesPerElement=44,ea(Mu,"StructArrayLayout11f44");class Su extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,n,i,s,a,o,l)}emplace(e,t,r,n,i,s,a,o,l,u){const c=9*e;return this.float32[c+0]=t,this.float32[c+1]=r,this.float32[c+2]=n,this.float32[c+3]=i,this.float32[c+4]=s,this.float32[c+5]=a,this.float32[c+6]=o,this.float32[c+7]=l,this.float32[c+8]=u,e}}Su.prototype.bytesPerElement=36,ea(Su,"StructArrayLayout9f36");class Bu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=r,e}}Bu.prototype.bytesPerElement=8,ea(Bu,"StructArrayLayout2f8");class Tu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=6*e;return this.uint32[3*e+0]=t,this.uint16[s+2]=r,this.uint16[s+3]=n,this.uint16[s+4]=i,e}}Tu.prototype.bytesPerElement=12,ea(Tu,"StructArrayLayout1ul3ui12");class Pu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Pu.prototype.bytesPerElement=2,ea(Pu,"StructArrayLayout1ui2");class zu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=s,this.float32[g+5]=a,this.float32[g+6]=o,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=y,e}}zu.prototype.bytesPerElement=64,ea(zu,"StructArrayLayout16f64");class Eu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=s,this.float32[u+3]=a,this.float32[u+4]=o,e}}Eu.prototype.bytesPerElement=20,ea(Eu,"StructArrayLayout4ui3f20");class ku extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}ku.prototype.bytesPerElement=2,ea(ku,"StructArrayLayout1i2");class Vu extends Zl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}Vu.prototype.bytesPerElement=1,ea(Vu,"StructArrayLayout1ub1");class Fu extends Hl{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]}}Fu.prototype.size=40;class Du extends mu{get(e){return new Fu(this,e)}}ea(Du,"CollisionBoxArray");class Cu extends Hl{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(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}Cu.prototype.size=60;class Ru extends vu{get(e){return new Cu(this,e)}}ea(Ru,"PlacedSymbolArray");class Lu extends Hl{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}Lu.prototype.size=80;class Ou extends wu{get(e){return new Lu(this,e)}}ea(Ou,"SymbolInstanceArray");class Uu extends eu{getoffsetX(e){return this.float32[1*e+0]}}ea(Uu,"GlyphOffsetArray");class Nu extends Kl{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}ea(Nu,"SymbolLineVertexArray");class ju extends Hl{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]}}ju.prototype.size=12;class Gu extends Tu{get(e){return new ju(this,e)}}ea(Gu,"FeatureIndexArray");class $u extends fu{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}ea($u,"FillExtrusionCentroidArray");class qu extends Hl{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}qu.prototype.size=6;class Hu extends Jl{get(e){return new qu(this,e)}}ea(Hu,"FillExtrusionWallArray");const Xu=Wl([{name:"a_pos",components:2,type:"Int16"}],4),Zu=Wl([{name:"a_road_z_offset",components:1,type:"Float32"}],4),Wu=Wl([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),Yu=Wl([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);class Ku{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,r,n,i){let s=this.segments.at(-1);return e>Ku.MAX_VERTEX_ARRAY_LENGTH&<(`Max vertices per segment is ${Ku.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>Ku.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n||void 0!==i&&s&&void 0!==s.batchIndex&&s.batchIndex!==i)&&(s={vertexOffset:t,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(s.sortKey=n),void 0!==i&&(s.batchIndex=i),this.segments.push(s)),s}prepareSegment(e,t,r,n,i){return this._prepareSegment(e,t.length,r.length,n,i)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy();}static simpleSegment(e,t,r,n){return new Ku([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ju(e,t){return 256*(e=Ze(Math.floor(e),0,255))+Ze(Math.floor(t),0,255)}Ku.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ea(Ku,"SegmentVector");const Qu=Wl([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ec=Wl([{name:"a_pattern_b",components:4,type:"Uint16"}]),tc=Wl([{name:"a_dash",components:4,type:"Uint16"}]);class rc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,r,n){this.ids.push(nc(e)),this.positions.push(t,r,n);}eachPosition(e,t){const r=nc(e);let n=0,i=this.ids.length-1;for(;n>1;this.ids[e]>=r?i=e:n=e+1;}for(;this.ids[n]===r;)t(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(e,t){const r=new Float64Array(e.ids),n=new Uint32Array(e.positions);return ic(r,n,0,r.length-1),t&&(t.add(r.buffer),t.add(n.buffer)),{ids:r,positions:n}}static deserialize(e){const t=new rc;let r;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==r&&t.uniqueIds.push(e),r=e;return t.indexed=!0,t}}function nc(e){const t=+e;return Number.isSafeInteger(t)?t:hr(String(e))}function ic(e,t,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(e[s]i);if(s>=a)break;sc(e,s,a),sc(t,3*s,3*a),sc(t,3*s+1,3*a+1),sc(t,3*s+2,3*a+2);}a-r`u_${e}`),this.type=r,this.context=n;}setUniform(e,t,r,n,i){const s=n.constantOr(this.value);t.set(e,i,s instanceof Ar?s.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):s);}getBinding(e,t){return "color"===this.type?new pc(e):new lc(e)}}class bc{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1;}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern;}setUniform(e,t,r,n,i){let s=null;"u_pattern"!==i&&"u_dash"!==i||(s=this.pattern),"u_pattern_b"===i&&(s=this.patternTransition),"u_pixel_ratio"===i&&(s=this.pixelRatio),s&&t.set(e,i,s);}getBinding(e,t){return "u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new hc(e):new lc(e)}}class vc{constructor(e,t,r,n){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0})),this.paintVertexArray=new n;}populatePaintArray(e,t,r,n,i,s,a,o){const l=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new Qa(0,{brightness:s,worldview:o}),t,{},i,n,a):"constant"===this.expression.kind&&this.expression.value,c=gc(this.lutExpression,t,{},n,i,s,a,o);this.paintVertexArray.resize(e),this._setPaintValue(l,e,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,a,o){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:a,worldview:o},r,n,void 0,i):"constant"===this.expression.kind&&this.expression.value,u=gc(this.lutExpression,r,n,i,void 0,a,void 0,o);this._setPaintValue(e,t,l,u?null:this.context.lut);}_setPaintValue(e,t,r,n){if("color"===this.type){const i=yc(r.toPremultipliedRenderColor(n));for(let r=e;r`u_${e}_t`),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0})),this.paintVertexArray=new s;}populatePaintArray(e,t,r,n,i,s,a,o){const l=this.expression.evaluate(new Qa(this.context.zoom,{brightness:s,worldview:o}),t,{},i,n,a),u=this.expression.evaluate(new Qa(this.context.zoom+1,{brightness:s,worldview:o}),t,{},i,n,a),c=gc(this.lutExpression,t,{},n,i,s,a,o),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,a,o){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:a,worldview:o},r,n,void 0,i),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:a,worldview:o},r,n,void 0,i),c=gc(this.lutExpression,r,n,i,void 0,a,void 0,o);this._setPaintValue(e,t,l,u,c?null:this.context.lut);}_setPaintValue(e,t,r,n,i){if("color"===this.type){const s=yc(r.toPremultipliedRenderColor(i)),a=yc(n.toPremultipliedRenderColor(i));for(let r=e;r!0){this.binders={},this._buffers=[],this.context=t;const n=[],i=e;for(const s in e.paint._values){const a=i.paint.get(s);if(s.endsWith("-use-theme"))continue;if(!r(s))continue;if(!(a instanceof ao&&ks(a.property.specification)))continue;const o=Sc(s,e.type),l=a.value,u=a.property.specification.type,c=!!a.property.useIntegerZoom,h="line-dasharray"===s||s.endsWith("pattern"),d=i.paint.get(`${s}-use-theme`),p="line-dasharray"===s&&"constant"!==i.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||p)if("source"===l.kind||p||h){const t=Pc(s,u,"source");this.binders[s]=h?new _c(l,o,u,t,e.id):new vc(l,o,u,t),n.push(`/a_${s}`);}else {const e=Pc(s,u,"composite");this.binders[s]=new wc(l,o,u,c,t,e),n.push(`/z_${s}`);}else this.binders[s]=h?new bc(l.value,o):new xc(l.value,o,u,t),n.push(`/u_${s}`);d&&(this.binders[s].lutExpression=d.value);}this.cacheKey=n.sort().join("");}updateExpressions(e){const t=e;for(const e in this.binders){const r=this.binders[e];if(r instanceof vc||r instanceof wc||r instanceof _c){const n=t.paint.get(e);r.expression=n.value;}}}getMaxValue(e){const t=this.binders[e];return t instanceof vc||t instanceof wc?t.maxValue:0}populatePaintArrays(e,t,r,n,i,s,a,o){for(const l in this.binders){const u=this.binders[l];u.context=this.context,(u instanceof vc||u instanceof wc||u instanceof _c)&&u.populatePaintArray(e,t,r,n,i,s,a,o);}}setConstantPatternPositions(e,t){for(const r in this.binders){const n=this.binders[r];n instanceof bc&&n.setConstantPatternPositions(e,t);}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof _c?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,r,n,i,s,a,o,l,u){let c=!1;const h=Object.keys(e),d=0!==h.length&&!o,p=d?h:t.uniqueIds;this.context.lut=i.lut;for(const o in this.binders){const h=this.binders[o];if(h.context=this.context,(h instanceof vc||h instanceof wc||h instanceof _c)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=i.paint.get(o);h.expression=f.value;for(const r of p){const i=e[r.toString()];t.eachPosition(r,(e,t,r)=>{const o=n.feature(e);h.updatePaintArray(t,r,o,i,s,a,l,u);});}if(!d)for(const t of r.uniqueIds){const i=e[t.toString()];r.eachPosition(t,(e,t,r)=>{const o=n.feature(e);h.updatePaintArray(t,r,o,i,s,a,l,u);});}c=!0;}}return c}defines(){const e=[];for(const t in this.binders){const r=this.binders[t];(r instanceof xc||r instanceof bc)&&e.push(...r.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`));}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof xc||n instanceof bc||n instanceof wc)for(const i of n.uniformNames)t.push({name:i,property:r,binding:n.getBinding(e,i)});}return t}setUniforms(e,t,r,n,i){for(const{name:t,property:s,binding:a}of r)this.binders[s].setUniform(e,a,i,n.get(s),t);}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof vc||t instanceof wc||t instanceof _c)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof _c&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer);}}upload(e){for(const t in this.binders){const r=this.binders[t];(r instanceof vc||r instanceof wc||r instanceof _c)&&r.upload(e);}this.updatePaintBuffers();}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof vc||t instanceof wc||t instanceof _c)&&t.destroy();}}}class Ic{constructor(e,t,r=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Ac(n,t,r);this.needsUpload=!1,this._featureMap=new rc,this._featureMapWithoutIds=new rc,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,r,n,i,s,a,o,l){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,n,i,s,a,o,l);void 0!==t.id?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,r,n,i,s,a,o){for(const l of r)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,i,s,a||0,o)||this.needsUpload;}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1;}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy();}updateExpressions(e){const t=new Set;for(const r of e){const e=this.programConfigurations[r.id];e&&(e.updateExpressions(r),t.add(r.id));}for(const e in this.programConfigurations)t.has(e)||delete this.programConfigurations[e];}}const Mc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function Sc(e,t){return Mc[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Bc={"line-pattern":{source:ou,composite:ou},"fill-pattern":{source:ou,composite:ou},"fill-extrusion-pattern":{source:ou,composite:ou},"line-dasharray":{source:lu,composite:lu}},Tc={color:{source:Bu,composite:du},number:{source:eu,composite:Bu}};function Pc(e,t,r){const n=Bc[e];return n&&n[r]||Tc[t][r]}ea(xc,"ConstantBinder"),ea(bc,"PatternConstantBinder"),ea(vc,"SourceExpressionBinder",{omit:["expression"]}),ea(_c,"PatternCompositeBinder",{omit:["expression"]}),ea(wc,"CompositeExpressionBinder",{omit:["expression"]}),ea(Ac,"ProgramConfiguration",{omit:["_buffers"]}),ea(Ic,"ProgramConfigurationSet");class zc{constructor(e,t,r){this.layoutVertexArray=new Kl,this.indexArray=new bu,this.lineIndexArray=new fu,this.triangleSegments=new Ku,this.lineSegments=new Ku,this.programConfigurations=new Ic(e,{zoom:t,lut:r}),this.uploaded=!1;}update(e,t,r,n,i,s,a,o){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o);}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy());}populatePaintArrays(e,t,r,n,i,s,a){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,r,n,i,s,void 0,a);}}ea(zc,"FillBufferData");class Ec{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new zc(e.layers,e.zoom,e.lut),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.sourceLayerIndex=e.sourceLayerIndex,this.sourceLayerName=e.sourceLayerName||"",this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.hasPattern=fl("fill",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=$l(a,e);if(!this.layers[0]._featureFilter.filter(new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r,t.availableImages):void 0,d={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Gl(a,r,n),patterns:{},sortKey:h};s.push(d);}i&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const e=ml("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[s].feature,i,s,a,this.index);}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this);}update(e,t,r,n,i,s,a){this.bufferData.update(e,t,r,n,i,s,a,this.worldview),this.hdExt&&this.hdExt.update(e,t,r,n,i,s,a,this.worldview);}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.hdExt&&this.hdExt.updateExpressions(e);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this);}isEmpty(){return this.bufferData.isEmpty()&&(!this.hdExt||this.hdExt.isEmpty())}uploadPending(){return !this.uploaded||this.bufferData.needsUpload()||null!=this.hdExt&&this.hdExt.needsUpload()}upload(e){this.bufferData.upload(e),this.hdExt&&this.hdExt.upload(e);}destroy(){this.bufferData.destroy(),this.hdExt&&this.hdExt.destroy();}addFeature(e,t,r,n,i,s=[],a,o){const l=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,u=this.bufferData.indexArray.length,c=Pe(t,500);null!=this.hdExt&&this.hdExt.handleFeature(e,c,r,n,o,this)||this.addGeometry(c,this.bufferData),this.bufferData.populatePaintArrays(e,r,i,s,n,a,this.worldview),this.hdExt&&this.hdExt.populatePaintArrays(e,r,i,s,n,a,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,u,this.bufferData.indexArray.length,l);}addGeometry(e,t,r,n){let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=null;r&&(a=r.elevationSampler.constantElevation(r.elevation,r.bias),null!=a&&(i=a,s=a));const o=r?t:null,l=(e,t,n)=>{if(null!=r)if(t.push(e),null!=a)o.elevatedLayoutVertexArray.emplaceBack(a),n.push(a);else {const t=r.elevationSampler.pointElevation(e,r.elevation,r.bias);o.elevatedLayoutVertexArray.emplaceBack(t),n.push(t),i=Math.min(i,t),s=Math.max(s,t);}};for(const i of e){let e=0;for(const t of i)e+=t.length;const s=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),a=s.vertexLength,o=[],u=[],c=[],h=[],d=[],p=t.layoutVertexArray.length;for(const e of i){if(0===e.length)continue;e!==i[0]&&u.push(o.length/2);const n=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),s=n.vertexLength;r&&d.push(t.layoutVertexArray.length-p),l(e[0],c,h),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(s+e.length-1,s),o.push(e[0].x),o.push(e[0].y);for(let r=1;r0&&r&&n){const e=r.elevation.isTunnel(),t=r.elevation.safeArea,i=n.addVertices(c,h);n.addTriangles(f,i,e);const s=d.length;if(s>0){for(let a=0;a>3,0===s)continue}if(s--,1===i)a+=e.readSVarint(),o+=e.readSVarint(),n&&r.push(n),n=[new _e(a,o)];else if(2===i)a+=e.readSVarint(),o+=e.readSVarint(),n&&n.push(new _e(a,o));else {if(7!==i)throw new Error(`unknown command ${i}`);n&&n.push(n[0].clone());}}return n&&r.push(n),r}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;for(;e.pos>3,0===n)continue}if(n--,1===r||2===r)i+=e.readSVarint(),s+=e.readSVarint(),io&&(o=i),su&&(u=s);else if(7!==r)throw new Error(`unknown command ${r}`)}return [a,l,o,u]}toGeoJSON(e,t,r){const n=this.extent*Math.pow(2,r),i=this.extent*e,s=this.extent*t,a=this.loadGeometry();function o(e){return [360*(e.x+i)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function l(e){return e.map(o)}let u;if(1===this.type){const e=[];for(const t of a)e.push(t[0]);const t=l(e);u=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};}else if(2===this.type){const e=a.map(l);u=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};}else {if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return [e];const r=[];let n,i;for(let s=0;s=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Nc(this._pbf,t,this.extent,this._keys,this._values)}}function $c(e){let t=null;const r=e.readVarint()+e.pos;for(;e.pos1){if(Yc(e,t))return !0;for(let n=0;n1?r:r.sub(t)._mult(i)._add(t))}function rh(e,t){let r,n,i,s=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-n.x)*(t.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function nh(e,t){let r=!1;for(let n=0,i=e.length-1;nt.y!=a.y>t.y&&t.x<(a.x-s.x)*(t.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function ih(e,t,r,n,i){for(const s of e)if(t<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new _e(t,r),new _e(t,i),new _e(n,i),new _e(n,r)];if(e.length>2)for(const t of s)if(nh(e,t))return !0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return !1;const s=ut(e,t,r[0]);return s!==ut(e,t,r[1])||s!==ut(e,t,r[2])||s!==ut(e,t,r[3])}function ah(e,t,r,n,i,s){let a=t.y-e.y,o=e.x-t.x;if(s=s||0){const e=a*a+o*o;if(0===e)return !0;const t=Math.sqrt(e);a/=t,o/=t;}return !((r.x-e.x)*a+(r.y-e.y)*o-s<0||(n.x-e.x)*a+(n.y-e.y)*o-s<0||(i.x-e.x)*a+(i.y-e.y)*o-s<0)}function oh(e,t,r,n,i,s,a){return !(ah(e,t,n,i,s,a)||ah(t,r,n,i,s,a)||ah(r,e,n,i,s,a)||ah(n,i,e,t,r,a)||ah(i,s,e,t,r,a)||ah(s,n,e,t,r,a))}class lh extends _e{constructor(e,t,r){super(e,t),this.z=r;}}class uh extends lh{constructor(e,t,r,n){super(e,t,r),this.w=n;}}function ch(e,t,r,n){const i="x"===r?"y":"x",s=(n-e[r])/(t[r]-e[r]);e[i]=Math.round(e[i]+(t[i]-e[i])*s),e[r]=n,Object.hasOwn(e,"z")&&(e.z=wr(e.z,t.z,s)),Object.hasOwn(e,"w")&&(e.w=wr(e.w,t.w,s));}function hh(e,t,r,n){const i=r,s=n;for(const r of ["x","y"]){let n=e,a=t;n[r]>=a[r]&&(n=t,a=e),n[r]i&&ch(n,a,r,i),n[r]s&&ch(a,n,r,s);}}function dh(e,t,r,n,i,s){const a=[];for(let o=0;o=n&&d.x>=n||(c.x>=n?c=new _e(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round():d.x>=n&&(d=new _e(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round()),c.y>=i&&d.y>=i||(c.y>=i?c=new _e(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round():d.y>=i&&(d=new _e(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round()),u&&c.equals(u.at(-1))||(u=[c],a.push(u),s&&s.push({progress:{min:f+fh(m,y,c)*p,max:1},parentIndex:o,prevPoint:m,nextPoint:y})),u.push(d),s&&(s.at(-1).progress.max=f+fh(m,y,d)*p,s.at(-1).nextPoint=y)))));}if(s&&h>0)for(let e=c;ee.t-t.t);let a=0,o=0,l=[];for(n.push(l);a!==e.length;){if(o===s.length){for(;a!==e.length;)0!==l.length&&l.at(-1).equals(e[a])||l.push(e[a]),a++;break}s[o].t<=a?(0!==l.length&&l.at(-1).equals(s[o].point)||l.push(s[o].point),Math.trunc(s[o].t),o++):(0!==l.length&&l.at(-1).equals(e[a])||l.push(e[a]),a++);}}function fh(e,t,r){return e.x!==t.x?(r.x-e.x)/(t.x-e.x):e.y!==t.y?(r.y-e.y)/(t.y-e.y):0}function mh(e,{width:t,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*r*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(t*r*n);return e.width=t,e.height=r,e.data=i,e}function yh(e,t,r){const{width:n,height:i}=t;n===e.width&&i===e.height||(gh(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r,null),e.width=n,e.height=i,e.data=t.data);}function gh(e,t,r,n,i,s,a,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,u=t.data,c=4===s&&o;for(let o=0;o1&&(a=e[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const d=t/r*(n+1);if(a.isDash){const e=n-Math.abs(d);h=Math.sqrt(c*c+e*e);}else h=n-Math.sqrt(c*c+d*d);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const r=e[t],n=e[t+1];r.zeroLength?e.splice(t,1):n&&n.isDash===r.isDash&&(n.left=r.left,e.splice(t,1));}const r=e[0],n=e.at(-1);r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=e[s];for(let r=0;r1&&(a=e[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128));}}addDash(e,t){const r=this.getKey(e,t);if(this.positions[r])return this.positions[r];const n="round"===t,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return lt("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={};}),this.layoutVertexArray=new su,this.layoutVertexArray2=new au,this.patternVertexArray=new au,this.indexArray=new bu,this.programConfigurations=new Ic(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Ku,this.sourceLayerName=e.sourceLayerName||"",this.maxLineLength=0,this.zOffsetVertexArray=new du,this.elevationIdColVertexArray=new au,this.elevationGroundScaleVertexArray=new eu,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.showElevationIdDebug=t.showElevationIdDebug,this.hasPattern=fl("line",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Fl(r);const s=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===s)this.elevationType="road";else {const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==s&&"ground"!==s&&t?"none":"offset","offset"===this.elevationType&&"none"===s&<(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===s;}const a=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==a;const o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=$l(s,e);if(!this.layers[0]._featureFilter.filter(new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Gl(s,r,n),patterns:{},sortKey:h};o.push(d);}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:u}=t,c=this.addConstantDashes(l);for(const n of o){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const e=ml("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,l.positions,t.availableImages,t.brightness,t.elevationFeatures);u.insert(e[s].feature,i,s,a,this.index);}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this);}addConstantDashes(e){let t=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)t=!0;else {const t=i.value,r=n.value;if(!r)continue;e.addDash(r,t);}}return t}addFeatureDashes(e,t){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===s.kind)continue;let a,o;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:r},e);o="constant"===s.kind?s.value:s.evaluate({zoom:r},e),t.addDash(a,o),e.patterns[n.id]=[t.getKey(a,o)];}}update(e,t,r,n,i,s,a,o,l){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,l);}updateExpressions(e){this.programConfigurations.updateExpressions(e);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Lc)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Uc)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Vc.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,Fc.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Dc.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(e,t){let r,n;if(t&&t>0?(r=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(r="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,r)&&Object.hasOwn(e.properties,n))return {start:+e.properties[r],end:+e.properties[n]}}addFeature(e,t,r,n,i,s,a,o){const l=this.layers[0].layout,u=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,c=this.indexArray.length,h=l.get("line-join").evaluate(e,{}),d=l.get("line-cap").evaluate(e,{}),p=l.get("line-miter-limit"),f=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const m=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const y=this.layers[0].paint,g=y.get("line-width").value;"constant"!==g.kind&&!1===g.isLineProgressConstant&&(this.variableWidthValue=g);const x=y.get("line-emissive-strength").value;if("constant"!==x.kind&&!1===x.isLineProgressConstant&&(this.variableEmissiveStrengthValue=x),this.isSeaLevelReference){const e=l.get("line-elevation-ground-scale").value;"constant"===e.kind&&0===e.value||(this.elevationGroundScaleValue=e);}if(null==this.hdExt||!this.hdExt.handleFeature(e,t,n,o,h,d,p,f,this))for(let r=0;r0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,i,s,n,a,void 0,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,c,this.indexArray.length,u);}fillNonElevatedRoadSegment(e){for(let t=e;t0,h=o&&o.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},n=1;if(o){const e=this.lineClips.end-this.lineClips.start;r=function(e,t,r){return {min:St(e.min,t,r),max:St(e.max,t,r)}}(o.progress,{min:0,max:1},r),e>0&&(n=(r.max-r.min)/e);}const i=+t.properties.mapbox_clip_feature_len,s=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(i)||Number.isNaN(s)){for(let t=0;t=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f0,z=this.overscaling<=16?122880/(512*this.overscaling):0;if(r&&"round"===o)if(Ss&&(o="bevel"),"bevel"===o&&(S>2&&(o="flipbevel"),S2*z){const t=y.sub(y.sub(g)._mult(z/e)._round());this.updateDistance(g,t),this.addCurrentVertex(t,b,0,0,m,A),g=t;}this.updateDistance(g,y),I._mult(S),this.addCurrentVertex(y,I,0,0,m,A);const t=y.dist(x);if(t>2*z){const e=y.add(x.sub(y)._mult(z/t)._round());this.updateDistance(y,e),this.addCurrentVertex(e,v,0,0,m,A),y=e;}}else I._mult(S),this.addCurrentVertex(y,I,0,0,m,A);else if("flipbevel"===o){if(S>100)I=v.mult(-1);else {const e=S*b.add(v).mag()/b.sub(v).mag();I._perp()._mult(e*(P?-1:1));}this.addCurrentVertex(y,I,0,0,m,A),this.addCurrentVertex(y,I.mult(-1),0,0,m,A);}else if("bevel"===o||"fakeround"===o){const e=y.dist(g);let t=1;if("offset"===this.elevationType&&"bevel"===o&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=A&&g&&x){const r=4*z;e1){this.lineSoFar=e.w;const r=(t.x-e.x)/c,n=(t.y-e.y)/c,i=(t.z-e.z)/c,s=(t.w-e.w)/c,a=t.x-e.x,o=t.y-e.y,d=Math.sqrt(a*a+o*o);if(0===d)return;const p=-o/d,f=a/d,m=p,y=f,g=-p,x=-f;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u,null!=l&&(this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth,l.variableEmissiveStrength),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){const e=l?l.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(e);}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance;}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance();}}function Th(e,t,r){return e.xr||e.yr}ea(Bh,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Ph=Wl([{name:"a_pos",components:2,type:"Int16"}],4),zh=Wl([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Eh=Wl([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class kh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Kl,this.indexArray=new bu,this.segments=new Ku,this.programConfigurations=new Ic(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){const i=this.layers[0],s=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:i,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=$l(i,e);if(!this.layers[0]._featureFilter.filter(new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=a?a.evaluate(c,{},r):void 0,d={id:o,properties:i.properties,type:i.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Gl(i,r,n),patterns:{},sortKey:h};s.push(d);}a&&s.sort((e,t)=>e.sortKey-t.sortKey);let o=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new uu,o=n.projection);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n,l=e[s].feature;this.addFeature(n,i,s,t.availableImages,r,o,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,i,s,a,this.index);}this.hdExt&&this.hdExt.finalize();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview);}updateExpressions(e){this.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ph.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Eh.members)),this.hdExt&&this.hdExt.upload(e)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.hdExt&&this.hdExt.destroy());}addFeature(e,t,r,n,i,s,a,o){this.hdExt&&this.hdExt.beginFeature(e,o);for(const r of t)for(const t of r){const r=t.x,n=t.y;if(r<0||r>=Xn||n<0||n>=Xn)continue;if(s){const e=s.projectTilePoint(r,n,i),t=s.upVector(i,r,n);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t);}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),o=a.vertexLength;this.addCircleVertex(r,n,-1,-1),this.addCircleVertex(r,n,1,-1),this.addCircleVertex(r,n,1,1),this.addCircleVertex(r,n,-1,1),this.hdExt&&this.hdExt.writeVertexQuad(r,n),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),a.vertexLength+=4,a.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},n,i,a,void 0,this.worldview);}addCircleVertex(e,t,r,n){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*t+(n+1)/2);}addGlobeExtVertex(e,t){const r=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*r,t[1]*r,t[2]*r);}}ea(kh,"CircleBucket",{omit:["layers"]});const Vh=Wl([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Fh=Wl([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Dh=Wl([{name:"a_projected_pos",components:4,type:"Float32"}],4);Wl([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ch=Wl([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Rh=Wl([{name:"a_feature_index",components:1,type:"Float32"}],4),Lh=Wl([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Oh=Wl([{name:"a_texb",components:2,type:"Uint16"}]),Uh=Wl([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Nh=Wl([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Wl([{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 jh=Wl([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Gh=Wl([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Wl([{name:"triangle",components:3,type:"Uint16"}]),Wl([{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"}]),Wl([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),Wl([{type:"Float32",name:"offsetX"}]),Wl([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const $h=class e{static getBlockIndices(t){let r=e._blockIndicesTemplate;if(!r){r=e._blockIndicesTemplate=new Uint32Array(t);for(let e=0;et.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${t.maxUniformBlockSize}`);if(this.headerBuffer=r.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.headerBuffer),r.bufferData(r.UNIFORM_BUFFER,e.HEADER_BYTES,r.DYNAMIC_DRAW),this.propertiesBuffer=r.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.propertiesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),this.blockIndicesBuffer=r.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");r.bindBuffer(r.UNIFORM_BUFFER,this.blockIndicesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),r.bindBuffer(r.UNIFORM_BUFFER,null);}writeDataDrivenBlock(t,r){const n=this.headerData,i=4*n[2];if(0===i)return;const s=r*i;if(s+i>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${r} exceeds propertiesData capacity`);const a=n[0],o=n[1];for(let r=0;r<9;r++)a&1<this._propsDirtyMax&&(this._propsDirtyMax=l);}rightSizeForTransfer(){const e=-1===this._propsDirtyMax?0:this._propsDirtyMax;e{if(!n)return;const s=r.getUniformBlockIndex(t,e);s!==r.INVALID_INDEX&&(r.uniformBlockBinding(t,s,i),r.bindBufferBase(r.UNIFORM_BUFFER,i,n));},i=3*this.batchIndex;n("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,i),n("SymbolPaintPropertiesUniform",this.propertiesBuffer,i+1),n("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,i+2);}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null);}}};$h.HEADER_DWORDS=12,$h.HEADER_BYTES=48,$h.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],$h.EVAL_FLAT_TOTAL=24,$h._blockIndicesTemplate=null;let qh=$h;function Hh(e,t,r,n,i,s,a,o){return !!e&&("constant"===e.kind?"none"===e.value:"none"===e.evaluate({zoom:0,brightness:s,worldview:o},t,r,i,n,a))}function Xh(e){if(!(e instanceof ao))return !1;const t=e.value;return ("source"===t.kind||"composite"===t.kind)&&t.isStateDependent}ea(qh,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});const Zh=["icon","text"].map(e=>[`${e}-color`,`${e}-halo-color`,`${e}-opacity`,`${e}-halo-width`,`${e}-halo-blur`,`${e}-emissive-strength`,`${e}-occlusion-opacity`,"symbol-z-offset",`${e}-translate`]),Wh=new Float32Array(qh.EVAL_FLAT_TOTAL),Yh=[0,0];class Kh{constructor(e,t,r,n,i="",s,a){this.layer=e,this.zoom=t,this.lut=r,this.isText=n,this.worldview=i,this.maxUniformBufferBindings=s||24,this.uboSizeDwords=a||4096,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.ubos=[],this.featureCount=0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=null,this.sharedZoomRanges=new Float32Array(18),this.header=new Uint32Array(qh.HEADER_DWORDS),this.updateHeader(),this.isAllConstant=0===this.header[0];const o=4*this.header[2];this.maxFeaturesPerBatch=0===o?Number.MAX_SAFE_INTEGER:Math.floor(this.uboSizeDwords/o);}updateHeader(){const e=this.layer.paint;let t=0,r=0,n=0,i=0,s=!0;const a=Zh[+this.isText];for(let o=0;o<9;o++){const l=a[o],u=o<2,c=8===o,h=e.get(l),d=!(!h||"function"!=typeof h.isConstant||h.isConstant()),p=this._appearancesHavePaintProperties(l),f=!(!h||!h.value||"composite"!==h.value.kind);if(!d&&!p){const e=this.layer._transitionablePaint._values[l];"camera"===(e&&e.value&&e.value.expression&&e.value.expression.kind)&&(n|=1<0)if(null==s.interpolationType){n=i=1;for(const e of a)if(e>t&&et&&a[0]t.hasPaintProperty(e))}hasStateDependentPaint(e){const t=e.paint,r=Zh[+this.isText];for(const e of r)if(Xh(t.get(e)))return !0;for(const t of e.getAppearances()||[])for(const e of r){const r=e;if(t.hasPaintProperty(r)&&Xh(t.paintProperties.get(r)))return !0}return !1}hasPerFeatureTranslate(){return !!(256&this.header[0])}getCurrentBatchIndex(){return 0===this.maxFeaturesPerBatch?0:Math.floor(this.featureCount/this.maxFeaturesPerBatch)}_writeFeatureBlock(e,t){const r=this.isAllConstant?0:e;let n=Math.floor(r/this.maxFeaturesPerBatch),i=r%this.maxFeaturesPerBatch;this._batchExceedsDeviceLimit(n)&&(n=0,i=0);const s=this.ubos[n];return !!s&&(s.writeDataDrivenBlock(t,i),!0)}_batchExceedsDeviceLimit(e){return 3*e+2>=this.maxUniformBufferBindings}_reevaluateAt(e,t,r,n,i,s){if(!t)return;const a=this.allFeatureVtIndices[e],o=t.feature(a);if(!o)return;const l=this.allFeatureIds[e],u=null!=l&&i[l]||{},c={type:o.type,id:l,properties:o.properties||{},geometry:[]},h=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(a):void 0,d=this.evaluateAllProperties(c,u,r,n,s,void 0,h);this._writeFeatureBlock(e,d);}_ensureRangeMaps(){if(!this.featureVertexRangesFromId){this.featureVertexRangesFromId=new Map,this.featureVertexRangesFromVtIndex=new Map;for(let e=0;e{const r=l[e],n=s.get(r);if(!n)return [0,0,0,1];const i=s.get(`${r}-use-theme`),u=Hh(i&&"string"!=typeof i?i.value:void 0,o,{},[],void 0,t,void 0,this.worldview)?null:this.lut;return (this.cameraMask&1<{const r=s.get(l[e]);if(!r)return t;if(this.cameraMask&1<=n?1:0:Math.max(0,Math.min(1,(t-n)/(i-n)));}}const d={fill_np_color:u(0),halo_np_color:u(1),opacity:c(2,1),halo_width:c(3,0),halo_blur:c(4,0),emissive_strength:c(5,0),occlusion_opacity:c(6,1),z_offset:c(7,0),zoomFactors:h};return this.cachedConstantUniforms=d,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,d}finalize(){for(const e of this.ubos)e.rightSizeForTransfer();}upload(e){for(const t of this.ubos)t.upload(e);}bind(e,t,r=0){this.ubos[r]&&this.ubos[r].bind(e,t);}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureCount=0,this.maxFeaturesPerBatch=0;}}ea(Kh,"SymbolPropertyBinderUBO",{omit:["layer","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex","featureVertexRangesFromId","featureVertexRangesFromVtIndex"]});const Jh=24;function Qh(e,t,r){return e.sections.forEach(e=>{e.text=function(e,t,r){const n=t.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Ka.applyArabicShaping&&(e=Ka.applyArabicShaping(e)),e}(e.text,t,r);}),e}const ed={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function td(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function rd(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const nd=4294967296,id=1/nd,sd="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class ad{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length;}readFields(e,t,r=this.length){let n;for(;n=this.nextField(r);)e(n,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*nd;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*nd;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf,r=t[this.pos++];if(r<128)return r;let n,i=127&r;return n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,r){const n=r.buf;let i,s;if(s=n[r.pos++],i=(112&s)>>4,s<128)return od(e,i,t);if(s=n[r.pos++],i|=(127&s)<<3,s<128)return od(e,i,t);if(s=n[r.pos++],i|=(127&s)<<10,s<128)return od(e,i,t);if(s=n[r.pos++],i|=(127&s)<<17,s<128)return od(e,i,t);if(s=n[r.pos++],i|=(127&s)<<24,s<128)return od(e,i,t);if(s=n[r.pos++],i|=(1&s)<<31,s<128)return od(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this))))}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&sd?sd.decode(this.buf.subarray(t,e)):function(e,t,r){let n="",i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+u>r)break;1===u?t<128&&(l=t):2===u?(s=e[i+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===u?(s=e[i+1],a=e[i+2],128==(192&s)&&128==(192&a)&&(l=(15&t)<<12|(63&s)<<6|63&a,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=e[i+1],a=e[i+2],o=e[i+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(l=(15&t)<<18|(63&s)<<12|(63&a)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u;}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const r=this.readPackedEnd();for(;this.pos=e)return 0;const t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}skip(e){const t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else {if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8;}}}function od(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function ld(e,t,r){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(n),r.buf.copyWithin(e+n,e,r.pos);}function ud(e,t){for(let r=0;r=0&&r>=e&&Id[this.text.charCodeAt(r)];r--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const r=new _d;return r.text=this.text.substring(e,t),r.sectionIndex=this.sectionIndex.slice(e,t),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(wd.forText(e.scale,e.fontStack||t));const r=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ad(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m=1,y=1){const g=_d.fromFeature(e,i,m,y);h===vd.vertical&&g.verticalizePunctuation(d);let x=[];const b=function(e,t,r,n,i,s,a=1){if(!e)return [];const o=[],l=function(e,t,r,n,i,s,a=1){let o=0;for(let r=0;r0&&l>w&&(w=l);}else {const e=r[o.fontStack];if(!e)continue;e[y]&&(I=e[y]);const n=t[o.fontStack];if(!n)continue;const s=n.glyphs[y];if(!s)continue;if(b=s.metrics,S=8203!==y?Jh:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,r=(e+t)*x;_-r/2;){if(a--,a<0)return !1;o-=e[a].dist(s),s=e[a];}o+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=t.dist(r);}return !0}function qd(e){let t=0;for(let r=0;ru){const c=(u-l)/s,h=wr(n.x,i.x,c),d=wr(n.y,i.y,c),p=new Gd(h,d,0,i.angleTo(n),r);return !a||$d(e,p,o,a,t)?p:void 0}l+=s;}}function Wd(e,t,r,n,i,s,a,o,l){const u=Hd(n,s,a),c=Xd(n,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&x=0&&d+u<=c){const r=new Gd(g,x,0,m,t);n&&!$d(e,r,s,n,i)||p.push(r);}}h+=f;}return o||p.length||a||(p=Yd(e,h/2,r,n,i,s,a,!0,l)),p}function Kd(e){let t=0,r=0;for(const n of e)t+=n.w*n.h,r=Math.max(r,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let i=0,s=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const r=n[e];if(!(t.w>r.w||t.h>r.h)){if(t.x=r.x,t.y=r.y,s=Math.max(s,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===r.w&&t.h===r.h){const t=n.pop();t&&et.id?1:e.versiont.version?1:e.sxt.sx?1:e.syt.sy?1:0}function Qd(e){let t=0;for(let r=0;r0,tp(e,r,this.iconDescriptors,i),tp(t,r,this.patternDescriptors,i),this.iconDescriptors.sort(Jd),this.patternDescriptors.sort(Jd);let s=0;const a=n?n.data:"";a&&(s=ep(s,Qd(a))),s=ep(s,1);for(const e of this.iconDescriptors)s=ep(s,Qd(e.id)),s=ep(s,e.version),s=ep(s,e.sx),s=ep(s,e.sy);s=ep(s,1);for(const e of this.patternDescriptors)s=ep(s,Qd(e.id)),s=ep(s,e.version),s=ep(s,e.sx),s=ep(s,e.sy);this.hash=s;}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,Jd)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,Jd)}isSubsetArray(e,t,r){let n=0,i=0;if(e.length>t.length)return !1;for(;n0&&u>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;s.texStorage2D(s.TEXTURE_2D,e,this.format,l,u),this.size=[l,u];}this.size&&(c?s.texSubImage2D(s.TEXTURE_2D,0,a,o,np(this.format),ip(this.format),e):"data"in e&&e.data&&s.texSubImage2D(s.TEXTURE_2D,0,a,o,r,n,np(this.format),ip(this.format),e.data)),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D);}bind(e,t,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,r,n,i){const{context:s}=this,{gl:a}=s;a.bindTexture(a.TEXTURE_2D,this.texture),t!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?e===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,n),this.wrapT=n),i!==this.compareMode&&(i?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_FUNC,i)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.NONE),this.compareMode=i);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class ap{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}}class op{static getImagePositionScale(e,t,r){if(t&&e){const{sx:t,sy:r}=e;return {x:t,y:r}}return {x:r,y:r}}constructor(e,t,r,n){this.paddedRect=e;const{pixelRatio:i,version:s,stretchX:a,stretchY:o,content:l,sdf:u,usvg:c}=t;this.pixelRatio=i,this.stretchX=a,this.stretchY=o,this.content=l,this.version=s,this.padding=r,this.sdf=u,this.usvg=c,this.scale=op.getImagePositionScale(n,c,i);}get tl(){return [this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return [this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return [(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function lp(e,t,r){const n=Kr.parse(e),i=function(e,t,r=[1,1]){return {x:0,y:0,w:(e.data?e.data.width:e.width*r[0])+2*t,h:(e.data?e.data.height:e.height*r[1])+2*t}}(t,r,[n.sx,n.sy]);return {bin:i,imagePosition:new op(i,t,r,n),imageVariant:n}}function up(e,t){const r=[];for(const[n,i]of e.entries()){const e=Kr.parse(n);e&&(r.push({key:n,value:i,variant:e}),t&&t.set(n,e));}r.sort((e,t)=>{const r=e.variant.id.toString().localeCompare(t.variant.id.toString());return 0!==r?r:e.variant.sx!==t.variant.sx?e.variant.sx-t.variant.sx:e.variant.sy!==t.variant.sy?e.variant.sy-t.variant.sy:0});const n=new Map;for(const e of r)n.set(e.key,e.value);return n}class cp{constructor(e){this.sourceAtlasHash=e;}}class hp{constructor(e,t,r,n){const i=new Map,s=new Map;this.haveRenderCallbacks=[];const a=[],o=void 0!==n,l=o?new Map:void 0,u=o?up(e,l):e,c=o?up(t,l):t;this.addImages(u,i,1,a),this.addImages(c,s,2,a);const{w:h,h:d}=Kd(a),p=new bh({width:h||1,height:d||1});for(const[e,t]of u.entries()){const r=i.get(e).paddedRect;bh.copy(t.data,p,{x:0,y:0},{x:r.x+1,y:r.y+1},t.data,null,t.sdf);}for(const[e,t]of c.entries()){const n=s.get(e),i=n.paddedRect;let a=n.padding;const o=i.x+a,l=i.y+a,u=t.data.width,c=t.data.height;a=a>1?a-1:a,bh.copy(t.data,p,{x:0,y:0},{x:o,y:l},t.data,r),bh.copy(t.data,p,{x:0,y:c-a},{x:o,y:l-a},{width:u,height:a},r),bh.copy(t.data,p,{x:0,y:0},{x:o,y:l+c},{width:u,height:a},r),bh.copy(t.data,p,{x:u-a,y:0},{x:o-a,y:l},{width:a,height:c},r),bh.copy(t.data,p,{x:0,y:0},{x:o+u,y:l},{width:a,height:c},r),bh.copy(t.data,p,{x:u-a,y:c-a},{x:o-a,y:l-a},{width:a,height:a},r),bh.copy(t.data,p,{x:0,y:c-a},{x:o+u,y:l-a},{width:a,height:a},r),bh.copy(t.data,p,{x:0,y:0},{x:o+u,y:l+c},{width:a,height:a},r),bh.copy(t.data,p,{x:u-a,y:0},{x:o-a,y:l+c},{width:a,height:a},r);}this.lut=r,this.image=p,this.iconPositions=i,this.patternPositions=s,o&&(this.contentDescriptor=new rp(u,c,n,r,l));}addImages(e,t,r,n){for(const[i,s]of e.entries()){const{bin:e,imagePosition:a,imageVariant:o}=lp(i,s,r);t.set(i,a),n.push(e),s.hasRenderCallback&&this.haveRenderCallbacks.push(o.id);}}patchUpdatedImages(e,t,r,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const i of e.getUpdatedImages(r)){for(const n of this.iconPositions.keys()){const s=Kr.parse(n);if(gr.isEqual(s.id,i)){const s=e.getImage(i,r);this.patchUpdatedImage(this.iconPositions.get(n),s,t,null);}}for(const s of this.patternPositions.keys()){const a=Kr.parse(s);if(gr.isEqual(a.id,i)){const a=e.getImage(i,r);this.patchUpdatedImage(this.patternPositions.get(s),a,t,n||this.lut);}}}}patchUpdatedImage(e,t,r,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[i,s]=e.tl,a=e.sdf;if(this.lut||a){const e={width:t.data.width,height:t.data.height},o=new bh(e);bh.copy(t.data,o,{x:0,y:0},{x:0,y:0},e,n,a),r.update(o,{position:{x:i,y:s},recreateWhenResize:!1});}else r.update(t.data,{position:{x:i,y:s},recreateWhenResize:!1});}}ea(op,"ImagePosition"),ea(hp,"ImageAtlas",{omit:["lut"]}),ea(cp,"ImageAtlasReference");class dp{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client";}loadGlyphRange(e,t,r,n,i){if("server"===this.fontstackCompositing)return void dp.loadGlyphRange(e,t,r,n,i);const s=e.split(",").map(e=>e.trim()).filter(e=>e.length>0);0!==s.length?1!==s.length?this._loadMultipleFonts(s,t,r,n,i):this._loadFont(s[0],t,r,n,i):i(new Error("Empty fontstack"));}_loadMultipleFonts(e,t,r,n,i){const s=e.map(()=>null),a={completed:0,firstError:null,callbackCalled:!1},o=(t,r,n)=>{if(!a.callbackCalled&&(r&&!a.firstError&&(a.firstError=r),n&&(s[t]=n),a.completed++,a.completed===e.length)){a.callbackCalled=!0;const e=s.filter(e=>null!==e);if(0===e.length)return void i(a.firstError||new Error("All fonts failed to load"));const t=this._composeGlyphs(e);i(null,t);}};for(let i=0;i{o(i,e,t);});}_loadFont(e,t,r,n,i){const s=`${e}:${t}`;if(this.cachedRanges.has(s)){const e=this.cachedRanges.get(s);return void Tt.frame(()=>i(null,e))}const a=this.pendingRequests.get(s);a?a.push(i):(this.pendingRequests.set(s,[i]),dp.loadGlyphRange(e,t,r,n,(e,t)=>{e||this.cachedRanges.set(s,t||null);const r=this.pendingRequests.get(s);if(this.pendingRequests.delete(s),r)for(const n of r)n(e,t);}));}_composeGlyphs(e){const t={};let r,n;for(const i of e)if(void 0===r&&void 0!==i.ascender&&(r=i.ascender),void 0===n&&void 0!==i.descender&&(n=i.descender),i.glyphs)for(const e in i.glyphs)void 0===t[e]&&(t[e]=i.glyphs[e]);return {glyphs:t,ascender:r,descender:n}}}dp.loadGlyphRange=function(e,t,r,n,i){const s=256*t,a=s+255,o=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${s}-${a}`),Jt.Glyphs);ar(o,(e,t)=>{if(e)i(e);else if(t){const e={},r=function(e){return function(e){const t={glyphs:[]};let r;for(;r=e.nextField();)1===r&&xd(e,e.readVarint()+e.pos,t);return t}(new ad(e))}(t);for(const t of r.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:r.ascender,descender:r.descender});}});};const pp=1e20,fp=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);fp[e]=t*Math.abs(t);}function mp(e,t,r,n,i,s,a,o,l){for(let u=t;u-1);l++,s[l]=o,a[l]=u,a[l+1]=pp;}for(let o=0,l=0;o{if(r){n.ascender=r.ascender,n.descender=r.descender;for(const e in r.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=r.glyphs[+e]);n.ranges[t]=!0;}for(const i of n.requests[t]||[])i(e,r);delete n.requests[t];}));}getGlyphs(e,t){const r=[],n=this.url||Pt.GLYPHS_URL;for(const t in e)for(const n of e[t])r.push({stack:t,id:n});Ke(r,({stack:e,id:t},r)=>{let i=this.entries[e];i||(i=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=i.glyphs[t];if(void 0!==s)return void r(null,{stack:e,id:t,glyph:s});if(s=this._tinySDF(i,e,t),s)return i.glyphs[t]=s,void r(null,{stack:e,id:t,glyph:s});const a=Math.floor(t/256);if(256*a>65535)return lt("glyphs > 65535 not supported"),void r(null,{stack:e,id:t,glyph:s});if(i.ranges[a])return void r(null,{stack:e,id:t,glyph:s});let o=i.requests[a];o||(o=i.requests[a]=[],this.glyphLoader.loadGlyphRange(e,a,n,this.requestManager,(e,t)=>{if(t){i.ascender=t.ascender,i.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(i.glyphs[+e]=t.glyphs[+e]);i.ranges[a]=!0;}for(const r of o)r(e,t);delete i.requests[a];})),o.push((n,i)=>{n?r(n):i&&r(null,{stack:e,id:t,glyph:i.glyphs[t]||null});});},(e,r)=>{if(e)t(e);else if(r){const e={};for(const{stack:t,id:n,glyph:i}of r)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e);}});}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==vp.none&&(this.localGlyphMode===vp.all?!!this.localFontFamily:!!this.localFontFamily&&(va(e)||Aa(e)||ha(e)||da(e)||ca(e)||ba(e)||(t=e)>=131072&&t<=173791||(e=>e>=66736&&e<=66815)(e)));var t;}_tinySDF(e,t,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=e.tinySDF;if(!i){let r="400";gp.test(t)?r="900":xp.test(t)?r="500":bp.test(t)&&(r="200"),i=e.tinySDF=new wp.TinySDF({fontFamily:n,fontWeight:r,fontSize:48,buffer:6,radius:16}),i.fontWeight=r;}const s=i.fontWeight;if(this.localGlyphs[s][r])return this.localGlyphs[s][r];const a=String.fromCodePoint(r),{data:o,width:l,height:u,glyphWidth:c,glyphHeight:h,glyphLeft:d,glyphTop:p,glyphAdvance:f}=i.draw(a);return this.localGlyphs[s][r]={id:r,bitmap:new xh({width:l,height:u},o),metrics:{width:c/2,height:h/2,left:d/2,top:p/2-27,advance:f/2,localGlyph:!0}}}}function _p(e,t){return e+t[1]-t[0]}function Ap(e,t,r,n,i=1){const s=[],a=e.imagePrimary,o=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=(e.right-e.left)*i,h=(e.bottom-e.top)*i,d=a.stretchX||[[0,l]],p=a.stretchY||[[0,u]],f=d.reduce(_p,0),m=p.reduce(_p,0),y=l-f,g=u-m;let x=0,b=f,v=0,w=m,_=0,A=y,I=0,M=g;if(a.content&&n){const e=a.content;x=Mp(d,0,e[0]),v=Mp(p,0,e[1]),b=Mp(d,e[0],e[2]),w=Mp(p,e[1],e[3]),_=e[0]-x,I=e[1]-v,A=e[2]-e[0]-b,M=e[3]-e[1]-w;}const S=(n,s,l,u)=>{const d=Tp(n.stretch-x,b,c,e.left*i),p=Pp(n.fixed-_,A,n.stretch,f),y=Tp(s.stretch-v,w,h,e.top*i),g=Pp(s.fixed-I,M,s.stretch,m),S=Tp(l.stretch-x,b,c,e.left*i),B=Pp(l.fixed-_,A,l.stretch,f),T=Tp(u.stretch-v,w,h,e.top*i),P=Pp(u.fixed-I,M,u.stretch,m),z=new _e(d,y),E=new _e(S,y),k=new _e(S,T),V=new _e(d,T),F=new _e(p/o,g/o),D=new _e(B/o,P/o),C=t*Math.PI/180;if(C){const e=Math.sin(C),t=Math.cos(C),r=[t,-e,e,t];z._matMult(r),E._matMult(r),V._matMult(r),k._matMult(r);}const R=n.stretch+n.fixed,L=l.stretch+l.fixed,O=s.stretch+s.fixed,U=u.stretch+u.fixed,N=e.imageSecondary;return {tl:z,tr:E,bl:V,br:k,texPrimary:{x:a.paddedRect.x+1+R,y:a.paddedRect.y+1+O,w:L-R,h:U-O},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+O,w:L-R,h:U-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:D,minFontScaleX:A/o/c,minFontScaleY:M/o/h,isSDF:r}};if(a.stretchX||a.stretchY){const e=Sp(d,y,f),t=Sp(p,g,m);for(let r=0;r0?[t,-r]:n<0?[-t,r]:0===t?[r,t]:[r,-t]}(r);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const f=t.positionedLines.length,m=p/f;let y=t.top-r[1];for(let e=0;es)&&(s=t.x),(!e||t.y>a)&&(a=t.y);}const l=Math.min(s-n,a-i);let u=l/2;const c=new Hn([],Vp);if(0===l)return new _e(n,i);for(let t=n;th.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-h.d<=t||(u=n.h/2,c.push(new Fp(n.p.x-u,n.p.y-u,u,e)),c.push(new Fp(n.p.x+u,n.p.y-u,u,e)),c.push(new Fp(n.p.x-u,n.p.y+u,u,e)),c.push(new Fp(n.p.x+u,n.p.y+u,u,e)),d+=4);}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function Vp(e,t){return t.max-e.max}wp.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:a="normal",lang:o=null}={}){this.buffer=t,this.radius=r,this.cutoff=n,this.lang=o;const l=this.size=e+4*t,u=this._createCanvas(l),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${s} ${e}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l);}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(r),o=Math.floor(-i),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-o)),u=Math.max(0,Math.min(this.size-this.buffer,a+Math.ceil(n))),c=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(c*h,0),p=new Uint8ClampedArray(d),f={data:p,width:c,height:h,glyphWidth:l,glyphHeight:u,glyphTop:a,glyphLeft:o,glyphAdvance:t};if(0===l||0===u)return f;const{ctx:m,buffer:y,gridInner:g,gridOuter:x}=this;this.lang&&(m.lang=this.lang),m.clearRect(y,y,l,u),m.fillText(e,y-o,y+a);const b=m.getImageData(y,y,l,u);x.fill(pp,0,d),g.fill(0,0,d);let v=3;for(let e=0;ee.y!=o.y>e.y&&e.x<(o.x-i.x)*(e.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,th(e,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const Dp=Object.keys,Cp=Number.POSITIVE_INFINITY,Rp=Math.sqrt(2);function Lp(e,t,r,n,i,s){const a=Vd(e)&&e.collisionPadding?e.collisionPadding:[0,0,0,0],o={top:e.top-a[1],bottom:e.bottom+a[3],left:e.left-a[0],right:e.right+a[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0;}(o,n),s&&(o.left+=s[0],o.right+=s[0],o.top+=s[1],o.bottom+=s[1]),r&&function(e,t,r){if(!t)return;const n=Ge(t),i=new _e(r?r[0]:0,r?r[1]:0),s=new _e(e.left,e.top),a=new _e(e.right,e.top),o=new _e(e.left,e.bottom),l=new _e(e.right,e.bottom);s._rotateAround(n,i),a._rotateAround(n,i),o._rotateAround(n,i),l._rotateAround(n,i),e.left=Math.min(s.x,a.x,o.x,l.x),e.right=Math.max(s.x,a.x,o.x,l.x),e.top=Math.min(s.y,a.y,o.y,l.y),e.bottom=Math.max(s.y,a.y,o.y,l.y);}(o,r,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function Op(e,[t,r]){let n=0,i=0;if(r===Cp){t<0&&(t=0);const r=t/Rp;switch(e){case "top-right":case "top-left":i=r-7;break;case "bottom-right":case "bottom-left":i=7-r;break;case "bottom":i=7-t;break;case "top":i=t-7;}switch(e){case "top-right":case "bottom-right":n=-r;break;case "top-left":case "bottom-left":n=r;break;case "left":n=t;break;case "right":n=-t;}}else {switch(t=Math.abs(t),r=Math.abs(r),e){case "top-right":case "top-left":case "top":i=r-7;break;case "bottom-right":case "bottom-left":case "bottom":i=7-r;}switch(e){case "top-right":case "bottom-right":case "right":n=-t;break;case "top-left":case "bottom-left":case "left":n=t;}}return [n,i]}function Up(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f){const m=e.layers[0],y=m.appearances;if(0===y.length)return {iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const g={iconBBox:null,iconVerticalBBox:null},x={textBBox:null,textVerticalBBox:null},{baseIconRotate:b,baseTextRotate:v,iconScaleFactor:w}=function(e,t,r){const n=e.get("icon-rotate").evaluate(t,{},r),i=e.get("text-rotate").evaluate(t,{},r),[s,a]=e.get("icon-size-scale-range");return {baseIconRotate:n,baseTextRotate:i,iconScaleFactor:Ze(1,s,a)}}(n,i,s);t&&(g.iconBBox=Lp(t,g.iconBBox,b),r)&&(g.iconVerticalBBox=Lp(r,g.iconVerticalBBox,b+90));const _=of(h.horizontal);_&&(x.textBBox=Lp(_,x.textBBox,v,1,p)),h.vertical&&(x.textVerticalBBox=Lp(h.vertical,x.textVerticalBBox,v+90,1,p));for(const r of y)r.hasIconLayoutProperties()&&Np(g,e,m,r,i,s,o,b,a,l,t,u,w,c,f),r.hasTextLayoutProperties()&&Gp(x,m,r,i,s,p,v,d,_,h.vertical);return {iconBBox:g.iconBBox,iconVerticalBBox:g.iconVerticalBBox,textBBox:x.textBBox,textVerticalBBox:x.textVerticalBBox}}function Np(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f){const{appearanceIconOffset:m,appearanceIconRotate:y,appearanceIconSize:g}=jp(n,r,i,s,a,o,l,u.iconScaleFactor);let x=null,b=null,v=null;n.hasLayoutProperty("icon-image")?v=function(e,t,r,n,i,s,a,o){let l=null;const u=t.getAppearanceValueAndResolveTokens(r,"icon-image",n,i,o);if(u){const c=e.getResolvedImageFromTokens(u),h=r.hasLayoutProperty("icon-size")?r.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],d=Xp(c,Ud(e.zoom,h,e.worldview,o),h,i,e.zoom,n,e.pixelRatio,a,e.worldview,o);l=s.get(d.iconPrimary.toString());}return l}(t,r,n,i,s,h,d,f):c&&(v=c.imagePrimary),v&&(x=Fd(v,null,m,p),t.allowVerticalPlacement&&(b=Fd(v,null,m,p)));const w=l>0?g/l:1;x&&(e.iconBBox=Lp(x,e.iconBBox,y,1!==w?w:void 0)),b&&(e.iconVerticalBBox=Lp(b,e.iconVerticalBBox,y+90,1!==w?w:void 0));}function jp(e,t,r,n,i,s,a,o){const l=e.hasLayoutProperty("icon-offset")?t.getAppearanceValueAndResolveTokens(e,"icon-offset",r,n,[]):null,u=l&&Array.isArray(l)?l:i,c=e.hasLayoutProperty("icon-rotate")?t.getAppearanceValueAndResolveTokens(e,"icon-rotate",r,n,[]):null,h="number"==typeof c?c:s,d=e.hasLayoutProperty("icon-size")?t.getAppearanceValueAndResolveTokens(e,"icon-size",r,n,[]):null;return {appearanceIconOffset:u,appearanceIconRotate:h,appearanceIconSize:"number"==typeof d?d*o:a}}function Gp(e,t,r,n,i,s,a,o,l,u){const{appearanceTextOffset:c,appearanceTextRotate:h,appearanceTextSize:d}=$p(r,t,n,i,s,a,o),p=d/o,f=[(c[0]-s[0])*p,(c[1]-s[1])*p],m=0!==f[0]||0!==f[1];l&&(e.textBBox=Lp(l,e.textBBox,h,p,c,m?f:void 0)),u&&(e.textVerticalBBox=Lp(u,e.textVerticalBBox,h+90,p,c,m?f:void 0));}function $p(e,t,r,n,i,s,a){const o=e.hasLayoutProperty("text-offset")?t.getAppearanceValueAndResolveTokens(e,"text-offset",r,n,[]):null,l=o&&Array.isArray(o)?[o[0]*Jh,o[1]*Jh]:i,u=e.hasLayoutProperty("text-rotate")?t.getAppearanceValueAndResolveTokens(e,"text-rotate",r,n,[]):null,c="number"==typeof u?u:s,h=e.hasLayoutProperty("text-size")?t.getAppearanceValueAndResolveTokens(e,"text-size",r,n,[]):null;return {appearanceTextOffset:l,appearanceTextRotate:c,appearanceTextSize:"number"==typeof h?h:a}}function qp(e,t,r,n,i,s,a,o,l){if(!t||!t.usvg)return;const u=Ld(n),c=Ld(i),h="both"!==s&&"width"!==s||!Cd(n)?1:c.width/u.width,d="both"!==s&&"height"!==s||!Rd(n)?1:c.height/u.height;r.scaleSelf(h,d);const p=r.toString();a.set(p,r),o.set(p,t);const{imagePosition:f}=lp(p,t,1);l.set(p,f);}function Hp(e,t,r,n,i,s,a,o,l,u){if(!e)return;const c=function(e,t,r,n,i,s,a){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Qa(e.maxZoom,{worldview:s}),r,a).evaluate(i,{},r,a),o=t.possiblyEvaluate(new Qa(e.minZoom,{worldview:s}),r,a).evaluate(i,{},r,a);return Math.max(n,o)}return t.possiblyEvaluate(new Qa(n,{worldview:s}),r,a).evaluate(i,{},r,a)}(t,r,n,i,s,l,u);return e.scaleSelf(c*o*a)}function Xp(e,t,r,n,i,s,a,o,l,u){return {iconPrimary:Hp(e.getPrimary(),t,r,n,i,s,a,o,l,u),iconSecondary:Hp(e.getSecondary(),t,r,n,i,s,a,o,l,u)}}function Zp(e,t,r){if(!t)return;const n=r.get(e.toString()),i=r.get(t.toString());n&&i&&(n.paddedRect.w===i.paddedRect.w&&n.paddedRect.h===i.paddedRect.h||lt(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==i.usvg&<(`Mismatch in icon variant image types: ${e.id} and ${t.id}`));}function Wp(e,t,r,n){if(!e)return;const i=t.get(r.toString());if(i&&(e.imagePrimary=i),n){const r=t.get(n.toString());e.imageSecondary=r;}}function Yp(e,t){for(const r in e.horizontal)Kp(e.horizontal[r],t);Kp(e.vertical,t);}function Kp(e,t){if(e)for(const r of e.positionedLines)for(const e of r.positionedGlyphs)if(null!==e.image){const r=e.image.toString();e.rect=t.get(r).paddedRect;}}function Jp(e){switch(e){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function Qp(e,t,r,n,i,s,a,o,l){const u=of(s.horizontal)||s.vertical,c=r.get("icon-text-fit-padding").evaluate(n,{},i);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&s.vertical&&(h=Dd(t,s.vertical,l,c,o,a)),u&&(d=Dd(t,u,l,c,o,a))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function ef(e,t){return e*t/24}function tf(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v,w,_,A,I,M,S,B){let T=a.textMaxSize.evaluate(t,{},d);void 0===T?T=o*a.textScaleFactor:T*=a.textScaleFactor;const P=e.layers[0].layout,z=ef(o,a.textScaleFactor),E=of(r.horizontal)||r.vertical,k=e.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),V=e.getAppearanceFeatureData(t.index);("none"!==y||k)&&V&&(V.textShaping=E,V.iconTextFitPadding=P.get("icon-text-fit-padding").evaluate(t,{},d),V.fontScale=z,V.textScaleFactor=a.textScaleFactor);const F="globe"===p.name,D=e.tilePixelRatio*T/24,C=(j=e.overscaling,e.zoom>18&&j>2&&(j>>=1),Math.max(Xn/(512*j),1)*P.get("symbol-spacing")),R=P.get("text-padding")*e.tilePixelRatio,L=P.get("icon-padding")*e.tilePixelRatio,O=Ge(P.get("text-max-angle")),U="map"===P.get("icon-rotation-alignment")&&"point"!==b,N=C/2;var j;!1===e.hasAnyIconTextFit&&"none"!==y&&(e.hasAnyIconTextFit=!0);const G=t.properties?+t.properties[_h]:null,$=e.hdExt?e.hdExt.elevationFeatureIdToIndex:void 0,q=G&&$?$.get(G):65535,H=(o,l,b)=>{if(l.x<0||l.x>=Xn||l.y<0||l.y>=Xn)return;if(M&&M.length>0&&t.properties&&B&&B(M,t.properties,l,d,S))return;let A=null;if(F){const{x:e,y:t,z:r}=p.projectTilePoint(l.x,l.y,b);A={anchor:new Gd(e,t,r,0,void 0),up:p.upVector(b,l.x,l.y)};}!function(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,b,v,w,_,A,I,M,S,B,T,P,z,E){const k=e.addToLineVertexArray(t,n);let V,F,D,C,R,L,O,U=0,N=0,j=0,G=0,$=-1,q=-1;const H={};let X=hr("");const Z=r?r.anchor:t,W="none"!==B;let Y=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(v,{},I);Y=e[0]*Jh,K=e[1]*Jh;}else Y=l.layout.get("text-radial-offset").evaluate(v,{},I)*Jh,K=Cp;if(e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(f)L=uf(e),o&&(O=uf(o));else {const r=l.layout.get("text-rotate").evaluate(v,{},I)+90;D=lf(u,Z,t,c,h,d,e,p,r,m,E),o&&(C=lf(u,Z,t,c,h,d,o,g,r,null,z));}}if(s){const n=l.layout.get("icon-rotate").evaluate(v,{},I),i=Ap(s,n,_,W,w.iconScaleFactor),a=o?Ap(o,n,_,W,w.iconScaleFactor):void 0;F=lf(u,Z,t,c,h,d,s,g,n,null,P);const p=function(e,t,r,n,i,s,a,o,l,u){const c=e.layers[0],h=c.appearances;let d=t.length;if(r&&(d=Math.max(d,r.length)),0===h.length)return d;const[p,f]=n.get("icon-size-scale-range"),m=Ze(1,p,f);for(const t of h)if(t.hasLayoutProperty("icon-image")){const r=c.getAppearanceValueAndResolveTokens(t,"icon-image",s,a,u);if(r){const n=e.getResolvedImageFromTokens(r);if(n){const r=t.hasLayoutProperty("icon-size")?t.getUnevaluatedLayoutProperty("icon-size"):i._values["icon-size"],l=Xp(n,Ud(e.zoom,r,e.worldview,u),r,a,e.zoom,s,e.pixelRatio,m,e.worldview,u),c=o.get(l.iconPrimary.toString());c&&(d=Math.max(d,Ip(c)));}}}return d}(e,i,a,l.layout,l._unevaluatedLayout,v,I,e.iconAtlasPositions,0,A);U=4*p;const f=l.layout.get("icon-size").evaluate(v,{},I,A),m=w.compositeIconSizes?w.compositeIconSizes[0].evaluate(v,{},I,A):0,y=w.compositeIconSizes?w.compositeIconSizes[1].evaluate(v,{},I,A):0,B=af(e.layerIds[0],e.iconSizeData,f,s.imagePrimary.usvg?1:w.iconScaleFactor,m,y);e.addSymbols(e.icon,i,B,b,x,v,void 0,r,t,k.lineStartIndex,k.lineLength,-1,A,I,M,S,e.symbolInstances.length,p),$=e.icon.placedSymbolArray.length-1,a&&(N=4*p,e.addSymbols(e.icon,a,B,b,x,v,vd.vertical,r,t,k.lineStartIndex,k.lineLength,-1,A,I,M,S,e.symbolInstances.length,p),q=e.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=n,o=i.horizontal[s];V||(X=hr(o.text),f?R=uf(o):V=lf(u,Z,t,c,h,d,o,p,l.layout.get("text-rotate").evaluate(v,{},I),m,E));const y=1===o.positionedLines.length;if(j+=sf(e,r,t,o,a,l,f,v,m,k,i.vertical?vd.horizontal:vd.horizontalOnly,y?Dp(i.horizontal):[s],H,$,w,A,I,e.symbolInstances.length,M),y)break}i.vertical&&(G+=sf(e,r,t,i.vertical,a,l,f,v,m,k,vd.vertical,["vertical"],H,q,w,A,I,e.symbolInstances.length,M));let J=-1;const Q=(e,t)=>e?Math.max(e,t):t;J=Q(R,J),J=Q(L,J),J=Q(O,J);const ee=J>-1?1:0;e.glyphOffsetArray.length>=65535&<("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,Z.x,Z.y,Z.z,H.right>=0?H.right:-1,H.center>=0?H.center:-1,H.left>=0?H.left:-1,H.vertical>=0?H.vertical:-1,$,q,X,void 0!==V?V:e.collisionBoxArray.length,void 0!==V?V+1:e.collisionBoxArray.length,void 0!==D?D:e.collisionBoxArray.length,void 0!==D?D+1:e.collisionBoxArray.length,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,C||e.collisionBoxArray.length,C?C+1:e.collisionBoxArray.length,c,j,G,U,N,ee,0,Y,K,J,0,W?1:0,T);}(e,l,A,o,r,n,s,i,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,R,x,u,0,L,U,g,t,a,c,h,d,f,m,y,q,v,w,_);};if("line"===b)for(const i of dh(t.geometry,0,0,Xn,Xn)){const t=Wd(i,C,O,r.vertical||E,n,24,D,e.overscaling,Xn);for(const r of t)E&&cf(e,E.text,N,r)||H(i,r,d);}else if("line-center"===b){for(const e of t.geometry)if(e.length>1){const t=Zd(e,O,r.vertical||E,n,24,D);t&&H(e,t,d);}}else if("Polygon"===t.type)for(const e of Pe(t.geometry,0)){const t=kp(e,16);H(e[0],new Gd(t.x,t.y,0,0,void 0),d);}else if("LineString"===t.type)for(const e of t.geometry)H(e,new Gd(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)H([t],new Gd(t.x,t.y,0,0,void 0),d);}const rf=255,nf=rf*Od;function sf(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x){const b=Ep(0,n,l,s,a,o,i,e.allowVerticalPlacement,void 0,f.textScaleFactor),v=s.layout.get("text-size").evaluate(o,{},y),w=f.compositeTextSizes?f.compositeTextSizes[0].evaluate(o,{},y):0,_=f.compositeTextSizes?f.compositeTextSizes[1].evaluate(o,{},y):0,A=af(e.layerIds[0],e.textSizeData,v,f.textScaleFactor,w,_);e.addSymbols(e.text,b,A,l,a,o,c,t,r,u.lineStartIndex,u.lineLength,p,m,y,x,!1,g,b.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*b.length}function af(e,t,r,n,i,s){const a=t;let o=null;return "source"===a.kind?(o=[Od*r*n],o[0]>nf&<(`${e}: Value for "text-size" or "icon-size" is >= ${rf}. Reduce your "text-size" or "icon-size".`)):"composite"===a.kind&&(o=[Od*i*n,Od*s*n],(o[0]>nf||o[1]>nf)&<(`${e}: Value for "text-size" or "icon-size" is >= ${rf}. Reduce your "text-size" or "icon-size".`)),o}function of(e){for(const t in e)return e[t];return null}function lf(e,t,r,n,i,s,a,o,l,u,c){let h,d,p,f;if(h=c?c.top:a.top,d=c?c.bottom:a.bottom,p=c?c.left:a.left,f=c?c.right:a.right,Vd(a)&&a.collisionPadding){const e=a.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3];}if(l){const e=new _e(p,h),t=new _e(f,h),r=new _e(p,d),n=new _e(f,d),i=Ge(l);let s=new _e(0,0);u&&(s=new _e(u[0],u[1])),e._rotateAround(i,s),t._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(e.x,t.x,r.x,n.x),f=Math.max(e.x,t.x,r.x,n.x),h=Math.min(e.y,t.y,r.y,n.y),d=Math.max(e.y,t.y,r.y,n.y);}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,p,h,f,d,o,n,i,s),e.length-1}function uf(e){Vd(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function cf(e,t,r,n){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])h&&(h=n);}return n[0]=c,n[1]=h,n}function bf(e,t){let r=!0;for(let n=0;n=0);if(0===s)return 0;s!==t.length&&(r=!1);}return r?2:1}const vf=[0,0];function wf(e,t){for(const r of e.projections){const n=xf(t,e.points[0],r.axis,vf);if(r.projection[1]n[1])return 0}return 1}function _f(e,t){const r=t[0],n=t[1],i=t[2],s=t[3];for(let t=0;t=0)return !0}return !1}class Af{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=If.fromPoints(this.points),this.projections=[],this.frustumEdges=[W([],this.points[2],this.points[3]),W([],this.points[0],this.points[3]),W([],this.points[4],this.points[0]),W([],this.points[5],this.points[1]),W([],this.points[6],this.points[2]),W([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],r=[e[2],0,-e[0]];this.projections.push({axis:t,projection:xf(this.points,this.points[0],t,[0,0])}),this.projections.push({axis:r,projection:xf(this.points,this.points[0],r,[0,0])});}}static fromInvProjectionMatrix(e,t,r,n){const i=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(r=>{const s=te([],r,e),a=1/s[3]/t*i;return (o=s)[0]=(l=s)[0]*(u=[a,a,n?1/s[3]:a,a])[0],o[1]=l[1]*u[1],o[2]=l[2]*u[2],o[3]=l[3]*u[3],o;var o,l,u;}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=U([],j([],W([],s[e[0]],s[e[1]]),W([],s[e[2]],s[e[1]]))),r=-N(t,s[e[1]]);return t.concat(r)}),o=[];for(let e=0;eh&&(h=r);}let d=1/0,p=-1/0;for(let t=0;tp&&(p=n);}if(c>p||d>h)return 0}return 1}containsPoint(e){for(const t of this.planes){const r=t[3];if(N([t[0],t[1],t[2]],e)+r<0)return !1}return !0}}class If{static fromPoints(e){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of e)k(t,t,n),V(r,r,n);return new If(t,r)}static fromTileIdAndHeight(e,t,r){const n=1<e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}function Mf(e){return e*yl/Al}ea(If,"Aabb");const Sf=[new If([bl,bl,bl],[vl,vl,vl]),new If([bl,bl,bl],[0,0,vl]),new If([0,bl,bl],[vl,0,vl]),new If([bl,0,bl],[0,vl,vl]),new If([0,0,bl],[vl,vl,vl])];function Bf(e,t,r,n=!0){const i=F([],e._camera.position,e.worldSize),s=[t,r,1,1];te(s,s,e.pixelMatrixInverse),Q(s,s,1/s[3]);const a=U([],W([],s,i)),o=e.globeMatrix,l=[o[12],o[13],o[14]],u=W([],l,i),c=S(u),h=U([],u),d=e.worldSize/(2*Math.PI),p=N(h,a),f=Math.asin(d/c);if(f1?null:function(e,t,r,n){const i=Math.sin(r);return e*(Math.sin((1-n)*r)/i)+t*(Math.sin(n*r)/i)}(e.a[t],e.b[t],e.angle,Ze(r,0,1))+e.center[t]}function zf(e){if(e.z<=1)return Sf[e.z+2*e.y+e.x];const t=Cf(Df(e));return If.fromPoints(t)}function Ef(e,t,r){return F(e,e,1-r),D(e,e,t,r)}function kf(e,t){const r=qf(t.zoom);if(0===r)return zf(e);const n=Df(e),i=Cf(n),s=_n(n.getWest())*t.worldSize,a=_n(n.getEast())*t.worldSize,o=An(n.getNorth())*t.worldSize,l=An(n.getSouth())*t.worldSize,u=[s,o,0],c=[a,o,0],d=[s,l,0],p=[a,l,0],f=h([],t.globeMatrix);return $(u,u,f),$(c,c,f),$(d,d,f),$(p,p,f),i[0]=Ef(i[0],d,r),i[1]=Ef(i[1],p,r),i[2]=Ef(i[2],c,r),i[3]=Ef(i[3],u,r),If.fromPoints(i)}function Vf(e,t,r){for(const n of e)$(n,n,t),F(n,n,r);}function Ff(e,t,r,n){const i=t/e.worldSize,s=e.globeMatrix;if(r.z<=1){const e=zf(r).getCorners();return Vf(e,s,i),If.fromPoints(e)}const a=Df(r,n),o=Cf(a,yl+Mf(e._tileCoverLift));Vf(o,s,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(a.contains(e.center)){for(const e of o)k(c,c,e),V(u,u,e);u[2]=0;const t=e.point,r=[t.x*i,t.y*i,0];return k(c,c,r),V(u,u,r),new If(c,u)}if(e._tileCoverLift>0){for(const e of o)k(c,c,e),V(u,u,e);return new If(c,u)}const h=[s[12]*i,s[13]*i,s[14]*i],d=a.getCenter(),p=Ze(e.center.lat,-85.051129,zl),f=Ze(d.lat,-85.051129,zl),m=_n(e.center.lng),y=An(p);let g=m-_n(d.lng);const x=y-An(f);g>.5?g-=1:g<-.5&&(g+=1);let b=0;Math.abs(g)>Math.abs(x)?b=g>=0?1:3:(b=x>=0?0:2,D(h,h,[s[4]*i,s[5]*i,s[6]*i],-Math.sin(Ge(x>=0?a.getSouth():a.getNorth()))*yl));const v=o[b],w=o[(b+1)%4],_=new Tf(v,w,h),A=[Pf(_,0)||v[0],Pf(_,1)||v[1],Pf(_,2)||v[2]],I=qf(e.zoom);if(I>0){const n=function({x:e,y:t,z:r},n,i,s,a){const o=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*n-(s*=n))*i+s,u=((u+d)*n-s)*i+s,c=(c*n-(a*=n))*i+a,h=(h*n-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,t,e._pixelsPerMercatorPixel,m,y);for(let e=0;eMath.PI/2*1.01}const Zf=Ge(85),Wf=Math.cos(Zf),Yf=Math.sin(Zf);function Kf(e,t){const r=e.fovAboveCenter,n=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,i=Math.min(n,e.isOrthographic?-10*t:0),s=(e._camera.position[2]*e.worldSize-i)/Math.cos(e._pitch),a=Math.sin(r)*s/Math.sin(Math.max(Math.PI/2-e._pitch-r,.01));let o=Math.sin(e._pitch)*a+s;const l=s*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let t=Math.max(e.zoom-17,0);e.isOrthographic&&(t/=10),o*=1+t;}return Math.min(1.01*o,l)}class Jf{constructor(e,t,r){this.z=e,this.x=t,this.y=r,this.key=tm(0,e,e,t,r);}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return 0===e.z||e.z>t&&e.y===this.y>>t}url(e,t){const r=function(e,t,r){const n=2**r,i=2*Math.PI*6378137,s=i*(e/n-.5),a=i*(.5-(t+1)/n);return `${s},${a},${s+i/n},${a+i/n}`}(this.x,this.y,this.z),n=function(e,t,r){let n,i="";for(let s=e;s>0;s--)n=1<this.canonical.z?new em(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new em(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return tm(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return tm(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new em(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new em(t,this.wrap,t,r,n),new em(t,this.wrap,t,r+1,n),new em(t,this.wrap,t,r,n+1),new em(t,this.wrap,t,r+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,r=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,r=e.wrap;return t===1<new em(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new em(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<b&&(v(e,u,n,i,o,l),v(u,r,o,l,s,a));}v(h,d,n,s,i,s),v(d,p,i,s,i,a),v(p,f,i,a,n,a),v(f,h,n,a,n,s),m-=b,y-=b,g+=b,x+=b;const w=1/Math.max(g-m,x-y);return {scale:w,x:m*w,y:y*w,x2:g*w,y2:x*w,projection:t}}function im(e,{x:t,y:r},n=0){return new _e(((t-n)*e.scale-e.x)*Xn,(r*e.scale-e.y)*Xn)}ea(Jf,"CanonicalTileID"),ea(em,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const sm=c(new Float32Array(16));class am{constructor(e){this.spec=e,this.name=e.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(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new Ml(0,0)}projectTilePoint(e,t,r){return {x:e,y:t,z:0}}locationPoint(e,t,r,n=!0){return e._coordinatePoint(e.locationCoordinate(t,r),n)}pixelsPerMeter(e,t){return Tl(1,e)*t}pixelSpaceConversion(e,t,r){return 1}farthestPixelDistance(e){return Kf(e,e.pixelsPerMeter)}pointCoordinate(e,t,r,n){const i=e.horizonLineFromTop(!1),s=new _e(t,Math.max(i,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,r){const n=new _e(t,r);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(e,t.x,t.y);const r=e.horizonLineFromTop();return t.y0?t<-mm+r&&(t=-mm+r):t>mm-r&&(t=mm-r);const s=i/Math.pow(ym(t),n);let a=s*Math.sin(n*e),o=i-s*Math.cos(n*e);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:r,f:n}=this,i=n-t,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(e*e+i*i);let o=Math.atan2(e,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(e)*s);const l=Ze($e(o/r)+this.center[0],-180,180),u=Ze($e(2*Math.atan(Math.pow(n/a,1/r))-mm),-85.051129,zl);return new Ml(l,this.southernCenter?-u:u)}}class xm extends am{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:_n(e),y:An(t),z:0}}unproject(e,t){const r=In(e),n=Mn(t);return new Ml(r,n)}}const bm=Ge(zl);class vm extends am{project(e,t){const r=(t=Ge(t))*t,n=r*r;return {x:.5*((e=Ge(e))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const e=s*s;i=(r*(1.007226+s*(.015085+e*(.028874*s-.044475-.005916*e)))-t)/(1.007226+s*(.045255+e*(.259866*s-.311325-.005916*11*e))),r=Ze(r-i,-bm,bm);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=Ze($e(e/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=$e(r);return new Ml(a,o)}}const wm=Ge(zl);class _m extends am{project(e,t){t=Ge(t),e=Ge(e);const r=Math.cos(t),n=2/Math.PI,i=Math.acos(r*Math.cos(e/2)),s=Math.sin(i)/i,a=.5*(e*n+2*r*Math.sin(e/2)/s)||0,o=.5*(t+Math.sin(t)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(e,t){let r=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),d=Math.sin(r/2),p=2*h*d,f=d*d,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*d+2*r/Math.PI)-e,b=.5*(g*s+n)-t,v=.5*y*(c*f+g*i*h*u)+1/Math.PI,w=y*(p*l/4-g*s*d),_=.125*y*(l*d-g*s*c*p),A=.5*y*(u*h+g*f*i)+.5,I=w*_-A*v;a=(b*w-x*A)/I,o=(x*_-b*v)/I,r=Ze(r-a,-Math.PI,Math.PI),n=Ze(n-o,-wm,wm);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new Ml($e(r),$e(n))}}class Am extends am{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:r,cosPhi:n}=this;return {x:Ge(e)*n*r+.5,y:-Math.sin(Ge(t))/n*r+.5,z:0}}unproject(e,t){const{scale:r,cosPhi:n}=this,i=-(t-.5)/r,s=Ze($e((e-.5)/r)/n,-180,180),a=Math.asin(Ze(i*n,-1,1)),o=Ze($e(a),-85.051129,zl);return new Ml(s,o)}}class Im extends xm{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,r){const n=Rf(e,t,r);return $(n,n,Uf(zf(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,r){const n=_l(t.lat,t.lng),i=U([],n),s=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;D(n,n,i,Tl(1,0)*Xn*s);const a=c(new Float64Array(16));return d(a,e.pixelMatrix,e.globeMatrix),$(n,n,a),new _e(n[0],n[1])}pixelsPerMeter(e,t){return Tl(1,0)*t}pixelSpaceConversion(e,t,r){const n=Tl(1,e)*t,i=wr(Tl(1,45)*t,n,r);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,r){const n=Nf(zf(r.canonical));return d(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:r}=e,n=Uf(zf(t));return y(n,n,Ge(r.lng)),m(n,n,Ge(r.lat)),f(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,r,n){return Bf(e,t,r,!0)||new Dl(0,0)}pointCoordinate3D(e,t,r){const n=this.pointCoordinate(e,t,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(e,t){return !Bf(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const r=e.cameraToCenterDistance,n=e._centerAltitude*t,i=e._camera,s=e._camera.forward(),a=P([],F([],s,-r),[0,0,n]),o=e.worldSize/(2*Math.PI),l=[0,0,-o],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=F([],i.up(),c),d=F([],i.right(),c*u),p=U([],P([],P([],s,h),d)),f=[];let m;if(new yf(a,p).closestPointOnSphere(l,o,f)){const t=P([],f,l),r=W([],t,a);m=Math.cos(e.fovAboveCenter)*S(r);}else {const e=W([],a,l),t=W([],l,a);U(t,t);const r=S(e)-o;m=Math.sqrt(r*(r+2*o));const n=Math.acos(m/(o+r))-Math.acos(N(s,t));m*=Math.cos(n);}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=qf(e.zoom);if(r>0){const n=Kf(e,Tl(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return wr(t,n+i*(1-Math.cos(s)),Math.pow(r,10))}return t}upVector(e,t,r){return Rf(t,r,e,1)}upVectorScale(e){return {metersToTile:Mf(Lf(zf(e)))}}}function Mm(e){const t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case "mercator":return new xm(e);case "equirectangular":return new fm(e);case "naturalEarth":return new vm(e);case "equalEarth":return new pm(e);case "winkelTripel":return new _m(e);case "albers":return r?new Am(e):new om(e);case "lambertConformalConic":return r?new Am(e):new gm(e);case "globe":return new Im(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Sm=Number.MAX_SAFE_INTEGER,Bm=Sm-1;function Tm(e,t,r,n){return e.ordert.max.x||e.max.xt.max.y||e.max.ynew _e((e.x+s.x*Xn)*o-a.x*Xn,(e.y+s.y*Xn)*o-a.y*Xn));}return Dm(r,i,e.indices,0,e.indices.length,0,0)}function Rm(e,t,r,n){const i=Math.pow(2,n.z-r.z);return new _e((e+r.x*Xn)*i-n.x*Xn,(t+r.y*Xn)*i-n.y*Xn)}function Lm(e,t){const r=[];t.grid.queryPoint(e,r);const n=t.indices,i=t.vertices;for(let t=0;tfunction(e){if(!e.condition)return {featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const t=e.condition.expression;return {featureDependent:!vi(t),stateDependent:!wi(t),zoomDependent:!_i(t,["zoom"]),pitchDependent:!_i(t,["pitch"]),brightnessDependent:!_i(t,["brightness","measure-light"]),worldviewDependent:!_i(t,["worldview"])}}(e));this.anyFeatureDependent=r.some(e=>e.featureDependent),this.anyStateDependent=r.some(e=>e.stateDependent);}update(e,t){const r=this.lastParams,n=!r||r.zoom!==e.zoom||r.pitch!==(e.pitch||0)||r.brightness!==(e.brightness||0)||r.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const i=t&&this.anyStateDependent;if(!n&&!i&&-2!==this.lastAllFeaturesIndex)return {kind:"no-changes"};if(!this.anyFeatureDependent&&!i){const t=this.evaluateAllFeatures(e);return t===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=t,{kind:"all-features",appearanceIndex:t})}return {kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;te-t),i=new Map;for(const e of n){const t=r.get(e);i.set(e,new Ku(t));}return t&&(this.cachedBatchIndices=n,this.cachedBatchSegments=i),{batchIndices:n,batchSegments:i}}snapshotSymbolVertexData(e,t){const r=e*Xm;return this.layoutVertexArray.uint16.slice(r,r+t*Xm)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*Xm);}updateSymbolVertexData(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=this.layoutVertexArray.uint16,f=e*Xm;p[f]=t,p[f+1]=r,p[f+2]=n,p[f+3]=i,p[f+4]=s,p[f+5]=a,p[f+6]=o,p[f+7]=l,p[f+8]=u,p[f+9]=c,p[f+10]=h,p[f+11]=d;}upload(e,t,r,n,i,s){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Vh.members,!!s),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Dh.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Nm,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Oh.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Fh.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Ch.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,Lh.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,Rh.members,!1))),(r||n)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy());}}ea(Zm,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Wm{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new Ku,this.collisionVertexArray=new xu,this.collisionVertexArrayExt=new du;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Uh.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Nh.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}ea(Wm,"CollisionBuffers");class Ym{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=c([]),this.placementViewportMatrix=c([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.disableSymbolUBO=e.disableSymbolUBO,this.textSizeData=Ud(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=Ud(this.zoom,t["icon-size"],this.worldview,e.availableImages);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(e=>vd[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map;}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||0===t.length)return !1;const r=Array.isArray(e)?e:[e];return t.some(e=>r.some(t=>e.hasLayoutProperty(t)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new Zm(new Ic(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new Zm(new Ic(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Kh(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Kh(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new Uu,this.lineVertexArray=new Nu,this.symbolInstances=new Ou;}calculateGlyphDependencies(e,t,r,n,i){for(const r of e){const e=r.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&i&&e<=65535){const e=ed[r];e&&(t[e.charCodeAt(0)]=!0);}}}calculateEffectiveAppearanceIconSize(e,t,r,n,i,s,a){if(!e.hasLayoutProperty("icon-size"))return a*s;let o=1;const l=e.getUnevaluatedLayoutProperty("icon-size"),u=Ud(this.zoom,l,this.worldview,i),c=jd(u,t);if("constant"!==u.kind&&"camera"!==u.kind||(o=c.uSize),"composite"===u.kind){const{minZoom:e,maxZoom:t}=u,s=l.possiblyEvaluate(new Qa(e,{worldview:this.worldview}),n),a=l.possiblyEvaluate(new Qa(t,{worldview:this.worldview}),n),h=s.evaluate(r,{},n,i);o=h+(a.evaluate(r,{},n,i)-h)*c.uSizeT;}return "source"===u.kind&&(o=l.possiblyEvaluate(new Qa(this.zoom,{worldview:this.worldview}),n).evaluate(r,{},n,i)),o*s}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return !km(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return "string"==typeof e?Jr.build(e):e}populate(e,t,r,n){const i=this.layers[0],s=i.layout,a="globe"===this.projection.name,o=s.get("text-font"),l=s.get("text-field"),u=s.get("icon-image"),[c,h]=s.get("icon-size-scale-range"),d=Ze(t.scaleFactor||1,c,h),[p,f]=s.get("text-size-scale-range"),m=Ze(t.scaleFactor||1,p,f),y=("constant"!==l.value.kind||l.value.value instanceof Yr&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),g="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,x=this.hasAnyAppearanceLayoutProperty("icon-image"),b=s.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!y&&!g&&!x)return;const v=t.iconDependencies,w=t.glyphDependencies,_=t.availableImages,A=new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),I=e=>{const t=e.id.toString();v.has(t)?v.get(t).push(e):v.set(t,[e]);};for(const t of e){const{feature:e,id:l,index:u,sourceLayerIndex:c}=t,h=i._featureFilter.needGeometry,p=$l(e,h);if(!i._featureFilter.filter(A,p,r))continue;if(h||(p.geometry=Gl(e,r,n)),a&&1!==e.type&&r.z<=5){const e=p.geometry,t=.98078528056,n=(e,n)=>N(Rf(e.x,e.y,r,1),Rf(n.x,n.y,r,1)){if(!e.getLayoutProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,S,p,r,_,P,d);t&&I(t);}),f){const e=o.evaluate(p,{},r).join(","),t="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(vd.vertical);for(const r of f.sections)if(r.image){const e=r.image.getPrimary().scaleSelf(this.pixelRatio*m),t=e.id.toString(),n=v.get(t)||[];n.push(e),v.set(t,n);}else {const n=Ea(f.toString()),i=r.fontStack||e,s=w[i]=w[i]||{};this.calculateGlyphDependencies(r.text,s,t,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(e){const t={},r={},n=[];let i=0;function s(t){n.push(e[t]),i++;}function a(e,t,i){const s=r[e];return delete r[e],r[t]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(e,r,i){const s=t[r];return delete t[r],t[e]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(e,t,r){const n=r?t[0].at(-1):t[0][0];return `${e}:${n.x}:${n.y}`}for(let u=0;ue.geometry)}(this.features)),"hd-road-markup"===s.get("symbol-elevation-reference")?(this.elevationType="road",this.hdExt&&t.elevationFeatures&&t.elevationFeatures.length>0&&this.hdExt.addElevationFeatures(t.elevationFeatures)):s.get("symbol-z-elevate")&&(this.elevationType="offset"),"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey);}getCombinedIconPrimary(e,t,r,n,i,s,a){let o,l;if(e.hasLayoutProperty("icon-image")){const s=t.getAppearanceValueAndResolveTokens(e,"icon-image",r,n,i);o=this.getResolvedImageFromTokens(s);}else {const e=t.getValueAndResolveTokens("icon-image",r,n,i);o=this.getResolvedImageFromTokens(e);}if(o){const r=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"];l=Xp(o,Ud(this.zoom,r,this.worldview,i),r,n,this.zoom,s,this.pixelRatio,a,this.worldview,i).iconPrimary;}return l}updateSymbolInstanceIconVertices(e,t,r,n,i,s){const{canonical:a,availableImages:o,globalProperties:l,layer:u,iconScaleFactor:c,featureState:h,layoutIconOffset:d,layoutIconSize:p,layoutIconRotate:f}=s;if(e.placedIconSymbolIndex<0)return {vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const m=r>=0?u.appearances[r]:null;if(m){const r=this.getCombinedIconPrimary(m,u,n,a,o,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},c);if(!r)return {vertexOffsetDelta:0,hasChanges:!1};const s=r.toString(),y=this.iconAtlasPositions&&this.iconAtlasPositions.get(s);if(y){const{appearanceIconOffset:r,appearanceIconRotate:s}=jp(m,u,n,a,d,f,p,c);let g=Fd(y,void 0,r,u.layout.get("icon-anchor").evaluate(n,h,a));const x=y.sdf,b=u.layout.get("icon-text-fit").constantOr("none");"none"!==b&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(g=Dd(g,t.textShaping,b,t.iconTextFitPadding,r,t.fontScale));const v=this.calculateEffectiveAppearanceIconSize(m,l.zoom,n,a,o,c,p),w=0,_=1+(Math.min(nf,Math.round(v*Od))<<1),A=Ap(g,s,x,"none"!==b,c);t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(i,e.numIconVertices));const I=Math.floor(e.numIconVertices/4),M=Math.min(A.length,I);let S=i;for(let r=0;r0||e.numVerticalGlyphVertices>0;if(!b)return {vertexOffsetDelta:b?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const v=r>=0?o.appearances[r]:null;if(v&&t.textShaping){const{appearanceTextOffset:r,appearanceTextRotate:s,appearanceTextSize:b}=$p(v,o,n,a,h,p,d);t.fontScale=ef(b,t.textScaleFactor);const w=v.getUnevaluatedLayoutProperty("text-size");let _=this.textSizeData,A=y,I=g;v.hasLayoutProperty("text-size")&&(_=Ud(this.zoom,w,this.worldview,x),A="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,I="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);const M=t.textShaping.bottom-h[1],S=t.textShaping.left-h[0],B=t.textShaping.right-h[0];t.textShaping.top=r[1]+(t.textShaping.top-h[1]),t.textShaping.bottom=r[1]+M,t.textShaping.left=r[0]+S,t.textShaping.right=r[0]+B;const T=Ep(0,t.textShaping,r,o,!1,n,u,this.allowVerticalPlacement,s),P=b&&"composite"===_.kind?w.possiblyEvaluate(new Qa(A,{}),a).evaluate(n,c,a):f,z=b&&"composite"===_.kind?w.possiblyEvaluate(new Qa(I,{}),a).evaluate(n,c,a):m,E=af(v.name,_,b,l,P,z),k=Array.isArray(E)?E[1]:b,V=0,F=1+(Math.min(nf,Math.round(k*Od))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(i,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let t=0;t0){const n=i[0],s=[this.text.uboBinder,this.icon.uboBinder].filter(e=>e&&e.hasStateDependentPaint(n));if(s.length>0){const i=new Set(Object.keys(e).map(e=>{const t=Number(e);return !isNaN(t)&&Number.isSafeInteger(t)&&String(t)===e?t:e}));for(const l of s)l.updateFeatures(i,n,t,o,r,e,a);}}}updateZOffset(){const e=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n);},t=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||s>0)&&(e(this.text.zOffsetVertexArray,i,o),e(this.text.zOffsetVertexArray,s,o)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:r}=n;e>=0&&t(this.icon.zOffsetVertexArray,a,o),r>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,r,n,i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0;}updateAppearances(e,t,r,n,i,s=!1){const a={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!r||!this.featureAppearanceData)return a;const o=t||{},l=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,u=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!l&&!u)return a;const c=this.layers[0],h=c.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===c.appearancesVersion||(this.featureAppearances=new Om(c.appearances,c.appearancesVersion));const d=this.featureAppearances.update(n,s);if("no-changes"===d.kind)return a;let p=1,f=0,m=!1,y=!1;if(l){const[e,t]=h.get("icon-size-scale-range");p=Ze(1,e,t);}let g=1,x=0,b=!1;if(u){const[e,t]=h.get("text-size-scale-range");g=Ze(1,e,t);}const v=new Map;if(i&&r)for(const e of r){const t=i.getImage(e,c.scope);if(t){const r=new Kr(e.toString());v.set(r.toString(),t);}}const w=[this.text.uboBinder,this.icon.uboBinder];for(let t=0;tt.isActive({globals:n,feature:A,canonical:e,featureState:_})):-1;I=t>=0?t:-1;}const M=s.activeAppearanceIndex!==I;if(u){const t=h.get("text-size"),n="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,a="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,o={canonical:e,layer:c,featureState:_,availableImages:r,textScaleFactor:g,imageMap:v,layoutTextOffset:h.get("text-offset").evaluate(A,_,e).map(e=>e*Jh),layoutTextSize:t.evaluate(A,_,e),layoutTextRotate:h.get("text-rotate").evaluate(A,_,e),layoutMinZoomSize:t.evaluate(A,{zoom:n},e),layoutMaxZoomSize:t.evaluate(A,{zoom:a},e),layoutTextSizeMinZoom:n,layoutTextSizeMaxZoom:a},l=this.updateSymbolInstanceTextVertices(i,s,I,A,x,o);x+=l.vertexOffsetDelta,b=b||l.hasChanges;}if(l){const t={canonical:e,layer:c,featureState:_,availableImages:r,globalProperties:n,iconScaleFactor:p,layoutIconOffset:h.get("icon-offset").evaluate(A,_,e),layoutIconSize:h.get("icon-size").evaluate(A,_,e,r),layoutIconRotate:h.get("icon-rotate").evaluate(A,_,e)},a=this.updateSymbolInstanceIconVertices(i,s,I,A,f,t);f+=a.vertexOffsetDelta,m=m||a.hasChanges;}if(M){const t=i.featureIndex,s=n?n.brightness:null,a=_||{},o=I>=0?c.appearances[I]:null;for(const n of w)n&&(n.layer=c,y=n.updateFeaturePaintForAppearance(t,A,a,e,r,s,o)||y);}s.activeAppearanceIndex=I;}return m&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),b&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:m||b,hasUboChanges:y}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Mm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const r=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:r}of t)this.lineVertexArray.emplaceBack(e,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g){const x=e.indexArray,b=e.layoutVertexArray,v=e.globeExtVertexArray,w=g,_=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,A=e.segments.prepareSegment(4*w,b,x,this.canOverlap?s.sortKey:void 0,_),I=this.glyphOffsetArray.length,M=A.vertexLength,S=this.allowVerticalPlacement&&a===vd.vertical?Math.PI/2:0,B=s.text&&s.text.sections;let T=b.length,P=-1;for(let n=0;n=0)){const t=4*z;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),s=Nd(this.textSizeData,e,i)/Jh;return this.tilePixelRatio*s}getSymbolInstanceIconSize(e,t,r){const n=this.icon.placedSymbolArray.get(r),i=Nd(this.iconSizeData,e,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,r,n){e.emplaceBack(t,-r,-r,n),e.emplaceBack(t,r,-r,n),e.emplaceBack(t,r,r,n),e.emplaceBack(t,-r,r,n);}_updateTextDebugCollisionBoxes(e,t,r,n,i,s,a){for(let a=n;a0}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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const r=e.placedSymbolArray.get(t),n=r.vertexStartIndex+4*r.numGlyphs;for(let t=r.vertexStartIndex;tn[e]-n[t]||i[t]-i[e]),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const r=this.sortKeyRanges.at(-1);r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1});}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else {this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}getOrCreateSortedSymbolsByBatch(e,t){const r=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const r of this.symbolsByBatch.values())for(const n of r){const r=this.symbolInstances.get(n.index);n.rotatedY=0|Math.round(e*r.tileAnchorX+t*r.tileAnchorY);}else {this.symbolsByBatch=new Map;for(let n=0;ne.rotatedY-t.rotatedY||t.featureIndex-e.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(e,t){for(const r of e){const e=r.batchIndex;if(void 0===e)continue;const n=t.get(e);if(!n){r.primitiveOffset=this.text.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.text.indexArray.length;const i=this.text.indexArray.length;for(const{index:e}of n){const t=this.symbolInstances.get(e),{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s);}r.primitiveLength=this.text.indexArray.length-i;}}rebuildIconSegmentIndices(e,t){for(const r of e){const e=r.batchIndex;if(void 0===e)continue;const n=t.get(e);if(!n){r.primitiveOffset=this.icon.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.icon.indexArray.length;const i=this.icon.indexArray.length;for(const{index:e}of n){const t=this.symbolInstances.get(e),{placedIconSymbolIndex:r,verticalPlacedIconSymbolIndex:n}=t;r>=0&&this.addIndicesForPlacedSymbol(this.icon,r),n>=0&&this.addIndicesForPlacedSymbol(this.icon,n);}r.primitiveLength=this.icon.indexArray.length-i;}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const e=Math.sin(this.sortedAngle),t=Math.cos(this.sortedAngle),r=this.getOrCreateSortedSymbolsByBatch(e,t),n=Array.from(r.keys()).sort((e,t)=>e-t);for(const e of n){const t=r.get(e);for(const{index:e}of t){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),r),this.rebuildIconSegmentIndices(this.icon.segments.get(),r),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}ea(Ym,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),Ym.addDynamicAttributes=qm;class Km extends zc{constructor(e,t,r){super(e,t,r),this.elevatedLayoutVertexArray=new eu;}upload(e){const t=this.uploaded;super.upload(e),!t&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Zu.members));}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),super.destroy();}}ea(Km,"ElevatedFillBufferData");class Jm{constructor(){this.portals=[];}static isOnBorder(e,t){return e<=0&&t<=0||e>=Xn&&t>=Xn}static evaluate(e){if(0===e.length)return new Jm;let t=[];for(const r of e)t.push(...r.portals);if(0===t.length)return new Jm;for(const e of t){const t=e.va,r=e.vb;(Jm.isOnBorder(t.x,r.x)||Jm.isOnBorder(t.y,r.y))&&(e.type="border");}const r=t.filter(e=>"unevaluated"!==e.type),n=t.filter(e=>"unevaluated"===e.type);if(0===n.length)return new Jm;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hashe.hash"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new Ic(t,{zoom:r,lut:n},e=>"fill-bridge-guard-rail-color"!==e);}addVertices(e,t){const r=this.unevalVertices.length;for(let r=0;r=i.min.x&&u.x<=i.max.x&&u.y>=i.min.y&&u.y<=i.max.y||c.x>=i.min.x&&c.x<=i.max.x&&c.y>=i.min.y&&c.y<=i.max.y||sh(u,c,a)))continue;if(this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;const h=ey.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(ey.computePosHash(u));null!=p?d=p.next:(p=this.vertexHashLookup.get(ey.computePosHash(c)),d=null!=p?p.prev:h),this.unevalEdges.push({polygonIdx:e,a:r,b:l,hash:h,portalHash:d,isTunnel:n,type:"unevaluated",featureInfo:s});}}addPortalCandidates(e,t,r,n,i){if(0!==t.length){this.vertexHashLookup.clear();for(const i of t){if(0===i.length)continue;const t=i[0];let s=ey.computeEdgeHash(t[t.length-2],t.at(-1));for(let i=0;i({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset;},n=new Qm(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const i=t(),s=t(),a=t(),o=(e,t)=>{e.sort((e,r)=>e.type===t&&r.type!==t?-1:e.type!==t&&r.type===t?1:0);const r=e.findIndex(e=>e.type!==t);return r>=0?r:e.length};let l=0;this.unevalEdges.length>0&&(l=o(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),r(a);const u=t(),c=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=o(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t});}r(u),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(s),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights,4),r(i),this.maskSegments=Ku.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=Ku.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableBridgeSegments=Ku.simpleSegment(0,a.primitiveOffset,0,a.primitiveLength),this.renderableTunnelSegments=Ku.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=Ku.simpleSegment(0,i.primitiveOffset,0,i.primitiveLength);}update(e,t,r,n,i,s,a,o){this.bridgeProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o),this.tunnelProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o);}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,Wu.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,Yu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e));}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy();}populatePaintArrays(e,t,r,n,i){const s=(s,a)=>{for(let o=0;oT(e,t[n].x,t[n].y,r[n]*o),c=I(),h=I(),d=I(),p=I(),f=I(),m=(e,r)=>{const n=a.get(ey.computePosHash(t[r])),i=n.from,s=n.to;if(!i||!s)return;u(c,i),u(h,r),u(d,s),X(p),Z(c,h)||(W(f,h,c),U(p,f)),Z(d,h)||(W(f,d,h),P(p,p,U(f,f)));const o=K(p);return o>0?F(e,p,1/o):void 0};let y=Number.POSITIVE_INFINITY;this.sortSubarray(n,i.min,i.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const g=I(),x=I(),b=I(),v=I(),w=I(),_=I(),A=I(),M=I(),S=I(),B=[I(),I(),I(),I()],z=[I(),I(),I(),I()],E=[{coord:new _e(0,0),height:0},{coord:new _e(0,0),height:0}],k=(e,t)=>e>t;for(let u=i.min;ue.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,i.min,i.max,o),this.sortSubarray(n,s.min,s.max,o);const l=e=>U(e,e),u=[{coord:new _e(0,0),height:0},{coord:new _e(0,0),height:0}],c=(e,t)=>ee.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let r=0,n=0,i=0,s=t[r].polygonIdx;do{n++,(n===t.length||t[r].hash!==t[n].hash)&&((1===n-r||t[n-1].polygonIdx!==s)&&(ie.portalHashs.hash?r++:s.hash>i.portalHash?n++:(i.type=s.type,r++);}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Xn&&t>=Xn}addFeatureSection(e,t,r,n){return e!==t&&(t=e,r.push({featureIndex:e,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),t}sortSubarray(e,t,r,n){const i=e.slice(t,r);i.sort(n),e.splice(t,i.length,...i);}static computeEdgeHash(e,t){return (e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(ey.computePosHash(e))<<32n|BigInt(ey.computePosHash(t))}static computePosHash(e){return ((65535&e.x)<<16|65535&e.y)>>>0}}class ty{constructor(){this._valid=!1;}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,r){return this.get(e,!0,t,r)}optional(e,t,r){return this.get(e,!1,t,r)}success(){return this._valid}get(e,t,r,n){const i=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==i&&!Number.isNaN(i)?r(n?n(i):i):t&&(this._valid=!1),this}}class ry{constructor(e,t){this.featureFunc=e,this.vertexFunc=t;}parseFeature(e,t,r){return this.featureFunc(e,t,r)}parseVertex(e,t,r){return this.vertexFunc(e,t,r)}}const ny=new ry((e,t,r)=>e.reset(t).require(_h,e=>{r.id=e;}).optional("fixed_height_relative",e=>{r.constantHeight=e;},sy.decodeRelativeHeight).geometry(e=>{r.bounds=e;},Re).success(),(e,t,r)=>e.reset(t).require(_h,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height_relative",e=>{r.height=e;},sy.decodeRelativeHeight).geometry(e=>{r.position=e;},sy.getPoint).success()),iy=new ry((e,t,r)=>e.reset(t).require(_h,e=>{r.id=e;}).optional("fixed_height",e=>{r.constantHeight=e;},sy.decodeMetricHeight).geometry(e=>{r.bounds=e;},Re).success(),(e,t,r)=>e.reset(t).require(_h,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height",e=>{r.height=e;},sy.decodeMetricHeight).geometry(e=>{r.position=e;},sy.getPoint).success());class sy{static getPoint(e){return de(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?"1.0.1"===e?iy:void 0:ny}static parse(e){const t=[],r=[],n=e.length,i=new ty;for(let s=0;s{return e.a0?F(o,o,1/l):T(o,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,r=Number.POSITIVE_INFINITY,n=0;const[i,s,a,o,l,u,c]=this._tmpVec2;pe(c,e.x,e.y);const h=new mf(c,null);for(let e=0;e0?be(o,a)/x:0,v=Ze(b,0,1),w=Math.abs((b-v)*this.edgeProps[e].len);me(l,c,f),pe(u,p[1],-p[0]);const _=w+Math.abs(be(l,u));_=0;--s){const a=this.edges[s].a,o=this.edges[s].b,{position:l,height:u,extent:c}=this.vertices[a],{position:h,height:d,extent:p}=this.vertices[o],f=this.vertexProps[a].dir,m=this.vertexProps[o].dir;if(T(t,l[0]/e,l[1]/e,u),T(r,h[0]/e,h[1]/e,d),T(n,f[1],-f[0],0),F(n,n,c),T(i,m[1],-m[0],0),F(i,i,p),this.distSqLines(B(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),B(r[0]-.5*i[0],r[1]-.5*i[1],r[2]-.5*i[2]),B(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),B(r[0]+.5*i[0],r[1]+.5*i[1],r[2]+.5*i[2]))<=.0025000000000000005)continue;const y=this.vertices.length,g=fe(he(),l,h);this.vertices.push({position:ye(g,g,.5),height:.5*(u+d),extent:.5*(c+p)});const x=fe(he(),f,m);this.vertexProps.push({dir:xe(x,x)}),this.edges.splice(s,1),this.edgeProps.splice(s,1),this.edges.push({a,b:y}),this.edges.push({a:y,b:o});const b=me(he(),this.vertices[y].position,l),v=ge(b),w={vec:b,dir:ye(he(),b,1/v),len:v};this.edgeProps.push(w),this.edgeProps.push(w);}}distSqLines(e,t,r,n){const i=z(I(),t,e),s=z(I(),n,r),a=z(I(),e,r),o=N(i,i),l=N(i,s),u=N(i,a),c=N(s,s),h=N(s,a),d=o*c-l*l;if(0===d)return R(G(i,r,n,N(a,s)/N(s,s)),e);const p=(o*h-l*u)/d;return R(G(i,e,t,(l*h-u*c)/d),G(s,r,n,p))}}class ly{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*Xn,this.yOffset=(e.y*this.zScale-t.y)*Xn);}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,r){const n=this.constantElevation(t,r);return null!=n?n:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),r))}computeBiasedHeight(e,t){return t<=0?e:e+t*We(0,t,e>=0?e:Math.abs(.5*e))}}function uy(e){if(0===e)return [0,0,0];const t=vs(e);return [t(),t(),t()]}function cy(e,t){if(!t)return;const r=+e.properties[_h];return Number.isNaN(r)?void 0:t.find(e=>e.id===r)}function hy(e,t){return e>t?1:e0))return t;t=t.left;}}return null}contains(e){for(var t=this._root,r=this._compare;t;){var n=r(e,t.key);if(0===n)return !0;t=n<0?t.left:t.right;}return !1}remove(e){var t=this.find(e);if(!t)return !1;if(this.splay(t),t.left)if(t.right){var r=this.minNode(t.right);r.parent!==t&&(this.replace(r,r.right),r.right=t.right,r.right.parent=r),this.replace(t,r),r.left=t.left,r.left.parent=r;}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return !1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t;}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var r=t.left,n=t.right,i=null;r&&(r.parent=null,i=this.maxNode(r),this.splay(i),this._root=i),n&&(r?i.right=n:this._root=n,n.parent=i),this._size--;}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key);}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,r=[],n=!1,i=0;!n;)t?(r.push(t),t=t.left):r.length>0?(e(t=r.pop(),i++),t=t.right):n=!0;return this}range(e,t,r,n){const i=[],s=this._compare;let a,o=this._root;for(;0!==i.length||o;)if(o)i.push(o),o=o.left;else {if(o=i.pop(),a=s(o.key,t),a>0)break;if(s(o.key,e)>=0&&r.call(n,o))return this;o=o.right;}return this}keys(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.key),e=e.right):n=!0;return r}values(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.data),e=e.right):n=!0;return r}at(e){for(var t=this._root,r=[],n=!1,i=0;!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right;}else n=!0;return null}load(e=[],t=[],r=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return r&&fy(e,t,0,n-1,this._compare),this._root=py(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,r,n,i){return new dy(r,i).load(e,t,n)}}function py(e,t,r,n,i){const s=i-n;if(s>0){const a=n+Math.floor(s/2),o={key:t[a],data:r[a],parent:e};return o.left=py(o,t,r,n,a),o.right=py(o,t,r,a+1,i),o}return null}function fy(e,t,r,n,i){if(r>=n)return;const s=e[r+n>>1];let a=r-1,o=n+1;for(;;){do{a++;}while(i(e[a],s)<0);do{o--;}while(i(e[o],s)>0);if(a>=o)break;let r=e[a];e[a]=e[o],e[o]=r,r=t[a],t[a]=t[o],t[o]=r;}fy(e,t,r,o,i),fy(e,t,o+1,n,i);}const my=11102230246251565e-32,yy=134217729,gy=(3+8*my)*my;function xy(e,t,r,n,i){let s,a,o,l,u=t[0],c=n[0],h=0,d=0;c>u==c>-u?(s=u,u=t[++h]):(s=c,c=n[++d]);let p=0;if(hu==c>-u?(a=u+s,o=s-(a-u),u=t[++h]):(a=c+s,o=s-(a-c),c=n[++d]),s=a,0!==o&&(i[p++]=o);hu==c>-u?(a=s+u,l=a-s,o=s-(a-l)+(u-l),u=t[++h]):(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=n[++d]),s=a,0!==o&&(i[p++]=o);for(;h0:(r[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(r[1]-e[1])>0}isAbove(e){return !this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new By(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function Ty(e,t){return e[0]===t[0]&&e[1]===t[1]}function Py(e,t,r){const n=function(e,t,r,n,i,s){const a=(t-s)*(r-i),o=(e-i)*(n-s),l=a-o;if(0===a||0===o||a>0!=o>0)return l;const u=Math.abs(a+o);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,r,n,i,s,a){let o,l,u,c,h,d,p,f,m,y,g,x,b,v,w,_,A,I;const M=e-i,S=r-i,B=t-s,T=n-s;v=M*T,d=yy*M,p=d-(d-M),f=M-p,d=yy*T,m=d-(d-T),y=T-m,w=f*y-(v-p*m-f*m-p*y),_=B*S,d=yy*B,p=d-(d-B),f=B-p,d=yy*S,m=d-(d-S),y=S-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,vy[0]=w-(g+h)+(h-A),x=v+g,h=x-v,b=v-(x-h)+(g-h),g=b-_,h=b-g,vy[1]=b-(g+h)+(h-_),I=x+g,h=I-x,vy[2]=x-(I-h)+(g-h),vy[3]=I;let P=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,vy),z=22204460492503146e-32*a;if(P>=z||-P>=z)return P;if(h=e-M,o=e-(M+h)+(h-i),h=r-S,u=r-(S+h)+(h-i),h=t-B,l=t-(B+h)+(h-s),h=n-T,c=n-(T+h)+(h-s),0===o&&0===l&&0===u&&0===c)return P;if(z=11093356479670487e-47*a+gy*Math.abs(P),P+=M*c+T*o-(B*u+S*l),P>=z||-P>=z)return P;v=o*T,d=yy*o,p=d-(d-o),f=o-p,d=yy*T,m=d-(d-T),y=T-m,w=f*y-(v-p*m-f*m-p*y),_=l*S,d=yy*l,p=d-(d-l),f=l-p,d=yy*S,m=d-(d-S),y=S-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Iy[0]=w-(g+h)+(h-A),x=v+g,h=x-v,b=v-(x-h)+(g-h),g=b-_,h=b-g,Iy[1]=b-(g+h)+(h-_),I=x+g,h=I-x,Iy[2]=x-(I-h)+(g-h),Iy[3]=I;const E=xy(4,vy,4,Iy,wy);v=M*c,d=yy*M,p=d-(d-M),f=M-p,d=yy*c,m=d-(d-c),y=c-m,w=f*y-(v-p*m-f*m-p*y),_=B*u,d=yy*B,p=d-(d-B),f=B-p,d=yy*u,m=d-(d-u),y=u-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Iy[0]=w-(g+h)+(h-A),x=v+g,h=x-v,b=v-(x-h)+(g-h),g=b-_,h=b-g,Iy[1]=b-(g+h)+(h-_),I=x+g,h=I-x,Iy[2]=x-(I-h)+(g-h),Iy[3]=I;const k=xy(E,wy,4,Iy,_y);v=o*c,d=yy*o,p=d-(d-o),f=o-p,d=yy*c,m=d-(d-c),y=c-m,w=f*y-(v-p*m-f*m-p*y),_=l*u,d=yy*l,p=d-(d-l),f=l-p,d=yy*u,m=d-(d-u),y=u-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Iy[0]=w-(g+h)+(h-A),x=v+g,h=x-v,b=v-(x-h)+(g-h),g=b-_,h=b-g,Iy[1]=b-(g+h)+(h-_),I=x+g,h=I-x,Iy[2]=x-(I-h)+(g-h),Iy[3]=I;const V=xy(k,_y,4,Iy,Ay);return Ay[V-1]}(e,t,r,n,i,s,u)}(e[0],e[1],t[0],t[1],r[0],r[1]);return n>0?-1:n<0?1:0}function zy(e,t){const r=e.point,n=t.point;return r[0]>n[0]?1:r[0]n[1]?1:-1:function(e,t,r){return e.left!==t.left?e.left?1:-1:0!==Py(r,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,r)}function Ey(e,t,r){const n=new By(t,!1,e,e.isSubject),i=new By(t,!0,e.otherEvent,e.isSubject);return Ty(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=i.contourId=e.contourId,zy(i,e.otherEvent)>0&&(e.otherEvent.left=!0,i.left=!1),e.otherEvent.otherEvent=i,e.otherEvent=n,r.push(i),r.push(n),r}function ky(e,t){return e[0]*t[1]-e[1]*t[0]}function Vy(e,t){return e[0]*t[0]+e[1]*t[1]}function Fy(e,t,r){const n=function(e,t,r,n){const i=[t[0]-e[0],t[1]-e[1]],s=[n[0]-r[0],n[1]-r[1]];function a(e,t,r){return [e[0]+t*r[0],e[1]+t*r[1]]}const o=[r[0]-e[0],r[1]-e[1]];let l=ky(i,s),u=l*l;const c=Vy(i,i);if(u>0){const t=ky(o,s)/l;if(t<0||t>1)return null;const n=ky(o,i)/l;return n<0||n>1?null:0===t||1===t?[a(e,t,i)]:0===n||1===n?[a(r,n,s)]:[a(e,t,i)]}if(l=ky(o,i),u=l*l,u>0)return null;const h=Vy(i,o)/c,d=h+Vy(i,s)/c,p=Math.min(h,d),f=Math.max(h,d);return p<=1&&f>=0?1===p?[a(e,p>0?p:0,i)]:0===f?[a(e,f<1?f:1,i)]:[a(e,p>0?p:0,i),a(e,f<1?f:1,i)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),i=n?n.length:0;if(0===i||1===i&&(Ty(e.point,t.point)||Ty(e.otherEvent.point,t.otherEvent.point))||2===i&&e.isSubject===t.isSubject)return 0;if(1===i)return !Ty(e.point,n[0])&&!Ty(e.otherEvent.point,n[0])&&Ey(e,n[0],r),!Ty(t.point,n[0])&&!Ty(t.otherEvent.point,n[0])&&Ey(t,n[0],r),1;const s=[];let a=!1,o=!1;return Ty(e.point,t.point)?a=!0:1===zy(e,t)?s.push(t,e):s.push(e,t),Ty(e.otherEvent.point,t.otherEvent.point)?o=!0:1===zy(e.otherEvent,t.otherEvent)?s.push(t.otherEvent,e.otherEvent):s.push(e.otherEvent,t.otherEvent),a&&o||a?(t.type=1,e.type=t.inOut===e.inOut?2:3,a&&!o&&Ey(s[1].otherEvent,s[0].point,r),2):o?(Ey(s[0],s[1].point,r),3):s[0]!==s[3].otherEvent?(Ey(s[0],s[1].point,r),Ey(s[1],s[2].point,r),3):(Ey(s[0],s[1].point,r),Ey(s[3].otherEvent,s[2].point,r),3)}function Dy(e,t){if(e===t)return 0;if(0!==Py(e.point,e.otherEvent.point,t.point)||0!==Py(e.point,e.otherEvent.point,t.otherEvent.point))return Ty(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1](t.contourId??0)?1:-1}return 1===zy(e,t)?1:-1}class Cy{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null;}isExterior(){return null==this.holeOf}}function Ry(e,t,r,n){let i,s=e+1,a=t[e].point;const o=t.length;for(sn;)s--;return s}function Ly(e,t,r){const n=new Cy;if(null!=e.prevInResult){const i=e.prevInResult,s=i.outputContourId;if(i.resultTransition>0){const e=t[s];if(null!=e.holeOf){const i=e.holeOf;t[i].holeIds.push(r),n.holeOf=i,n.depth=t[s].depth;}else t[s].holeIds.push(r),n.holeOf=s,n.depth=t[s].depth+1;}else n.holeOf=null,n.depth=t[s].depth;}else n.holeOf=null,n.depth=0;return n}const Oy=Math.max,Uy=Math.min;let Ny=0;function jy(e,t,r,n,i,s){let a,o,l,u,c,h;for(a=0,o=e.length-1;a0?h.left=!0:c.left=!0;const o=l[0],d=l[1];i[0]=Uy(i[0],o),i[1]=Uy(i[1],d),i[2]=Oy(i[2],o),i[3]=Oy(i[3],d),n.push(c),n.push(h);}}const Gy=[];function $y(e,t,r){let n=e,i=t;"number"==typeof e[0][0][0]&&(n=[e]),"number"==typeof t[0][0][0]&&(i=[t]);let s=function(e,t,r){let n=null;return e.length*t.length===0&&(0===r?n=Gy:2===r?n=e:(1===r||3===r)&&(n=0===e.length?t:e)),n}(n,i,r);if(s)return s===Gy?null:s;const a=[1/0,1/0,-1/0,-1/0],o=[1/0,1/0,-1/0,-1/0],l=function(e,t,r,n,i){const s=new Hn(void 0,zy);let a,o,l,u,c,h;for(l=0,u=e.length;ln[2]||n[0]>r[2]||r[1]>n[3]||n[1]>r[3])&&(0===i?s=Gy:2===i?s=e:(1===i||3===i)&&(s=e.concat(t))),s}(n,i,a,o,r),s)return s===Gy?null:s;const u=function(e,t,r,n,i,s){const a=new dy(Dy),o=[],l=Math.min(n[2],i[2]);let u,c,h;for(;0!==e.length;){let t=e.pop();if(o.push(t),0===s&&t.point[0]>l||2===s&&t.point[0]>n[2])break;if(t.left){c=u=a.insert(t),h=a.minNode(),u=u!==h?a.prev(u):null,c=a.next(c);const r=u?u.key:null;let n;if(My(t,r,s),c&&2===Fy(t,c.key,e)&&(My(t,r,s),My(c.key,t,s)),u&&2===Fy(u.key,t,e)){let e=u;e=e!==h?a.prev(e):null,n=e?e.key:null,My(r,n,s),My(t,r,s);}}else t=t.otherEvent,c=u=a.find(t),u&&c&&(u=u!==h?a.prev(u):null,c=a.next(c),a.remove(t),c&&u&&Fy(u.key,c.key,e));}return o}(l,0,0,a,o,r),c=function(e){let t,r;const n=function(e){let t,r,n,i,s;const a=[];for(r=0,n=e.length;r{i[t]=!0,t=n.length)&&n[o];);s.push(r);}return s}(u),h=[];for(let e=0;e0&&(i=$y(i,s,2)),Yy(i,1/n,.001)}function Xy(e,t=1){return [e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Zy(e,t){const r=Math.floor(e)+.5;return Math.abs(e-r)<=t?Math.round(r):Math.round(e)}class Wy{constructor(e){this.xs=[],this.ys=[],this.ixs=[],this.iys=[],this.buckets=new Map,this.tolerance=e;}canonicalize(e,t){const r=this.tolerance,n=Math.floor(e/r),i=Math.floor(t/r);for(let s=-1;s<=1;s++){const a=this.buckets.get(n+s);if(a)for(let s=-1;s<=1;s++){const o=a.get(i+s);if(o)for(const s of o)if(Math.abs(this.xs[s]-e)<=r&&Math.abs(this.ys[s]-t)<=r){const r=this.ixs[s],a=this.iys[s];return this.xs[s]===e&&this.ys[s]===t||this.store(e,t,r,a,n,i),[r,a]}}}const s=Zy(e,r),a=Zy(t,r);return this.store(e,t,s,a,n,i),[s,a]}store(e,t,r,n,i,s){const a=this.xs.length;this.xs.push(e),this.ys.push(t),this.ixs.push(r),this.iys.push(n);let o=this.buckets.get(i);o||(o=new Map,this.buckets.set(i,o));let l=o.get(s);l||(l=[],o.set(s,l)),l.push(a);}}function Yy(e,t=1,r){const n=null!=r?new Wy(r):null;return e.map(e=>e.map((e,r)=>{const i=e.map(e=>{const r=e[0]*t,i=e[1]*t;if(n){const[e,t]=n.canonicalize(r,i);return new _e(e,t)}return new _e(Math.round(r),Math.round(i))});return r>0&&i.reverse(),i}))}class Ky{constructor(){this.frcCoverage=new Set,this.featureTriSegments=[],this.frcPerLevel=new Map,this.frcNonRoadSegments=new Ku;}empty(){return 0===this.frcCoverage.size}}function Jy(e,t,r){if(0===e.frcCoverage.size||0===e.featureTriSegments.length)return;const n=r.get(),i=t.uint16,s=[];e.featureTriSegments.sort((e,t)=>e.segIdx!==t.segIdx?e.segIdx-t.segIdx:null===e.frc&&null===t.frc?0:null===e.frc?-1:null===t.frc?1:t.frc-e.frc);const a=new Map;let o=0,l=e.featureTriSegments[0].frc,u={vertexOffset:n[o].vertexOffset,primitiveOffset:0,vertexLength:n[o].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0};const c=()=>{u.primitiveLength>0&&(a.has(l)||a.set(l,[]),a.get(l).push(Object.assign({},u)));};for(const t of e.featureTriSegments){t.segIdx!==o&&(c(),o=t.segIdx,l=t.frc,u={vertexOffset:n[o].vertexOffset,primitiveOffset:s.length/3,vertexLength:n[o].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0}),t.frc!==l&&(c(),l=t.frc,u=Object.assign({},u,{primitiveOffset:s.length/3,primitiveLength:0}));for(let e=t.start;e0?i.length-1:0,frc:n});}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&Jy(this.frcData,e.bufferData.indexArray,e.bufferData.triangleSegments);}handleFeature(e,t,r,n,i,s){const a=new Array;if(!this.elevationMode)return !1;const o=cy(e,i);if(!o)return !1;{const e=this.clipPolygonsToTile(t,1);e.length>0&&a.push({polygons:e,elevationFeature:o,elevationTileID:n});}const l={guardRailEnabled:s.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},n),featureIndex:r};for(const t of a)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ey(t.elevationTileID,s.layers,s.zoom,s.lut));const r=t.elevationFeature.isTunnel();let n=0;Object.hasOwn(e.properties,Ah)&&(n=+e.properties[Ah]),this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,t.polygons,r,t.elevationFeature,n);}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const i=new ly(n,t.elevationTileID);this.addElevatedGeometry(s,t.polygons,i,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,r,l);}return !0}populatePaintArrays(e,t,r,n,i,s,a){this.elevationBufferData&&this.elevationBufferData.populatePaintArrays(e,t,r,n,i,s,a);}update(e,t,r,n,i,s,a,o){this.elevationBufferData&&this.elevationBufferData.update(e,t,r,n,i,s,a,o),this.elevatedStructures&&this.elevatedStructures.update(e,t,r,n,i,s,a,o);}updateExpressions(e){this.elevationBufferData&&this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e));}upload(e){this.elevationBufferData&&this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e);}destroy(){this.elevationBufferData&&this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy();}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,r,n,i,s){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,r,n,i,s));}addElevatedGeometry(e,t,r,n,i,s,a){const o={elevation:n,elevationSampler:r,bias:i,index:s,featureInfo:a},[l,u]=e.addGeometry(t,this.elevationBufferData,o,this.elevatedStructures);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:l,max:u}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,l),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,u));}prepareElevatedPolygons(e,t,r){const n=1/Fl(r),i=[];for(const r of e){const e=Hy(r,new ay(t,n),.1);i.push(...e);}return i}clipPolygonsToTile(e,t){const r=-t,n=-t,i=Xn+t,s=Xn+t;let a=0;const o=[],l=[];for(;a=r&&u.max.x<=i&&u.min.y>=n&&u.max.y<=s?o:l).push(t);}if(o.length===e.length)return e;const u=[new _e(r,n),new _e(i,n),new _e(i,s),new _e(r,s),new _e(r,n)],c=o;for(const e of l)c.push(...qy(e,u));return c}}function ng(e,t){return e.nextPoint.sub(t.at(-2)).unit()}function ig(e,t){return t[1].sub(e.prevPoint).unit()}ea(rg,"FillHDExtension"),ea(ey,"ElevatedStructures");class sg{constructor(e,t){this.elevationEnabled=e,t&&(this.frcData=new Ky);}isEmpty(){const e=!this.elevationEnabled||void 0===this.heightRange,t=!this.frcData||this.frcData.empty();return e&&t}trackFeatureFrc(e){if(!this.frcData)return null;const t=eg(e||{});return null!==t&&this.frcData.frcCoverage.add(t),t}recordFeatureRange(e,t,r,n){if(!this.frcData||r<=t)return;const i=e.segments.get();this.frcData.featureTriSegments.push({start:3*t,end:3*r,segIdx:i.length>0?i.length-1:0,frc:n});}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&Jy(this.frcData,e.indexArray,e.segments);}handleFeature(e,t,r,n,i,s,a,o,l){if(!this.elevationEnabled)return !1;const u=cy(e,n);if(u){const n=dh(t,-1,-1,8193,8193),c=this.prepareElevatedLines(n,u,r);for(const t of c){const n=l.layoutVertexArray.length;l.addLine(t,e,r,i,s,a,o);const c=new ly(r,r),h=l.showElevationIdDebug?uy(u.id):null;for(let e=n;e>1,l.layoutVertexArray.int16[6*e+1]>>1),r=c.pointElevation(t,u,.05);this.updateHeightRange(r),l.zOffsetVertexArray.emplaceBack(r,0,0,0),h?l.elevationIdColVertexArray.emplaceBack(h[0],h[1],h[2]):l.showElevationIdDebug&&l.elevationIdColVertexArray.emplaceBack(0,0,0);}}return !0}const c=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics,h=l.layoutVertexArray.length,d=[],p=dh(t,-1,-1,8193,8193,d);for(let t=0;t0?u.parentIndex:null);}return l.fillNonElevatedRoadSegment(h),!0}prepareElevatedLines(e,t,r){if(null!=t.constantHeight)return e;const n=[],i=1/Fl(r);for(const r of e)ph(r,new ay(t,i),0,n);return n}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e};}}ea(sg,"LineHDExtension");class ag{constructor(){this.elevatedLayoutVertexArray=new eu,this.hasElevation=!1;}beginFeature(e,t){this.currentFeatureElevation=cy(e,t);}writeVertexQuad(e,t){const r=this.currentFeatureElevation?this.currentFeatureElevation.pointElevation(new _e(e,t)):0;this.hasElevation=this.hasElevation||0!==r;for(let e=0;e<4;e++)this.elevatedLayoutVertexArray.emplaceBack(r);}finalize(){this.hasElevation||(this.elevatedLayoutVertexArray=void 0);}upload(e){this.elevatedLayoutVertexArray&&!this.elevatedLayoutVertexBuffer&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,zh.members));}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy();}}ea(ag,"CircleHDExtension");const og=(e,t,r,n)=>{for(let i=0;i0||h>0,m=d>0,y=this.elevationFeatures[o.elevationFeatureIndex];if(y){const t=new _e(o.tileAnchorX,o.tileAnchorY),c=.075+y.pointElevation(t);o.zOffset!==c&&(r=!0,o.zOffset=c),0!==c&&(e.hasAnyZOffset=!0);const h=y.computeSlopeNormal(t,i),d=ce(re(),B(0,0,1),h);H(l,l,d),H(u,u,d),l[2]*=n,u[2]*=n,1===l[0]&&0===l[1]&&0===l[2]&&0===u[0]&&1===u[1]&&0===u[2]||(s=s||f,a=a||m);}if(f&&(og(e.text.orientationVertexArray,c,l,u),og(e.text.orientationVertexArray,h,l,u)),m){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=o;t>=0&&og(e.icon.orientationVertexArray,d,l,u),r>=0&&og(e.icon.orientationVertexArray,p,l,u);}}s||(e.text.orientationVertexArray=void 0),a||(e.icon.orientationVertexArray=void 0),r&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}getElevationFeatureForPlacedSymbol(e,t,r){const n=e.symbolInstances.get(t.symbolInstanceIndices[r]).elevationFeatureIndex;if(n>2)-3,a=r[n++]>>2;if(n++,i.json=JSON.parse(Tg.decode(r.subarray(n,n+a))),n+=a,n>>0,Math.ceil(1.2*i)),a=Math.ceil((s-i)/65536);try{return r.grow(a),n(),!0}catch(e){return !1}},b:i}}).then(e=>{const{Rb:i,Qb:s,P:a,T:o,X:l,Ja:u,La:c,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:y,e:g,yb:x,zb:b,Ab:v,Bb:w,Db:_,Gb:A}=e.instance.exports;r=g;const I=(()=>{let e=0,r=0,n=0,a=0;return o=>{n&&(i(a),i(e),r+=n,n=e=0),e||(r+=128,e=s(r));const l=o.length+7&-8;let u=e;l>=r&&(n=l,u=a=s(l));for(let e=0;e{ug=e,cg=null;})),cg}()),d&&c.push(function(){var e;if(!hg)return null!=dg||(dg=(e=fetch(Et()),WebAssembly.instantiateStreaming(e,{}).then(e=>{const{sbrk:t,memory:r,meshopt_decodeVertexBuffer:n,meshopt_decodeIndexBuffer:i,meshopt_decodeIndexSequence:s,meshopt_decodeFilterOct:a,meshopt_decodeFilterQuat:o,meshopt_decodeFilterExp:l}=e.instance.exports,u={ATTRIBUTES:n,TRIANGLES:i,INDICES:s},c={OCTAHEDRAL:a,QUATERNION:o,EXPONENTIAL:l};return e.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(e,n,i,s,a,o){const l=n+3&-4,h=t(l*i),d=t(s.length),p=new Uint8Array(r.buffer);p.set(s,d);const f=u[a](h,n,i,d,s.length);if(0===f&&c[o]&&c[o](h,l,i),e.set(p.subarray(h,h+n*i)),t(h-t(0)),0!==f)throw new Error(`Malformed buffer data: ${f}`)}}})).then(e=>{hg=e,dg=null;})),dg}()),a)for(let e=0;e{const i=ir(e,(e,t)=>{e?n(e):r(t);});t&&t.addEventListener("abort",()=>{i.cancel(),n(new DOMException("Aborted","AbortError"));},{once:!0});})}({url:e,type:"arrayBuffer"},t);return Vg(r,0,e,t)}class Dg{constructor(e,t,r,n){if(this.triangleCount=t.length/3,this.min=new _e(0,0),this.max=new _e(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[i,s]=[e[0].clone(),e[0].clone()];for(let t=1;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let u=0;for(;uthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const r=Cg(e.x-this.min.x,this.xScale,this.cellsX),n=Cg(e.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Cg(e.x-this.min.x,this.xScale,this.cellsX),i=Cg(t.x-this.min.x,this.xScale,this.cellsX),s=Cg(e.y-this.min.y,this.yScale,this.cellsY),a=Cg(t.y-this.min.y,this.yScale,this.cellsY);for(let e=s;e<=a;e++)for(let t=n;t<=i;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;e0){const r=function(e,t){const r=t.worldSize,n=Tl(1,0)*r*kl(t.center.lat,t.zoom)/jf(r),i=Tl(1,t.center.lat)*r,s=c([]);y(s,s,Ge(t.center.lng)),m(s,s,Ge(t.center.lat)),p(s,s,[0,0,yl]),f(s,s,[n,n,n*i]);const a=t.point;return p(s,s,[-a.x,-a.y,0]),d(s,s,e),d(s,t.globeMatrix,s)}(e,t);return function(e,t,r){const n=(e,t,r)=>{const n=S(e),i=S(t),s=Ef(e,t,r);return F(s,s,1/S(s)*wr(n,i,r))},i=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],r),s=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],r),a=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],r),o=Ef([e[12],e[13],e[14]],[t[12],t[13],t[14]],r);return [i[0],i[1],i[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],1]}(i,r,n)}return i}function ex(e,t,r,n){const i=If.projectAabbCorners(n,r);let s=Number.MAX_VALUE;for(let e=0;e0||0===a&&r[0]*s[0]+r[1]*s[1]>=0&&r[0]*r[0]+r[1]*r[1]>s[0]*s[0]+s[1]*s[1])&&(n=t);}i=n;}while(i!==r);return t.length>0&&t.push(t[0]),t}(i);if(Hc(e,a))return s}const tx=64,rx={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function nx(e,t,r,n,i,s,a,o,l,u=!1){const h=r.zoom,m=r.project(n),y=kl(n.lat,h),g=1/y;c(e),p(e,e,[m.x+a[0]*g,m.y+a[1]*g,a[2]]);let x=1,b=1;const v=r.worldSize;if(u){if("mercator"===r.projection.name){let e=0;r.elevation&&(e=r.elevation.getAtPointOrZero(new Dl(m.x/v,m.y/v),0));const t=te([],[m.x,m.y,e,1],r.projMatrix)[3]/r.cameraToCenterDistance;x=t,b=t*kl(r.center.lat,h);}else if("globe"===r.projection.name){const t=Qg(e,r),i=[0,0,0,1];te(i,i,d([],r.projMatrix,t));const s=i[3]/r.cameraToCenterDistance,a=qf(h),o=r.projection.pixelsPerMeter(n.lat,v)*kl(n.lat,h),l=r.projection.pixelsPerMeter(r.center.lat,v)*kl(r.center.lat,h);x=s/wr(o,El(r.center.lat),a),b=s*y/o,x*=l,b*=l;}}else x=g;f(e,e,[x,x,b]);const w=[...e],A=t.orientation,I=[];if(Kg(I,[A[0]+(i?i[0]:0),A[1]+(i?i[1]:0),A[2]+(i?i[2]:0)],s),d(e,w,I),o&&r.elevation){let i=0;const s=[];if(l&&r.elevation){i=function(e,t,r,n,i){const s=t.elevation;if(!s)return 0;const a=If.projectAabbCorners(r,n),o=Tl(1,i.lat)*t.worldSize,l=function(e,t){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of n){const n=e[i.corners[0]],s=e[i.corners[1]],a=e[i.corners[2]],o=[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])],l=j(o,o,[a[0]-n[0],a[1]-n[1],t*(a[2]-n[2])]);U(l,l),i.dotProductWithUp=N(l,r);}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(a,o),u=a[l[0]],c=a[l[1]],h=a[l[2]],d=a[l[3]],p=s.getAtPointOrZero(new Dl(u[0]/t.worldSize,u[1]/t.worldSize),0),f=s.getAtPointOrZero(new Dl(c[0]/t.worldSize,c[1]/t.worldSize),0),m=s.getAtPointOrZero(new Dl(h[0]/t.worldSize,h[1]/t.worldSize),0),y=s.getAtPointOrZero(new Dl(d[0]/t.worldSize,d[1]/t.worldSize),0),g=(p+y)/2,x=(f+m)/2;return g>x?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function ax(e,t,r){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Rg.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Ng.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Ug.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Lg:Og).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Gg.members,!0)),e.segments=Ku.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&sx(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&sx(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&sx(n.normalTexture,t),n.occlusionTexture&&sx(n.occlusionTexture,t,r),n.emissionTexture&&sx(n.emissionTexture,t);}function ox(e,t,r){if(e.meshes)for(const n of e.meshes)ax(n,t,r);if(e.lodMeshes)for(const n of e.lodMeshes)ax(n,t,r);if(e.children)for(const n of e.children)ox(n,t,r);}function lx(e){e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();}function ux(e){if(e.meshes)for(const t of e.meshes)lx(t);if(e.lodMeshes)for(const t of e.lodMeshes)lx(t);if(e.children)for(const t of e.children)ux(t);}function cx(e){var t;e.vertexBuffer&&(e.vertexBuffer.destroy(),e.indexBuffer.destroy(),e.normalBuffer&&e.normalBuffer.destroy(),e.texcoordBuffer&&e.texcoordBuffer.destroy(),e.colorBuffer&&e.colorBuffer.destroy(),e.pbrBuffer&&e.pbrBuffer.destroy(),e.segments.destroy(),e.material&&((t=e.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));}function hx(e){if(e.meshes)for(const t of e.meshes)cx(t);if(e.lodMeshes)for(const t of e.lodMeshes)cx(t);if(e.footprintDebugMesh&&(e.footprintDebugMesh.vertexBuffer.destroy(),e.footprintDebugMesh.indexBuffer.destroy(),e.footprintDebugMesh.segments.destroy()),e.children)for(const t of e.children)hx(t);}function dx(e,t,r,n){return e[0]<=n[0]&&t[0]>=r[0]&&e[1]<=n[1]&&t[1]>=r[1]&&e[2]<=n[2]&&t[2]>=r[2]}function px(e,t,r,n,i,s,a,o,l,u,c){const h=.5*(u[0]+c[0]),d=.5*(u[1]+c[1]),p=.5*(u[2]+c[2]),f=.5*(c[0]-u[0]),m=.5*(c[1]-u[1]),y=.5*(c[2]-u[2]),g=e-h,x=t-d,b=r-p,v=n-h,w=i-d,_=s-p,A=a-h,I=o-d,M=l-p,S=v-g,B=w-x,T=_-b,P=A-v,z=I-w,E=M-_,k=g-A,V=x-I,F=b-M;let D,C,R,L,O,U;if(D=b*B-x*T,C=_*B-w*T,R=M*B-I*T,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(T)*m+Math.abs(B)*y,L>U||O<-U)return !1;if(D=b*z-x*E,C=_*z-w*E,R=M*z-I*E,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(E)*m+Math.abs(z)*y,L>U||O<-U)return !1;if(D=b*V-x*F,C=_*V-w*F,R=M*V-I*F,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(F)*m+Math.abs(V)*y,L>U||O<-U)return !1;if(D=g*T-b*S,C=v*T-_*S,R=A*T-M*S,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(T)*f+Math.abs(S)*y,L>U||O<-U)return !1;if(D=g*E-b*P,C=v*E-_*P,R=A*E-M*P,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(E)*f+Math.abs(P)*y,L>U||O<-U)return !1;if(D=g*F-b*k,C=v*F-_*k,R=A*F-M*k,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(F)*f+Math.abs(k)*y,L>U||O<-U)return !1;if(D=x*S-g*B,C=w*S-v*B,R=I*S-A*B,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(B)*f+Math.abs(S)*m,L>U||O<-U)return !1;if(D=x*P-g*z,C=w*P-v*z,R=I*P-A*z,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(z)*f+Math.abs(P)*m,L>U||O<-U)return !1;if(D=x*k-g*V,C=w*k-v*V,R=I*k-A*V,L=Math.min(D,C,R),O=Math.max(D,C,R),U=Math.abs(V)*f+Math.abs(k)*m,L>U||O<-U)return !1;if(L=Math.min(g,v,A),O=Math.max(g,v,A),L>f||O<-f)return !1;if(L=Math.min(x,w,I),O=Math.max(x,w,I),L>m||O<-m)return !1;if(L=Math.min(b,_,M),O=Math.max(b,_,M),L>y||O<-y)return !1;const N=B*E-T*z,j=T*P-S*E,G=S*z-B*P,$=-(N*g+j*x+G*b);return U=f*Math.abs(N)+m*Math.abs(j)+y*Math.abs(G),!(Math.abs($)>U)}const fx=[];class mx{serializeFromGltf(e,t,r,n){if(e.length<7)return;let i=0;if(109!==e[i++]||98!==e[i++]||120!==e[i++]||98!==e[i++]||118!==e[i++]||104!==e[i++])return;if(43!==e[i++])return;const s=new DataView(e.buffer,e.byteOffset),a=s.getUint16(i,!0);if(i+=2,0===a)return;this._nodes=[];let o=0;for(let e=0;e0;){const i=r.pop(),s=this._nodes[i];if(s.aabbMax[2]<=n)continue;if(65535===s.backChild){for(let r=0;r=0?n:null}}function yx(e,t){const r=e.json.bufferViews[t.bufferView],n=bg[t.componentType];return new n(e.buffers[r.buffer],(t.byteOffset||0)+(r.byteOffset||0),t.count*(r.byteStride&&r.byteStride!==wg[t.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:wg[t.type]))}function gx(e,t,r,n){const i=bg[t.componentType],s=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),a=e.json.bufferViews[t.bufferView],o=a.byteStride?a.byteStride/i.BYTES_PER_ELEMENT:wg[t.type],l=r.float32,u=l.length/r.capacity,c=t.count*o;for(let e=0,t=0;e0){s.texcoordArray=new Bu;const e=t.json.accessors[i.TEXCOORD_0];s.texcoordArray.resizeExact(e.count);const r=yx(t,e);gx(t,e,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const e=t.json.accessors[i._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(s.featureData=yx(t,e));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(yx(t,t.json.accessors[i._FEATURE_RGBA4444]).buffer));const y=e.material;return s.material=function(e,t){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:a,emissiveTexture:o,doubleSided:l,name:u}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=a?t[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&m){const e=a.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]];}return {name:u,pbrMetallicRoughness:{baseColorFactor:new Ar(...c),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new Ar(...r),alphaMode:n,alphaCutoff:i,normalTexture:s?t[s.index]:void 0,occlusionTexture:m,emissionTexture:o?t[o.index]:void 0,defined:void 0===e.defined}}(void 0!==y?t.json.materials[y]:{defined:!1},r),s}function bx(e,t,r){const{matrix:n,rotation:i,translation:s,scale:a,mesh:o,extras:l,children:c,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,r,n){var i=t[0],s=t[1],a=t[2],o=t[3],l=i+i,u=s+s,c=a+a,h=i*l,d=i*u,p=i*c,f=s*u,m=s*c,y=a*c,g=o*l,x=o*u,b=o*c,v=n[0],w=n[1],_=n[2];return e[0]=(1-(f+y))*v,e[1]=(d+b)*v,e[2]=(p-x)*v,e[3]=0,e[4]=(d-b)*w,e[5]=(1-(h+y))*w,e[6]=(m+g)*w,e[7]=0,e[8]=(p+x)*_,e[9]=(m-g)*_,e[10]=(1-(h+f))*_,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}([],i||[0,0,0,1],s||[0,0,0],a||[1,1,1]),d.globalMatrix=u(d.localMatrix),void 0!==o){d.meshes=r[o];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:r,max:n}=t.aabb;e[0]+=r[0]+n[0],e[1]+=r[1]+n[1];}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2);}if(l&&(l.id&&(d.id=l.id),l.lights&&(d.lights=function(e){if(!e.length)return [];const t=function(e){const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e=o.length||i>=o.length||s>=o.length||a>=o.length)return null;const l=o[n],u=o[i],c=o[s],h=o[a];if(void 0===l.bufferView||void 0===u.bufferView||void 0===c.bufferView||void 0===h.bufferView)return null;const d=e.json.bufferViews;if(l.bufferView>=d.length||u.bufferView>=d.length||c.bufferView>=d.length||h.bufferView>=d.length)return null;const p=d[l.bufferView],f=d[u.bufferView],m=d[c.bufferView],y=d[h.bufferView];if(p.buffer>=e.buffers.length||f.buffer>=e.buffers.length||m.buffer>=e.buffers.length||y.buffer>=e.buffers.length)return null;const g=(e,t,r)=>e>=0&&e<=r&&t<=r-e,x=l.byteOffset||0,b=u.byteOffset||0,v=c.byteOffset||0,w=h.byteOffset||0;if(!(g(x,0,p.byteLength)&&g(b,3*u.count*4,f.byteLength)&&g(v,3*c.count*4,m.byteLength)&&g(w,4*h.count,y.byteLength)))return null;const _=new Uint8Array(e.buffers[p.buffer],(p.byteOffset||0)+x,p.byteLength-x),A=new Float32Array(e.buffers[f.buffer],(f.byteOffset||0)+b,3*u.count),I=new Float32Array(e.buffers[m.buffer],(m.byteOffset||0)+v,3*c.count),M=new Uint32Array(e.buffers[y.buffer],(y.byteOffset||0)+w,h.count),S=new mx;if(S.serializeFromGltf(_,A,I,M),void 0!==r&&e.json.meshes&&e.json.meshes[r]){const t=e.json.meshes[r].primitives[0];if(t&&void 0!==t.attributes.POSITION&&t.attributes.POSITION1&&n.at(-1).equals(n[0])&&n.pop();let i=0;for(let e=0;e0&&n.reverse();const s=No(n.flatMap(e=>[e.x,e.y]),[]);return 0===s.length?null:{vertices:n,indices:s}}function _x(e,t){const r=[],n=[];let i=0;const s=[];for(const a of e){i=r.length;const e=a.vertexArray.float32,o=a.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]]);}return {vertices:r,indices:n}}function Ax(e,t){for(let r=0;r0){const t=Array.from(i.values()).sort((e,t)=>e-t);for(let r=t.length-1;r>=0;r--)e.splice(t[r],1);}}(l,o,e.json.nodes);const u=n?Ax(n,"LOD"):-1;if(u>=0){const t=n[u].nodes,i=new Map;for(const n of t){const t=bx(s[n],e,r);t.id&&i.set(t.id,t);}for(const e of l)if(e.id){const t=i.get(e.id);t&&t.meshes&&(e.lodMeshes=t.meshes,t.meshBVH&&(e.meshBVH=t.meshBVH));}}return l}function Mx(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,r=e.aabb.min[0]-1,n=e.aabb.min[1]-1,i=tx/(e.aabb.max[0]-r+2),s=tx/(e.aabb.max[1]-n+2);for(let a=0;ae.heightmap[u*tx+l]&&(e.heightmap[u*tx+l]=o);}}function Sx(e,t,r,n,i){r.reserve(r.length+4*e.length),n.reserve(n.length+10*e.length),i.reserve(i.length+10*e.length);let s=n.length;for(const a of e){const e=Math.min(10,Math.max(4,1.3*a.height))*t,o=[-a.normal[1],a.normal[0],0],l=Math.min(.29,.1*a.width/a.depth),u=a.width-2*a.depth*t*(l+.01),c=D([],a.pos,o,u/2),h=D([],a.pos,o,-u/2),d=[c[0],c[1],c[2]+a.height],p=[h[0],h[1],h[2]+a.height],f=D([],a.normal,o,l);F(f,f,e);const m=D([],a.normal,o,-l);F(m,m,e),P(f,c,f),P(m,h,m),c[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const y=u/e/2;i.emplaceBack(-y-l,-1,y,.8),i.emplaceBack(y+l,-1,y,.8),i.emplaceBack(-y,0,y,1.3),i.emplaceBack(y,0,y,1.3),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(0,0,y,1.3),i.emplaceBack(0,0,y,1.3),i.emplaceBack(y+l,-1.2,y,.8),i.emplaceBack(y+l,-1.2,y,.8),r.emplaceBack(6+s,4+s,8+s),r.emplaceBack(7+s,9+s,5+s),r.emplaceBack(0+s,1+s,2+s),r.emplaceBack(1+s,3+s,2+s),s+=10;}}function Bx(e,t){const r={};r.indexArray=new bu,r.vertexArray=new au,r.colorArray=new du,r.indexArray.reserveExact(4*e.length),r.vertexArray.reserveExact(10*e.length),r.colorArray.reserveExact(10*e.length),Sx(e,t,r.indexArray,r.vertexArray,r.colorArray);const n={defined:!0};n.emissiveFactor=Ar.black;const i={};return i.baseColorFactor=Ar.white,n.pbrMetallicRoughness=i,r.material=n,r.aabb=new If([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}ea(mx,"ModelBVH");const Tx=Wl([{name:"a_pos_3f",components:3,type:"Float32"}]),Px=Wl([{name:"a_normal_3",components:3,type:"Int16"}]),zx=Wl([{name:"a_centroid_3",components:3,type:"Int16"}]),Ex=Wl([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),kx=Wl([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Vx=Wl([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Fx=Wl([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Dx=Wl([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Cx=Wl([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Rx=Wl([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Lx=Wl([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Ox=Wl([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),Ux=Wl([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Nx=Wl([{name:"a_join_normal_inside",components:3,type:"Int16"}]),jx=Wl([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Gx=Wl([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:$x}=Rx;function qx(e,t,r,n){const i=[],s=0===n?(e,t,r,n,i,s)=>{e.push(new _e(s,r+(s-t)/(n-t)*(i-r)));}:(e,t,r,n,i,s)=>{e.push(new _e(t+(s-r)/(i-r)*(n-t),s));};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&s(a,o,l,u,c,t):h>r?d=t&&s(a,o,l,u,c,t),d>r&&h<=r&&s(a,o,l,u,c,r);}let o=i.at(-1);const l=0===n?o.x:o.y;l>=t&&l<=r&&a.push(o),a.length&&(o=a.at(-1),a[0].x===o.x&&a[0].y===o.y||a.push(a[0]),e.push(a));}e.length&&i.push(e);}return i}const Hx={None:0,Model:1,Symbol:2,FillExtrusion:4},Xx=[new _e(0,0),new _e(Xn,0),new _e(Xn,Xn),new _e(0,Xn)];function Zx(e,t){const r=[];let n=[];if(!t||e.length<2)return [e];if(2===e.length)return sh(e[0],e[1],Xx)?[e]:[];for(let t=0;t0&&(n.length>1&&r.push(n),n=[]);}return n.length>1&&r.push(n),r}const Wx=Nc.types,Yx=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],Kx=["fill-extrusion-flood-light-ground-radius"],Jx=Math.pow(2,13),Qx=Math.pow(2,15)-1,eb=new _e(0,1),tb=2147483648,rb=1073741824;function nb(e,t,r,n,i,s,a,o){e.emplaceBack((t<<1)+a,(r<<1)+s,(Math.floor(n*Jx)<<1)+i,Math.round(o));}function ib(e,t,r){e.emplaceBack(t.x*Xn,t.y*Xn,r?1:0);}function sb(e,t,r,n,i,s){e.emplaceBack(t.x,t.y,(r.x<<1)+n,(r.y<<1)+i,s);}function ab(e,t,r){const n=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*n,r[1]*n,r[2]*n);}class ob{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class lb{constructor(){this.data=[];}get length(){return this.data.length}push(e){this.data.push(e);}get(e){return this.data[e]}static serialize(e,t){const r=e.data.length,n=new Uint32Array(4*r),i=[];i.length=r;for(let t=0;te.max.x&&(e.max.x=t.x,n=!0),t.ye.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Xn)&&t.x===r.x)!=((0===t.y||t.y===Xn)&&t.y===r.y)&&this.processBorderOverlap(t,r),n&&this.checkBorderIntersection(t,r);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,wr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Xn!=e.x>Xn&&this.addBorderIntersection(1,wr(t.y,e.y,(Xn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,wr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Xn!=e.y>Xn&&this.addBorderIntersection(3,wr(t.x,e.x,(Xn-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){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 r=this.borders[e];tr[1]&&(r[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y);}else {const r=0===e.y?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x);}}centroid(){return 0===this.accCount?new _e(0,0):new _e(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function db(e,t){const r=e.add(t)._unit(),n=Ze(e.x*r.x+e.y*r.y,-1,1);var i,s,a;return a=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(a)))/4*Qx*((i=e).x*(s=t).y-i.y*s.x<0?-1:1)}const pb=[e=>e.x<0,e=>e.x>Xn,e=>e.y<0,e=>e.y>Xn];function fb(e,t,r,n){const i=[4];if(0===n)return i;r._mult(n);const s=e.sub(r),a=t.sub(r),o=[e,t,s,a];for(let e=0;e<4;e++)for(const t of o)if(pb[e](t)){i.push(e);break}return i}class mb{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new iu,this.indexArray=new bu,this.programConfigurations=new Ic(e.layers,{zoom:e.zoom,lut:e.lut},e=>Kx.includes(e)),this._segments=new Ku,this.hiddenByLandmarkVertexArray=new Vu,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Ku;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,r,n=!1){const i=e.length;if(i>2){let s=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let o;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const t=e[0],r=e[1];o=db(t.sub(e[i-1])._perp()._unit(),r.sub(t)._perp()._unit());}for(let l=0;le.region-t.region);for(let r=0;re+t,0);let s=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let r=this.regionSegments[e];r||(r=this.regionSegments[e]=new Ku);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:t};r.get().push(i);}s+=t;}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,jx.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class yb{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new cb,this.footprintIndices=new bu,this.footprintVertices=new Kl,this.footprintSegments=new lb,this.layoutVertexArray=new nu,this.centroidVertexArray=new $u,this.wallVertexArray=new Hu,this.indexArray=new bu,this.programConfigurations=new Ic(e.layers,{zoom:e.zoom,lut:e.lut},e=>Yx.includes(e)),this.segments=new Ku,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new mb(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.features=[],this.hasPattern=fl("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Fl(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:i,id:s,index:a,sourceLayerIndex:o}of e){const e=this.layers[0]._featureFilter.needGeometry,l=$l(i,e);if(!this.layers[0]._featureFilter.filter(new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,r))continue;const u={id:s,sourceLayerIndex:o,index:a,geometry:e?l.geometry:Gl(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===Wx[u.type];if(this.hasPattern)this.features.push({featureId:i.id,feature:ml("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of u.geometry)for(const s of Zx(e,h))this.addFeature(i.id,u,[s],a,r,{},t.availableImages,n,t.brightness);else this.addFeature(i.id,u,u.geometry,a,r,{},t.availableImages,n,t.brightness);t.featureIndex.insert(i,u.geometry,a,o,this.index,c);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(e,t,r,n,i,s){for(const{featureId:e,feature:a}of this.features){const o="Polygon"===Wx[a.type],{geometry:l}=a;if(this.wallMode)for(const u of l)for(const l of Zx(u,o))this.addFeature(e,a,[l],a.index,t,r,n,i,s);else this.addFeature(e,a,l,a.index,t,r,n,i,s);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview),this.groundEffect.update(e,t,i,r,n,s,a,this.worldview);}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,$x),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Nx.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Gx.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ux.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,r,n,i,s,a,o,l){const u=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new _e(0,0),new _e(Xn,Xn)],h=o.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===Wx[t.type],f=new hb;f.centroidDataIndex=this.centroidData.length;const m=new ub;m.buildingId=e,t.properties&&Object.hasOwn(t.properties,"building_id")&&(m.buildingId=Number(t.properties.building_id)),f.buildingId=m.buildingId;const y=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},i)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},i);let x;if(m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new uu),this.wallMode){if(d)return void lt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;x=function(e){const t=e[0].x===e.at(-1).x&&e[0].y===e.at(-1).y,r=function(e){let t=0;const r=e.length;for(let n=0;n=0}(e);r||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],s=[],a=[];let o=e.length;for(;o>=2&&e[o-1].equals(e[o-2]);)o--;if(o<(t?3:2))return n;let l,u,c,h,d,p=0;for(;p0;let g="miter";const x=2;"miter"===g&&m>x&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const o=new _e(e.x,e.y),l=new _e(e.x,e.y);o.x+=t.x*n,o.y+=t.y*n,l.x-=t.x*Math.max(r,1),l.y-=t.y*Math.max(r,1),a.push(t),i.push(o),s.push(l);};if("miter"===g)n._mult(m),b(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),b(l,n,0,0),b(l,n.mult(-1),0,0);else {const e=-Math.sqrt(m*m-1),t=y?e:0,r=y?0:e;u&&b(l,h,t,r),c&&b(l,d,t,r);}}n.geometry=[...i,...s.reverse(),i[0]],n.joinNormals=[...a,...a.reverse(),a.at(-1)];const f=n.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,v=this.wallMode?[r]:Pe(r,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||_b(t[0]))&&v.splice(e,1);}let w;if(d)w=Sb(v,c,i);else {w=[];for(const e of v)w.push({polygon:e,bounds:c});}const _=p?this.edgeRadius:0,A=_>0&&this.zoom<17,I=(e,t)=>{if(0===e.length)return !1;const r=e.at(-1);return t.x===r.x&&t.y===r.y};for(const{polygon:e,bounds:t}of w){let r=0,n=0;for(const t of e)p&&!t[0].equals(t.at(-1))&&t.push(t[0]),n+=p?t.length-1:t.length;const s=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new ob;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const n=[],a=[];r=s.vertexLength;for(let r=0;r4&&Ab(a[a.length-2],a[0],a[1]),l=_?xb(a[a.length-2],a[0],a[1],_):0;const c=[];let g,v,w;v=a[1].sub(a[0])._perp()._unit();let A=!0;for(let e=1,n=0;e0?1:0,P=u.dist(p);if(n+P>32768&&(n=0),_){w=M.sub(p)._perp()._unit();let e=bb(u,p,M,gb(v,w),_);isNaN(e)&&(e=0);const t=p.sub(u)._unit();u=u.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,v=w,y&&this.zoom>=17&&(I(c,u)||c.push(u),I(c,p)||c.push(p));}const z=s.vertexLength,E=a.length>4&&Ab(u,p,M);let k=Ib(n,o,A);if(nb(this.layoutVertexArray,u.x,u.y,B,T,0,0,k),nb(this.layoutVertexArray,u.x,u.y,B,T,0,1,k),this.wallMode){const t=b(e-1,a),r=x.joinNormals[e-1];ib(this.wallVertexArray,r,t),ib(this.wallVertexArray,r,t);}if(n+=P,k=Ib(n,E,!A),o=E,nb(this.layoutVertexArray,p.x,p.y,B,T,0,0,k),nb(this.layoutVertexArray,p.x,p.y,B,T,0,1,k),this.wallMode){const t=b(e,a),r=x.joinNormals[e];ib(this.wallVertexArray,r,t),ib(this.wallVertexArray,r,t);}if(s.vertexLength+=4,this.indexArray.emplaceBack(z+0,z+1,z+2),this.indexArray.emplaceBack(z+1,z+3,z+2),s.primitiveLength+=2,_){const n=r+(1===e?a.length-2:e-2),i=1===e?r:n+1;if(this.indexArray.emplaceBack(z+1,n,z+3),this.indexArray.emplaceBack(n,i,z+3),s.primitiveLength+=2,void 0===g&&(g=z),!vb(M,a[e],t)){const t=e===a.length-1?g:s.vertexLength;this.indexArray.emplaceBack(z+2,z+3,t),this.indexArray.emplaceBack(z+3,t+1,t),this.indexArray.emplaceBack(z+3,i,t+1),s.primitiveLength+=3;}A=!A;}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(u.x,u.y,i),r=h.projectTilePoint(p.x,p.y,i),n=h.upVector(i,u.x,u.y),s=h.upVector(i,p.x,p.y);ab(e,t,n),ab(e,t,n),ab(e,r,s),ab(e,r,s);}}p&&(r+=a.length-1),y&&_&&this.zoom>=17&&(0!==c.length&&I(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u,_>0));}this.footprintSegments.push(o),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++m.footprintSegLen,++m.polygonSegLen;}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?eb:this.encodeCentroid(f,m),t.properties&&Object.hasOwn(t.properties,"building_id")){const e=m.buildingId;let t=this.buildingGroups.get(e);t||(t={accX:0,accY:0,accCount:0,mergedMin:new _e(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new _e(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(e,t)),t.accX+=f.acc.x,t.accY+=f.acc.y,t.accCount+=f.accCount,t.mergedMin.x=Math.min(t.mergedMin.x,m.min.x),t.mergedMin.y=Math.min(t.mergedMin.y,m.min.y),t.mergedMax.x=Math.max(t.mergedMax.x,m.max.x),t.mergedMax.y=Math.max(t.mergedMax.y,m.max.y),t.partIndices.push(this.centroidData.length);}if(this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[r].borders[e][0]);}splitToSubtiles(){const e=[];for(let t=0;tXn),i=2*n+(+(r.min.x+r.max.x>Xn)^n);for(let n=0;ne.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let r=0,n=0,i=0;for(const t of e){if(t.triangleSegmentIdx!==r)break;i++;}const s=e.length;for(;n!==e.length;){r=e[n].triangleSegmentIdx;let a=0,o=n,l=n;for(let t=o;t0&&this.triangleSubSegments.push({segment:c,min:s,max:u}),o=l;for(let t=o;t[wr(e[0],t[0],r[0]),wr(e[1],t[1],r[1])],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Xn,d[1]=e.min.y/Xn,p[0]=e.max.x/Xn,p[1]=e.max.y/Xn;const t=h(u,c,d),a=h(u,c,p);if(0===new If([t[0],t[1],i],[a[0],a[1],s]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const o=e.segment;l&&l.vertexOffset!==o.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=o.vertexLength,l.primitiveLength+=o.primitiveLength):l={vertexOffset:o.vertexOffset,primitiveLength:o.primitiveLength,vertexLength:o.vertexLength,primitiveOffset:o.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(e,t){const r=e.centroid(),n=t.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(6,Math.round(n.y*this.tileToMeter/10));return new _e(Ze(r.x,1,8191)<<3|i,Ze(r.y,1,8191)<<3|s)}encodeBorderCentroid(e){if(!e.borders)return new _e(0,0);const t=e.borders,r=Number.MAX_VALUE;if(t[0][0]!==r||t[1][0]!==r){const e=t[0][0]!==r?0:1;return new _e(6|(t[0][0]!==r?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==r?2:3;return new _e((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==r?0:65528))}}showCentroid(e){const t=this.centroidData.get(e.centroidDataIndex);if(t.flags&=tb,0!==t.groupCentroidPos.x||0!==t.groupCentroidPos.y){const e=t.span(),r=Math.min(7,Math.round(e.x*this.tileToMeter/10)),n=Math.min(6,Math.round(e.y*this.tileToMeter/10));t.centroidXY=new _e(Ze(t.groupCentroidPos.x,1,8191)<<3|r,Ze(t.groupCentroidPos.y,1,8191)<<3|n);}else t.centroidXY=new _e(0,0);this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,n=-1073741824&e.flags?eb:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||i!==n.x){for(let e=t;ee.max.x||e.min.x>t.max.x||t.min.y>e.max.y||e.min.y>t.max.y||t.footprint.buildingIds.has(e.buildingId)&&(e.flags|=t.clipMask!==Hx.None?-1073741824:tb);else for(const r of this.centroidData)if(!(r.flags&tb||r.flags&rb||t.min.x>r.max.x||r.min.x>t.max.x||t.min.y>r.max.y||r.min.y>t.max.y))for(let s=0;st!=l>t&&e<(this.footprintVertices.int16[2*(o+s.vertexOffset)+0]-r)*(t-a)/(l-a)+r&&(n=!n);}a=r;}}return n}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(e+Xn)*Xn+(t+Xn);if(Object.hasOwn(this.partLookup,i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&tb)}:void 0}const s=this.centroidData.buffer,a=this.centroidData.length;for(let o=0;os[a+4]||s[a+2]>e||t>s[a+5]||s[a+3]>t)continue;const l=s[a+13];if(l<=r)continue;const u=this.centroidData.get(o);this.footprintContainsPoint(e,t,u)&&(r=l,this.partLookup[i]=u,n=!!(u.flags&tb));}if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function gb(e,t){const r=e.add(t)._unit();return e.x*r.x+e.y*r.y}function xb(e,t,r,n){const i=t.sub(e)._perp()._unit(),s=r.sub(t)._perp()._unit();return bb(e,t,r,gb(i,s),n)}function bb(e,t,r,n,i){const s=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(r)/3,i*s/n)}function vb(e,t,r){return e.xr[1].x&&t.x>r[1].x||e.yr[1].y&&t.y>r[1].y}function wb(e,t){return e.xt[1].x||e.yt[1].y}function _b(e){return e.every(e=>e.x<=0)||e.every(e=>e.x>=Xn)||e.every(e=>e.y<=0)||e.every(e=>e.y>=Xn)}function Ab(e,t,r){if(e.x<0||e.x>=Xn||t.x<0||t.x>=Xn||r.x<0||r.x>=Xn)return !1;const n=r.sub(t),i=n.perp(),s=e.sub(t);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function Ib(e,t,r){const n=t?2|e:-3&e;return r?1|n:-2&n}function Mb(){const e=Math.PI/32,t=Math.tan(e),r=Al;return r*Math.sqrt(1+2*t*t)-r}function Sb(e,t,r){const n=1<{for(const r of e)a.push({polygon:r,bounds:t});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):o(d,e);}if(f.length){const e=[new _e(0===r?c:n.x,1===r?c:n.y),a];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):o(f,e);}}return a}(e,t,Math.ceil((s-i)/11.25),Math.ceil((a-o)/11.25),1,(e,t,i)=>{if(0===e)return .5*(t+i);{const e=Mn((r.y+t/Xn)/n);return (An(.5*(Mn((r.y+i/Xn)/n)+e))*n-r.y)*Xn}})}function Bb(e,t,r,n,i,s){const a=Math.pow(2,n.z-i.z);for(let o=0;oTb?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Tb?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;0!==this.module.heapU8[e];)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters);}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t);}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t);}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0);}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0);}setFauxFacadeOptions(e,t,r){this.module.setFauxFacadeOptions(e?1:0,t?1:0,r);}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e);}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),r=this.createFloatArray(t.coordinates);if(-1===e||-1===r)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(t.id,t.sourceId,t.minHeight,t.height,t.roofType,r,e,t.ringIndices.length-1);}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const r=this.createFloatArray(t),n=this.createFloatArray(e.coordinates);if(-1===r||-1===n)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,r,t.length,n,e.coordinates.length);}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const r=this.module.getMeshCount(),n=new Array(r);for(let e=0;er||e.y<-t||e.y>r)return !1;return !0}function Vb(e){switch(e){case "flat":return 3;case "hipped":return 1;case "gabled":return 2;case "parapet":return 0;case "mansard":return 4;case "skillion":return 5;case "pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${e}`)}}let Fb,Db,Cb=null,Rb=null,Lb=null;class Ob{constructor(){this.layoutVertexArray=new au,this.layoutAttenuationArray=new du,this.layoutColorArray=new fu,this.indexArray=new bu,this.indexArrayForConflation=new bu,this.segmentsBucket=new Ku;}}class Ub{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Ku,this.entranceBloom=new Ob;const t=66560;this.layoutVertexArray=new au,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Jl,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Jl,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new fu,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new ku,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new Vu,this.layoutAOArray.reserve(t),this.indexArray=new bu,this.indexArray.reserve(66560),this.indexArrayForConflation=new bu,this.segmentsBucket=new Ku,this.entranceBloom=new Ob,e&&(this.layoutFacadePaintArray=new fu,this.layoutFacadeDataArray=new lu,this.layoutFacadeVerticalRangeArray=new fu);}reserve(e,t,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e));}}class Nb{constructor(e){this.requiresHDRuntime=!0,this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Bu,this.footprintsIndices=new Pu,this.footprintsMin=new _e(1/0,1/0),this.footprintsMax=new _e(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Ub(!1),this.buildingWithFacade=new Ub(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new Ic(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new mb(e),this.groundEffect.groundRadiusArray=new eu,this.hasAppearances=null;}updateFootprints(e,t){const r=new Dg([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:n,id:e});}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){if(!Lb)return;const i=Fl(r);this.tileToMeter=i,this.brightness=t.brightness,Lb.setStyle({normalScale:[1,-1,i],tileToMeters:i}),Lb.setAOOptions(!1,.3),Lb.setMetricOptions(!1,16),Lb.setStructuralOptions(!0),Lb.setFacadeClassifierOptions(3);const s=new Map,a=new Map;let o=0;for(const{feature:t}of e){if("LineString"!==zb[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Qa(this.zoom),t,r))continue;const i=$l(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new Qa(this.zoom),i,r))continue;const l=e?i.geometry:Gl(t,r,n),u=[];for(const e of l)for(const t of e)u.push(t.x),u.push(t.y);const c={coordinates:u,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let d=a.get(h);d||(d=[],a.set(h,d)),d.push(c),++o;}this.maxHeight=0;const l=new Array,u=new Set,c=e=>{null!=e&&u.add(e);},h=(e,t)=>{null!=e&&l.push({buildingId:e,footprintIndex:t});},d=64*(e.length-o),p=d/2;this.buildingWithFacade.reserve(d,p,!0),this.buildingWithoutFacade.reserve(2*d,2*p,!1),this.footprintsIndices.reserve(16*(e.length-o)),this.footprintsVertices.reserve(8*(e.length-o));for(const{feature:o,id:l,index:d,sourceLayerIndex:p}of e){if("LineString"===zb[o.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Qa(this.zoom),o,r))continue;let f=null;if(o.properties&&Object.hasOwn(o.properties,"building_id")&&(f=Number(o.properties.building_id),u.has(f)))continue;const m=$l(o,e);if(!e&&!this.layers[0]._featureFilter.filter(new Qa(this.zoom),m,r))continue;const y=e?m.geometry:Gl(o,r,n),g=Pe(y,500);let x=!1;for(const e of g)if(1!==e.length){x=!0;break}if(x){c(f);continue}if(!kb(y,163)){c(f);continue}const b=this.layers[0],v=Vb(b.layout.get("building-roof-shape").evaluate(o,{},r)),w=b.layout.get("building-base").evaluate(o,{},r),_=b.layout.get("building-height").evaluate(o,{},r),A=b.layout.get("building-flood-light-ground-radius").evaluate(o,{},r),I=b.paint.get("building-ambient-occlusion-intensity"),M=A/this.tileToMeter;o.properties["building-part"]="roof";const S=b.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),B=b.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);o.properties["building-part"]="wall";const T=b.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),P=b.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);o.properties["building-part"]="window";const z=b.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),E=b.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);o.properties["building-part"]="door";const k=b.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),V=b.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);let F=b.layout.get("building-flood-light-wall-radius").evaluate(o,{},r);F=Ze(F,0,2048);const D=F/2048*Eb,C=s.get(l),R=a.get(C)||[],L=0!==R.length&&b.layout.get("building-facade").evaluate(o,{},r);Lb.setFacadeOptions(4,!0),Lb.setFauxFacadeOptions(L,!1,1);let O=0,U=0,N=0,j=0,G=0,$=0,q=0,H=0,X=0,Z=0,W=0;if(L){let e=Math.round(b.layout.get("building-facade-floors").evaluate(o,{},r));if(0===w){e=Math.max(1,e-(R.length>0?1:0));let t=4;if(_>100){const e=[10,13,15];t=e[o.id?o.id%e.length:0];}else _<=10&&(t=3);Lb.setFacadeOptions(t,!0),G=(_<15?1.3:1.61803)*t/i;}else G=w/i;$=_/i,G=Math.min(G,$),N=b.layout.get("building-facade-unit-width").evaluate(o,{},r)/i,j=($-G)/e,Lb.setFauxFacadeOptions(!0,!0,N);const t=b.layout.get("building-facade-window").evaluate(o,{},r);O=t[0],U=t[1],q=Math.floor(65535*Math.min(1,G/Xn)),H=Math.floor(65535*Math.min(1,$/Xn)),X=Math.floor(255*O)<<8|Math.floor(255*U),Z=Math.floor(65535*Math.min(1,N/Xn)),W=Math.floor(65535*Math.min(1,j/Xn));}const Y=Array(g.length),K={x:1/0,y:1/0},J={x:-1/0,y:-1/0},Q={x:0,y:0};let ee=0;for(let e=0;e0){const r=[],n=Array(t.length+1);n[0]=0;for(let e=0;eXn||K.y<0||J.y>Xn)&&this.featuresOnBorder.push({featureId:o.id,footprintIndex:this.footprints.length});{const e=No(ge,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,me),this.buildingIds.add(null!=f?f:o.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,xe.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,xe.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,be.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,be.y);const t={footprintVertexOffset:ye,footprintVertexLength:this.footprintsVertices.length-ye,footprintIndexOffset:me,footprintIndexLength:this.footprintsIndices.length-me,min:xe,max:be,hiddenFlags:0,indicesOffset:he,indicesLength:fe,bloomIndicesOffset:oe,bloomIndicesLength:le,groundEffectVertexOffset:ve,groundEffectVertexLength:we,hasFauxFacade:L,height:de,promoteId:l,feature:m,parts:se,buildingBloom:ae},r=this.footprints.length;void 0!==o.id&&this.featureFootprintLookup.set(o.id,r),h(f,r),this.footprints.push(t);}this.programConfigurations.populatePaintArrays(re.layoutVertexArray.length,o,d,{},t.availableImages,r,t.brightness),this.groundEffect.addPaintPropertiesData(o,d,{},t.availableImages,r,t.brightness),t.featureIndex.insert(o,y,d,p,this.index,ue);}l.forEach(({buildingId:e,footprintIndex:t})=>{u.has(e)&&(this.footprints[t].hiddenFlags|=4);});const f=new Set;this.buildingIds.forEach((e,t,r)=>{u.has(e)||f.add(e);}),this.buildingIds=f,this.groundEffect.prepareBorderSegments();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a),this.groundEffect.update(e,t,i,r,n,s,a),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1;}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,Tx.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,Px.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,zx.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,Cx.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,Vx.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,Fx.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,Tx.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,Dx.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e);};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()));};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy();}updateFootprintHiddenFlags(e,t,r=!0){let n=!1;const i=r?t:0,s=0|(r?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],r=e.hiddenFlags&s|i;e.hiddenFlags!==r&&(e.hiddenFlags=r,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags));}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16));};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0));};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0;}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,Ex.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,kx.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Ex.members,!0);};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0;}evaluate(e,t){const r=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const i=t[n.promoteId],s=n.feature;s.properties["building-part"]="roof";const a=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),o=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),u=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="window";const c=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,i=a;1===e.part?(i=a,t=o):0===e.part?(i=l,t=u):2===e.part?(i=c,t=h):3===e.part&&(i=d,t=p),t=Ze(t,0,1);for(let s=0;st.max.x||r.max.xt.max.y||r.max.ya.max.x||a.min.x>e||t>a.max.y||a.min.y>t||a.height<=r||jb(s,this.footprintsVertices.float32.subarray(2*a.footprintVertexOffset,2*(a.footprintVertexOffset+a.footprintVertexLength)),this.footprintsIndices.uint16.subarray(a.footprintIndexOffset,a.footprintIndexOffset+a.footprintIndexLength))&&(r=a.height,this.footprintLookup[i]=a,n=0!==a.hiddenFlags);if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.footprintLookup[i]=void 0;}}function jb(e,t,r){for(let n=0;n0&&this.rings[0].length>0}}async function qb(){}function Hb(e,t,r){const n=t.paint.get(e).value;return "constant"===n.kind?n.value:r.programConfigurations.get(t.id).getMaxValue(e)}function Xb(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Zb(e,t,r,n,i){if(!t[0]&&!t[1])return e;const s=_e.convert(t)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let t=0;t{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Jb(e,t,r,n,i,s,a,o,l){if(s&&e.queryGeometry.isAboveHorizon)return !1;s&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(o),d=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,p=r.projection.projectTilePoint(h.x,h.y,u);if(d>0){const e=r.projection.upVector(u,h.x,h.y);p.x+=e[0]*c*d,p.y+=e[1]*c*d,p.z+=e[2]*c*d;}const f=s?h:Qb(p.x,p.y,p.z,n),m=s?e.tilespaceRays.map(e=>rv(e,d)):e.queryGeometry.screenGeometry,y=te([],[p.x,p.y,p.z,1],n);if(!a&&s?l*=y[3]/r.cameraToCenterDistance:a&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const e=Mn((t.y/Xn+u.y)/(1<{t[e.evaluationKey]=a;const o=e.expression.evaluate(t),l=o?o.toNonPremultipliedRenderColor(s):null;l&&(i.data[r+n+0]=Math.floor(255*l.r),i.data[r+n+1]=Math.floor(255*l.g),i.data[r+n+2]=Math.floor(255*l.b),i.data[r+n+3]=Math.floor(255*l.a));};if(e.clips)for(let t=0,i=0;te.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.footprints)t.push({footprint:r,id:e});}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){const i=[];for(const{feature:s,id:a,index:o,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=$l(s,e);if(!this.layers[0]._featureFilter.filter(new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,r))continue;const c={id:a,properties:s.properties,type:s.type,sourceLayerIndex:l,index:o,geometry:e?u.geometry:Gl(s,r,n),patterns:{}};i.push(c);}for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n;this.addFeature(n,i,s,r,{},t.availableImages,t.brightness),t.featureIndex.insert(e[s].feature,i,s,a,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(e){}update(e,t,r,n,i,s,a){}destroy(){}addFeature(e,t,r,n,i,s=[],a){for(const e of Pe(t,2)){const t=[],r=[],n=[],i=new _e(1/0,1/0),s=new _e(-1/0,-1/0);for(const a of e)if(0!==a.length){a!==e[0]&&n.push(r.length/2);for(let e=0;e{e[0]=t,e[1]=r,e[2]=n,e[3]=1;},g=Mb();r>0&&(r+=g),n+=g;for(const g of t){const t=[],x=[];for(const h of g){const d=h.x+i.x,g=h.y+i.y,b=e.projection.projectTilePoint(d,g,c),v=e.projection.upVector(c,h.x,h.y);let w=r,_=n;if(a){const e=Iv(d,g,r,n,a,o,l,u);w+=e.base,_+=e.top;}0!==r?y(f,b.x+v[0]*p*w,b.y+v[1]*p*w,b.z+v[2]*p*w):y(f,b.x,b.y,b.z),y(m,b.x+v[0]*p*_,b.y+v[1]*p*_,b.z+v[2]*p*_),$(f,f,s),$(m,m,s),t.push(new lh(f[0],f[1],f[2])),x.push(new lh(m[0],m[1],m[2]));}h.push(t),d.push(x);}return [h,d]}(e,t,r,n,i,s,a,o,l,u,c):a?function(e,t,r,n,i,s,a,o,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const u of d){const c=u.x+n.x,d=u.y+n.y,f=Iv(c,d,t,r,s,a,o,l);h[0]=c,h[1]=d,h[2]=f.base,h[3]=1,te(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new lh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=f.top,h[3]=1,te(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new lh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(y);}u.push(e),c.push(p);}return [u,c]}(t,r,n,i,s,a,o,l,u):function(e,t,r,n,i){const s=[],a=[],o=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*r,d=i[9]*r,p=i[10]*r,f=i[11]*r;for(const t of e){const e=[],r=[];for(const s of t){const t=s.x+n.x,a=s.y+n.y,m=i[0]*t+i[4]*a+i[12],y=i[1]*t+i[5]*a+i[13],g=i[2]*t+i[6]*a+i[14],x=i[3]*t+i[7]*a+i[15],b=m+o,v=y+l,w=g+u,_=Math.max(x+c,1e-5),A=m+h,I=y+d,M=g+p,S=Math.max(x+f,1e-5);e.push(new lh(b/_,v/_,w/_)),r.push(new lh(A/S,I/S,M/S));}s.push(e),a.push(r);}return [s,a]}(t,r,n,i,s)}function Iv(e,t,r,n,i,s,a,o){const l=a*i.getElevationAt(e,t,!0,!0),u=0!==s[0],c=u?0===s[1]?a*(s[0]/7-450):a*function(e,t,r){const n=Math.floor(t[0]/8),i=Math.floor(t[1]/8),s=10*(t[0]-8*n),a=10*(t[1]-8*i),o=e.getElevationAt(n,i,!0,!0),l=e.getMeterToDEM(r),u=Math.floor(.5*(s*l-1)),c=Math.floor(.5*(a*l-1)),h=e.tileCoordToPixel(n,i),d=2*u+1,p=2*c+1,f=function(e,t,r,n,i){return [e.getElevationAtPixel(t,r,!0),e.getElevationAtPixel(t+i,r,!0),e.getElevationAtPixel(t,r+i,!0),e.getElevationAtPixel(t+n,r+i,!0)]}(e,h.x-u,h.y-c,d,p),m=Math.abs(f[0]-f[1]),y=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),x=Math.min(.25,.5*l*(m+y)/d),b=Math.min(.25,.5*l*g/p);return o+Math.max(x*s,b*a)}(i,s,o):l;return {base:l+(0===r?-1:r),top:u?Math.max(c+n,l+r+2):l+n}}function Mv(e,t,r){return t*(Xn/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}function Sv(e,t){return 1/Mv(e,1,t.tileZoom)}function Bv(e,t,r,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}ea(bv,"ClipBucket",{omit:["layers"]});const Tv=e=>{const t=[];Pv(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT"),"multiply"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_MULTIPLY"),"additive"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_ADDITIVE");const r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const n="none"===e.layout.get("line-join").constantOr("miter"),i=!!e.paint.get("line-pattern").constantOr(1);return n&&i&&t.push("LINE_JOIN_NONE"),t};function Pv(e){const t=e.paint.get("line-dasharray").value;return "constant"!==t.kind||t.value}let zv;const Ev=()=>zv||(zv={layout:yv||(yv=new ho({"line-cap":new uo(po.layout_line["line-cap"]),"line-join":new uo(po.layout_line["line-join"]),"line-miter-limit":new lo(po.layout_line["line-miter-limit"]),"line-round-limit":new lo(po.layout_line["line-round-limit"]),"line-sort-key":new uo(po.layout_line["line-sort-key"]),"line-z-offset":new uo(po.layout_line["line-z-offset"]),"line-elevation-reference":new lo(po.layout_line["line-elevation-reference"]),"line-cross-slope":new lo(po.layout_line["line-cross-slope"]),visibility:new lo(po.layout_line.visibility),"line-width-unit":new lo(po.layout_line["line-width-unit"]),"line-elevation-ground-scale":new uo(po.layout_line["line-elevation-ground-scale"])})),paint:gv||(gv=new ho({"line-opacity":new uo(po.paint_line["line-opacity"]),"line-color":new uo(po.paint_line["line-color"]),"line-translate":new lo(po.paint_line["line-translate"]),"line-translate-anchor":new lo(po.paint_line["line-translate-anchor"]),"line-width":new uo(po.paint_line["line-width"]),"line-gap-width":new uo(po.paint_line["line-gap-width"]),"line-offset":new uo(po.paint_line["line-offset"]),"line-blur":new uo(po.paint_line["line-blur"]),"line-dasharray":new uo(po.paint_line["line-dasharray"]),"line-pattern":new uo(po.paint_line["line-pattern"]),"line-pattern-cross-fade":new lo(po.paint_line["line-pattern-cross-fade"]),"line-gradient":new co(po.paint_line["line-gradient"]),"line-trim-offset":new lo(po.paint_line["line-trim-offset"]),"line-trim-fade-range":new lo(po.paint_line["line-trim-fade-range"]),"line-trim-color":new lo(po.paint_line["line-trim-color"]),"line-emissive-strength":new uo(po.paint_line["line-emissive-strength"]),"line-border-width":new uo(po.paint_line["line-border-width"]),"line-border-color":new uo(po.paint_line["line-border-color"]),"line-occlusion-opacity":new lo(po.paint_line["line-occlusion-opacity"]),"line-blend-mode":new lo(po.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new lo(po.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},zv);class kv extends uo{possiblyEvaluate(e,t){return t=new Qa(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,n){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,n)}}let Vv,Fv,Dv,Cv;function Rv(e,t){return t>0?t+2*e:e}function Lv(e,t){return t.replace(/{([^{}]+)}/g,(t,r)=>r in e?String(e[r]):"")}class Ov{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Er,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}ea(Ov,"FormatSectionOverride",{omit:["defaultValue"]});const Uv=()=>Cv||(Cv={layout:Fv||(Fv=new ho({"symbol-placement":new lo(po.layout_symbol["symbol-placement"]),"symbol-spacing":new lo(po.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new lo(po.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new uo(po.layout_symbol["symbol-sort-key"]),"symbol-z-order":new lo(po.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new lo(po.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new lo(po.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new lo(po.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new lo(po.layout_symbol["icon-ignore-placement"]),"icon-optional":new lo(po.layout_symbol["icon-optional"]),"icon-rotation-alignment":new lo(po.layout_symbol["icon-rotation-alignment"]),"icon-size":new uo(po.layout_symbol["icon-size"]),"icon-size-scale-range":new lo(po.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new uo(po.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new uo(po.layout_symbol["icon-text-fit-padding"]),"icon-image":new uo(po.layout_symbol["icon-image"]),"icon-image-use-theme":new lo({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new uo(po.layout_symbol["icon-rotate"]),"icon-padding":new lo(po.layout_symbol["icon-padding"]),"icon-keep-upright":new lo(po.layout_symbol["icon-keep-upright"]),"icon-offset":new uo(po.layout_symbol["icon-offset"]),"icon-anchor":new uo(po.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new lo(po.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new lo(po.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new lo(po.layout_symbol["text-rotation-alignment"]),"text-field":new uo(po.layout_symbol["text-field"]),"text-font":new uo(po.layout_symbol["text-font"]),"text-size":new uo(po.layout_symbol["text-size"]),"text-size-scale-range":new lo(po.layout_symbol["text-size-scale-range"]),"text-max-width":new uo(po.layout_symbol["text-max-width"]),"text-line-height":new uo(po.layout_symbol["text-line-height"]),"text-letter-spacing":new uo(po.layout_symbol["text-letter-spacing"]),"text-justify":new uo(po.layout_symbol["text-justify"]),"text-radial-offset":new uo(po.layout_symbol["text-radial-offset"]),"text-variable-anchor":new lo(po.layout_symbol["text-variable-anchor"]),"text-anchor":new uo(po.layout_symbol["text-anchor"]),"text-max-angle":new lo(po.layout_symbol["text-max-angle"]),"text-writing-mode":new lo(po.layout_symbol["text-writing-mode"]),"text-rotate":new uo(po.layout_symbol["text-rotate"]),"text-padding":new lo(po.layout_symbol["text-padding"]),"text-keep-upright":new lo(po.layout_symbol["text-keep-upright"]),"text-transform":new uo(po.layout_symbol["text-transform"]),"text-offset":new uo(po.layout_symbol["text-offset"]),"text-allow-overlap":new lo(po.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new lo(po.layout_symbol["text-ignore-placement"]),"text-optional":new lo(po.layout_symbol["text-optional"]),visibility:new lo(po.layout_symbol.visibility)})),paint:Dv||(Dv=new ho({"icon-opacity":new uo(po.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new uo(po.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new uo(po.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new uo(po.paint_symbol["text-emissive-strength"]),"icon-color":new uo(po.paint_symbol["icon-color"]),"icon-halo-color":new uo(po.paint_symbol["icon-halo-color"]),"icon-halo-width":new uo(po.paint_symbol["icon-halo-width"]),"icon-halo-blur":new uo(po.paint_symbol["icon-halo-blur"]),"icon-translate":new lo(po.paint_symbol["icon-translate"]),"icon-translate-anchor":new lo(po.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new lo(po.paint_symbol["icon-image-cross-fade"]),"text-opacity":new uo(po.paint_symbol["text-opacity"]),"text-occlusion-opacity":new uo(po.paint_symbol["text-occlusion-opacity"]),"text-color":new uo(po.paint_symbol["text-color"],{runtimeType:Dr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new uo(po.paint_symbol["text-halo-color"]),"text-halo-width":new uo(po.paint_symbol["text-halo-width"]),"text-halo-blur":new uo(po.paint_symbol["text-halo-blur"]),"text-translate":new lo(po.paint_symbol["text-translate"]),"text-translate-anchor":new lo(po.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new lo(po.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new lo(po.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new lo(po.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new lo(po.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new uo(po.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},Cv);class Nv extends Oo{constructor(e,t,r,n){super(e,Uv(),t,r,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=c([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint);}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0);}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(r=>{r.recalculate(e,t,this.iconImageUseTheme);}),"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 r=this.layout.get("text-writing-mode");if(r){const e=[];for(const t of r)e.includes(t)||e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,t,r,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,r,n){e=Mt(e),t=It(t);const i=l(),s=e/3,a=1-2*s,o=[a,s,s,0,s,a,s,0,s,s,a,0,0,0,0,1],u=.5-.5*t,c=n-r;return d(i,[c,0,0,0,0,c,0,0,0,0,c,0,r,r,r,1],[t,0,0,0,0,t,0,0,0,0,t,0,u,u,u,1]),d(i,i,o),i}(e,t,r,n),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,r,n){const i=this.layout.get(e).evaluate(t,{},r,n),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||qs(s.value)||!i?i:Lv(t.properties,i)}getAppearanceValueAndResolveTokens(e,t,r,n,i){const s=e.getLayoutProperty(t);if(!s)return;const a=s.evaluate(r,{},n,i),o=e.getUnevaluatedLayoutProperties()._values[t];return o.isDataDriven()||qs(o.value)||!a||"string"!=typeof a?a:Lv(r.properties,a)}createBucket(e){return new Ym(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of Uv().paint.overridableProperties){if(!Nv.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new Ov(t),n=new $s(r,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Xs("source",n):new Zs("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new ao(t.property,i,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,r){return !(!this.layout||t.isDataDriven()||r.isDataDriven())&&Nv.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),n=Uv().paint.properties[t];let i=!1;const s=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Yr)s(r.value.value.sections);else if("source"===r.value.kind){const e=t=>{i||(t instanceof nn&&tn(t.value)===Or?s(t.value.sections):t instanceof ln?s(t.sections):t.eachChild(e));},t=r.value;t._styleExpression&&e(t._styleExpression.expression);}return i}getProgramIds(){return ["symbol"]}getDefaultProgramParams(e,t,r){return {config:new Ac(this,{zoom:t,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}mayUse(e){return "HD"===e&&Uo(this,"symbol-elevation-reference",e=>"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?qb():Promise.resolve()}}let jv,Gv,$v,qv;var Hv=Wl([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function Xv(e,t,r,n,i,s,l,u){const c=[e,t,1,r,n,1,i,s,1],h=[l,u,1],d=a([],c),[p,f,m]=q(h,h,d);return o(c,c,[p,0,0,0,f,0,0,0,m])}function Zv(e,t,r,n,i,s,l,u){const c=function(e,t,r,n,i,s,l,u){const c=Xv(0,0,1,0,1,1,0,1),h=Xv(e,t,r,n,i,s,l,u);return o(h,h,a([],c))}(e,t,r,n,i,s,l,u);return [c[2]/c[8]/Xn,c[5]/c[8]/Xn]}function Wv(e){return [e[0],Math.min(Math.max(e[1],-85.051129),zl)]}class Yv extends yr{constructor(e,t,r,n){super(),this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=t,this._dirty=!1;}load(e,t){if(this._loaded=t||!1,this.fire(new dr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=cr(this.map._requestManager.transformRequest(this.url,Jt.Image),(t,r)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new pr(t)):r&&(this.image=r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading());});}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new ap(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new dr("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof ap||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],r=e[0][1];for(const n of e)n[1]>r&&(r=n[1]),n[1]zl?this.onNorthPole=!0:n<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(Dl.fromLngLat);this.tileID=function(e){let t=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of e)t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);const s=Math.max(n-t,i-r),a=Math.max(0,Math.floor(-Math.log2(s))),o=Math.pow(2,a);let l=Math.floor((t+n)/2*o);return l>1&&(l-=1),new Jf(a,l,Math.floor((r+i)/2*o))}(t),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new dr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof ap||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=nm(new Jf(0,0,0),this.map.transform.projection),r=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,r=e[1].y-e[0].y,n=e[2].x-e[1].x,i=e[2].y-e[1].y,s=e[3].x-e[2].x,a=e[3].y-e[2].y,o=e[0].x-e[3].x,l=e[0].y-e[3].y,u=t*i-n*r,c=n*a-s*i,h=s*l-o*a,d=o*r-t*l;return u>0&&c>0&&h>0&&d>0||u<0&&c<0&&h<0&&d<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=nm(this.tileID,this.map.transform.projection),[i,s,l,u]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return im(n,t)._round()});this.perspectiveTransform=Zv(i.x,i.y,s.x,s.y,l.x,l.y,u.x,u.y);const c=this._boundsArray=new Ql;c.emplaceBack(i.x,i.y,0,0),c.emplaceBack(s.x,s.y,Xn,0),c.emplaceBack(u.x,u.y,0,Xn),c.emplaceBack(l.x,l.y,Xn,Xn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,Hv.members),this.boundsSegments=Ku.simpleSegment(0,0,4,2);const h=[],d=function(e){return [Wv(e[0]),Wv(e[1]),Wv(e[2]),Wv(e[3])]}(this.coordinates),[p,f,m,y]=function(e){let t=e[0][0],r=t,n=e[0][1],i=n;for(let s=1;sr&&(r=e[s][0]),e[s][1]i&&(i=e[s][1]);return [t,n,r-t,i-n]}(d);{const n=new Ql,[i,s,l,u]=function(e){let t=e[0].x,r=t,n=e[0].y,i=n;for(let s=1;sr&&(r=e[s].x),e[s].yi&&(i=e[s].y);return [t,n,r-t,i-n]}(r),c=e=>[(e.x-i)/l,(e.y-s)/u],[d,g,x,b]=r.map(c),v=function(e,t,r,n,i,s,l,u){const c=Xv(0,0,1,0,1,1,0,1);return o(c,c,a([],Xv(e,t,r,n,i,s,l,u)))}(d[0],d[1],g[0],g[1],x[0],x[1],b[0],b[1]);this.elevatedGlobePerspectiveTransform=Zv(d[0],d[1],g[0],g[1],x[0],x[1],b[0],b[1]);const w=(e,t)=>{h.push(e.lng);const r=Math.round((e.lng-p)/m*Xn),i=Math.round((e.lat-f)/y*Xn),s=c(t),a=q([],[s[0],s[1],1],v),o=Math.round(a[0]/a[2]*Xn),l=Math.round(a[1]/a[2]*Xn);n.emplaceBack(r,i,o,l);},_=r[3].x-r[0].x,A=r[3].y-r[0].y,I=r[2].x-r[1].x,M=r[2].y-r[1].y;for(let e=0;e<65;e++){const n=e/64,i=[r[0].x+n*_,r[0].y+n*A],s=[r[1].x+n*I,r[1].y+n*M],a=s[0]-i[0],o=s[1]-i[1];for(let e=0;e<65;e++){const r=e/64,n={x:i[0]+a*r,y:i[1]+o*r};w(t.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,Hv.members);}{this.maxLongitudeTriangleSize=0;let t=[],r=new bu;const n=(e,n,i)=>{r.emplaceBack(e,n,i);const s=h[e],a=h[n],o=h[i],l=Math.min(Math.min(s,a),o),u=Math.max(Math.max(s,a),o)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),t.push(l+u/2);};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const r=65*e+t,i=r+1,s=r+65,a=s+1;n(r,s,i),n(i,s,a);}[t,r]=function(e,t){const r=Array.from({length:e.length},(e,t)=>t);r.sort((t,r)=>e[t]-e[r]);const n=[],i=new bu;for(let s=0;s{s.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},o=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=o){const e=At(r,0,r.length,n+o);return e===r.length||a(e,_t(r,e+1,r.length,n+360-o)-e),s}n0}}let ew,tw,rw,nw,iw,sw,aw;class ow extends Oo{constructor(e,t,r,n){super(e,{layout:ew||(ew=new ho({visibility:new lo(po["layout_raster-particle"].visibility)})),paint:tw||(tw=new ho({"raster-particle-array-band":new lo(po["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new lo(po["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new co(po["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new lo(po["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new lo(po["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new lo(po["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new lo(po["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new lo(po["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp(),this.lastInvalidatedAt=Tt.now();}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null);}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy();}hasColorMap(){return !!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return ["rasterParticle"]}hasOffscreenPass(){return "none"!==this.visibility}isDraped(e){return !1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=xv({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=Tt.now();}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class lw extends Oo{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(e){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}function uw(e,t,r){const n=[0,0,1],i=ne([]);return se(i,i,r?-Ge(e)+Math.PI:Ge(e)),ie(i,i,-Ge(t)),H(n,n,i),U(n,n)}class cw{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class hw{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new zu,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}colorForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=Math.floor(r[t+2]);const i=1.05*(r[t+2]-n);return n/=100,[r[t]%1*1.05,r[t+1]%1*1.05,i,n]}tileCoordinatesForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=r[t+0];return n=n>Xn?n-Xn:n,new _e(Math.trunc(n),Math.trunc(r[t+1]))}translationForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+4],r[t+5],r[t+6]]}rotationScaleForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+10],r[t+11],r[t+12],r[t+13],r[t+14],r[t+15]]}transformForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+4],r[t+10],r[t+11],r[t+12],r[t+5],r[t+13],r[t+14],r[t+15],r[t+6],0,0,0,1]}}class dw{constructor(e){this.requiresStandardRuntime=!0,this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.tileToMeter=Fl(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const s="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?t.elevationFeatures:void 0;for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of e){const e=null!=o?o:a.properties&&Object.hasOwn(a.properties,"id")?a.properties.id:void 0,c=$l(a,i);if(!this.layers[0]._featureFilter.filter(new Qa(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h={id:e,sourceLayerIndex:u,index:l,geometry:i?c.geometry:Gl(a,r,n),properties:a.properties,type:a.type,patterns:{}},d=this.addFeature(h,h.geometry,c,s,r);d&&t.featureIndex.insert(a,h.geometry,l,u,this.index,this.instancesPerModel[d].instancedDataArray.length,256);}this.lookup=null;}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let r=0;for(const n of this.modelUris){const i=e.getModel(n,t);if(!i)continue;const s=this.instancesPerModel[n];if(s){const e=.5*C(i.aabb.max,i.aabb.min)*s.maxScale+s.maxXYTranslationDistance,t=Math.min(Xn,Math.max(e/this.tileToMeter,256));r=Math.max(t,r);}}return r}update(e,t,r,n){for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t in e)Object.hasOwn(r.idToFeaturesIndex,t)&&(this.evaluate(r.features[r.idToFeaturesIndex[t]],e[t],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t of r.features){const n=this.layers[0],i=t.feature,s=this.canonical,a=n.paint.get("model-rotation").evaluate(i,{},s),o=n.paint.get("model-scale").evaluate(i,{},s),l=n.paint.get("model-translation").evaluate(i,{},s);Z(t.rotation,a)&&Z(t.scale,o)&&Z(t.translation,l)||(this.evaluate(t,t.featureStates,r,!0),e=!0);}}return e}updateReplacement(e,t,r,n){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(km(this.activeReplacements,i))return !1;this.activeReplacements=i;let s=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t],a=i.instancedDataArray;for(const t of i.features){const i=t.instancedDataOffset,o=t.instancedDataCount;for(let t=0;tXn;l=u?l-Xn:l;const c=Math.floor(l),h=Math.floor(a.float32[o+1]);let d=!1;for(const t of this.activeReplacements)if(!Tm(t,r,Hx.Model,n)&&!(t.min.x>c||c>t.max.x||t.min.y>h||h>t.max.y)&&(d=Lm(Rm(c,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;a.float32[o]=d?l+Xn:l,s=s||d!==u;}}}return s}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,jg.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(e){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const e of this.modelUris)t.removeModel(e,"",!0);}addFeature(e,t,r,n,i){const s=this.layers[0],a=s.layout.get("model-id"),o=s.layout.get("model-allow-density-reduction"),l=a.evaluate(r,{},this.canonical);if(!l)return lt(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),l;!l.includes("://")&&!this.styleDefinedModelURLs[l]||this.modelUris.includes(l)||this.modelUris.push(l),this.instancesPerModel[l]||(this.instancesPerModel[l]=new hw);const u=this.instancesPerModel[l],c=u.instancedDataArray,h=new cw(r,c.length);let d;n&&(d=cy(e,n));for(const e of t)for(const t of e){if(t.x<0||t.x>=Xn||t.y<0||t.y>=Xn)continue;if(0!==this.lookupDim&&o){const e=(this.lookupDim-1)/Xn,r=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}}this.instanceCount++;const e=c.length;if(c.resize(e+1),n){u.instancesRoadElevation||(u.instancesRoadElevation=[]);const e=d?d.pointElevation(new _e(t.x,t.y)):0;u.instancesRoadElevation.push(e);}u.instancesEvaluatedElevation.push(0),c.float32[16*e]=t.x,c.float32[16*e+1]=t.y;}return h.instancedDataCount=u.instancedDataArray.length-h.instancedDataOffset,h.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(h),this.evaluate(h,{},u,!1)),l}getModelUris(){return this.modelUris}evaluate(e,t,r,n){const i=this.layers[0],s=e.feature,a=this.canonical,o=e.rotation=i.paint.get("model-rotation").evaluate(s,t,a),l=e.scale=i.paint.get("model-scale").evaluate(s,t,a),u=e.translation=i.paint.get("model-translation").evaluate(s,t,a),{r:c,g:h,b:d}=i.paint.get("model-color").evaluate(s,t,a),p=i.paint.get("model-color-mix-intensity").evaluate(s,t,a),f=[];this.maxVerticalOffset0?Math.sqrt(m):0;r.maxScale=Math.max(Math.max(r.maxScale,l[0]),Math.max(l[1],l[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,y),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Kg(f,o,l);const g=Math.round(100*p)+d/1.05;for(let t=0;t10?this.tileToMeter:Fl(a,d)),o[s+4]=u[0],o[s+5]=u[1],o[s+6]=u[2]+(r.instancesRoadElevation?r.instancesRoadElevation[i]:0)+l,o[s+7]=f[0],o[s+8]=f[1],o[s+9]=f[2],o[s+10]=f[4],o[s+11]=f[5],o[s+12]=f[6],o[s+13]=f[8],o[s+14]=f[9],o[s+15]=f[10],r.instancesEvaluatedElevation[i]=u[2];}}}ea(dw,"ModelBucket",{omit:["layers"]}),ea(hw,"PerModelAttributes"),ea(cw,"ModelFeature");class pw{constructor(e,t,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=r;}static create(e,t,r){const n=r||e.findDEMTileFor(t);if(!n||!n.dem)return;const i=n.dem,s=n.tileID,a=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=rx.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=rx.HasMapboxMeshFeatures),i&&(this.modelTraits|=rx.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=s,this.worldview=o,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new ww(e)),bw(e,a.featureIndexArray.length,a.grid),a.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,a.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&t.push({footprint:n.footprint,id:e});}}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const r=t?this.stateDependentLayers:this.layers;if(!Ae(e,this.states))for(const t of r)this.evaluate(t,e);this.states=structuredClone(e);}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const r of t){const t=r.node;this.uploaded?this.updatePbrBuffer(t):ox(t,e,!0);}for(const e of t)ux(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);if(e.lodMeshes)for(const r of e.lodMeshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);return t}needsReEvaluation(e,t,r){const n=e.transform.projectionOptions,i=e.style.getBrightness(),s=this.brightness!==i;if(!this.uploaded||this.dirty||n.name!==this.projection.name||Aw(r.paint.get("model-color").value,s)||Aw(r.paint.get("model-color-mix-intensity").value,s)||Aw(r.paint.get("model-roughness").value,s)||Aw(r.paint.get("model-emissive-strength").value,s)||Aw(r.paint.get("model-height-based-emissive-strength-multiplier").value,s)){this.projection=n,this.brightness=i;const e=this.getNodesInfo();for(const t of e)t.state=null;return !0}return !1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const e of r){const r=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(r,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(r,{},n);}}evaluate(e,t){const r=this.getNodesInfo();for(const n of r){if(!n.node.meshes)continue;const r=n.feature,i=t&&t[r.id];if(Ae(i,n.state))continue;n.state=structuredClone(i);const s=n.node.meshes&&n.node.meshes[0].featureData,a=n.evaluatedColor[2],o=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,s){for(let t=0;t=e)continue;const h=fw[u],d=Math.abs(h);d>o&&(a=h,o=d,l=i,c=t);}if(o>.1){const s=1-(e+.5*Math.abs(l*c))/u;let o=t._dem.get(n,r)+a*s;const h=t._dem.get(n+l,r+c),d=t._dem.get(n-l,r-c,!0);(o-h)*(o-d)>0&&(o=(h+d)/2),fw[i]=t._dem.set(n,r,o),mw[i]=e;}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Tt.now());}setFilter(e){this.filter=e?go(e):null;}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Qa(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)ux(t.node),hx(t.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!r.some(e=>e.footprint===t);}}getHeightAtTileCoord(e,t){const r=[0,0,0],n=c([]);for(const i of this.getNodesInfo()){const s=i.node.meshes[0],a=s.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===i.node.hidden)return {height:1/0,maxHeight:i.feature.properties.height,hidden:!1,verticalScale:i.evaluatedScale[2]};if(h(n,i.node.globalMatrix),r[0]=e,r[1]=t,r[2]=0,$(r,r,n),i.node.meshBVH){const e=r[0],t=r[1];yw[0]=e-1,yw[1]=t-1,yw[2]=-1e3,gw[0]=e+1,gw[1]=t+1,gw[2]=1e3;const n=i.node.meshBVH.findHighestPoint(yw,gw);if(null!==n)return {height:n,maxHeight:i.feature.properties.height,hidden:i.hiddenByReplacement,verticalScale:i.evaluatedScale[2]};continue}const o=(r[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*tx|0,l=Math.min(63,(r[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*tx|0)*tx+Math.min(63,o),u=s.heightmap[l];if(u<0&&i.node.footprint){const r=[];if(i.node.footprint.grid.query(new _e(e,t),new _e(e,t),r),r.length>0)return {height:void 0,maxHeight:i.feature.properties.height,hidden:i.hiddenByReplacement,verticalScale:i.evaluatedScale[2]};continue}if(i.hiddenByReplacement)return;return {height:u,maxHeight:i.feature.properties.height,hidden:!1,verticalScale:i.evaluatedScale[2]}}}}function Aw(e,t){return e instanceof Xs&&!e.isLightConstant&&t}function Iw(e){const t=Ze(e,0,2);return Math.min(Math.round(.5*t*255),255)}const Mw=new Float64Array(10*vw.length);function Sw(e,t,r,n,i){if(!e.featureData)return;const s=e.featureArray=new Eu;s.reserveExact(e.featureData.length),function(e,t,r){const n=r-t;for(let r=0;r>r&65535,i=t>>n&15,u=i<8?i:0,c=10*u;let h=(61440&e|(61440&e)>>4)>>8,d=(3840&e|(3840&e)>>4)>>4,p=240&e|(240&e)>>4;const f=(15&e|(15&e)<<4)/255,m=a[c+3];m>0&&(h=wr(h,a[c],m),d=wr(d,a[c+1],m),p=wr(p,a[c+2],m)),h*=f,d*=f,p*=f;const y=h<<8|d,g=p<<8|a[c+4],x=a[c+5],b=a[c+6],v=a[c+7],w=a[c+8],_=a[c+9];if(s.emplaceBack(y,g,x,b,v,w,_),l&&2===u){l=!1;const e=10*o.lights.length,t=new Eu;t.reserveExact(e);for(let r=0;r"string"==typeof e)){e.nodeOverrideNames=[];for(const r of t)e.nodeOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n={orientation:[0,0,0],minZoom:void 0,maxZoom:void 0};if(Object.hasOwn(r,"orientation")){const e=r.orientation;e&&(n.orientation=e);}Object.hasOwn(r,"minzoom")&&(n.minZoom=r.minzoom),Object.hasOwn(r,"maxzoom")&&(n.maxZoom=r.maxzoom),e.nodeOverrides.set(t,n);});}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const r of t)e.materialOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n=r["model-color"],i={color:void 0!==n?new Ar(n[0],n[1],n[2]):new Ar(1,1,1),colorMix:0,emissionStrength:0,opacity:1},s=r["model-color-mix-intensity"];void 0!==s&&(i.colorMix=s);const a=r["model-emissive-strength"];void 0!==a&&(i.emissionStrength=a);const o=r["model-opacity"];void 0!==o&&(i.opacity=o),e.materialOverrides.set(t,i);});}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){if(0===this._modelsInfo.size)return !0;for(const e of this._modelsInfo.values())if(null==e.model)return !1;return !0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return !1}reload(){this.cancelModelRequests();const e=zo(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load();}onRemove(e){this.cancelModelRequests();}setModels(e){this.models=[];const t=new Map;for(const r in e){const n=e[r],i=this._modelsInfo.get(r);i&&i.modelSpec.uri===n.uri&&t.set(r,i);}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[e,r]of t)r.model||t.delete(e);}this._modelsInfo=t,this._options.models=e,this.load();}}function Ew(e,t,r,n){const i=1<"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?qb():Promise.resolve()}},heatmap:class extends Oo{createBucket(e){return new nv(e)}constructor(e,t,r,n){super(e,{layout:iv||(iv=new ho({visibility:new lo(po.layout_heatmap.visibility)})),paint:sv||(sv=new ho({"heatmap-radius":new uo(po.paint_heatmap["heatmap-radius"]),"heatmap-weight":new uo(po.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new lo(po.paint_heatmap["heatmap-intensity"]),"heatmap-color":new co(po.paint_heatmap["heatmap-color"]),"heatmap-opacity":new lo(po.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=xv({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);}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}queryRadius(e){return Hb("heatmap-radius",this,e)}queryIntersectsFeature(e,t,r,n,i,s,a,o){const l=this.paint.get("heatmap-radius").evaluate(t,r);return Jb(e,n,s,a,o,!0,!0,new _e(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,r){return "heatmap"===e?{config:new Ac(this,{zoom:t,lut:r}),overrideFog:!1}:{}}},hillshade:class extends Oo{constructor(e,t,r,n){super(e,{layout:av||(av=new ho({visibility:new lo(po.layout_hillshade.visibility)})),paint:ov||(ov=new ho({"hillshade-illumination-direction":new lo(po.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new lo(po.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new lo(po.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new lo(po.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new lo(po.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new lo(po.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new lo(po.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t,r){return {overrideFog:!1}}},fill:class extends Oo{constructor(e,t,r,n){super(e,{layout:lv||(lv=new ho({"fill-sort-key":new uo(po.layout_fill["fill-sort-key"]),visibility:new lo(po.layout_fill.visibility),"fill-elevation-reference":new lo(po.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new uo(po.layout_fill["fill-construct-bridge-guard-rail"])})),paint:uv||(uv=new ho({"fill-antialias":new lo(po.paint_fill["fill-antialias"]),"fill-opacity":new uo(po.paint_fill["fill-opacity"]),"fill-color":new uo(po.paint_fill["fill-color"]),"fill-outline-color":new uo(po.paint_fill["fill-outline-color"]),"fill-translate":new lo(po.paint_fill["fill-translate"]),"fill-translate-anchor":new lo(po.paint_fill["fill-translate-anchor"]),"fill-pattern":new uo(po.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new lo(po.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new lo(po.paint_fill["fill-emissive-strength"]),"fill-z-offset":new uo(po.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new uo(po.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new uo(po.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),r=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(e,t,r){return {config:new Ac(this,{zoom:t,lut:r}),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(e){return new Ec(e)}queryRadius(){return Xb(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,r,n,i,s){return !e.queryGeometry.isAboveHorizon&&Zc(Zb(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(e){if(0!==this.paint.get("fill-z-offset").constantOr(1))return !0;const t=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=e?t&&!e:t}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}mayUse(e){return "HD"===e&&Uo(this,"fill-elevation-reference",e=>"none"!==e)}prepare(){return this.mayUse("HD")?qb():Promise.resolve()}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends Oo{constructor(e,t,r,n){super(e,{layout:dv||(dv=new ho({visibility:new lo(po["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new lo(po["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new lo(po["layout_fill-extrusion"]["source-max-zoom"])})),paint:pv||(pv=new ho({"fill-extrusion-opacity":new lo(po["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new uo(po["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new lo(po["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new lo(po["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new uo(po["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new lo(po["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new uo(po["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new uo(po["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new lo(po["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new lo(po["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new lo(po["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new lo(po["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new lo(po["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new lo(po["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new lo(po["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new lo(po["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new lo(po["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new lo(po["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new uo(po["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new uo(po["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new lo(po["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new lo(po["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new lo(po["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new lo(po["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new lo(po["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new uo(po["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new uo(po["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new lo(po["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new yb(e)}queryRadius(){return Xb(this.paint.get("fill-extrusion-translate"))}is3D(e){return !0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,r,n,i,s,a,o,l){const u=Wb(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,r),h=this.paint.get("fill-extrusion-base").evaluate(t,r),d=[0,0],p=o&&s.elevation,f=s.elevation?s.elevation.exaggeration():1,m=e.tile.getBucket(this);if(m instanceof yb){const e=m.centroidData.find(e=>l>=e.vertexArrayOffset&&le.polygon).flat());const y=p?o:null,[g,x]=Av(s,n,h,c,u,a,y,d,f,s.center.lat,e.tileID.canonical),b=e.queryGeometry;return _v(g,x,b.isPointQuery()?b.screenBounds:b.screenGeometry)}},building:class extends Oo{constructor(e,t,r,n){super(e,{layout:fv||(fv=new ho({visibility:new lo(po.layout_building.visibility),"building-facade":new uo(po.layout_building["building-facade"]),"building-facade-floors":new uo(po.layout_building["building-facade-floors"]),"building-facade-unit-width":new uo(po.layout_building["building-facade-unit-width"]),"building-facade-window":new uo(po.layout_building["building-facade-window"]),"building-roof-shape":new uo(po.layout_building["building-roof-shape"]),"building-height":new uo(po.layout_building["building-height"]),"building-base":new uo(po.layout_building["building-base"]),"building-flood-light-wall-radius":new uo(po.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new uo(po.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new uo(po.layout_building["building-flip-roof-orientation"])})),paint:mv||(mv=new ho({"building-opacity":new lo(po.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new lo(po.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new lo(po.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new lo(po.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new lo(po.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new lo(po.paint_building["building-vertical-scale"]),"building-cast-shadows":new lo(po.paint_building["building-cast-shadows"]),"building-color":new uo(po.paint_building["building-color"]),"building-emissive-strength":new uo(po.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new lo(po.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new lo(po.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new lo(po.paint_building["building-front-cutoff"]),"building-flood-light-color":new lo(po.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new lo(po.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new lo(po.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}mayUse(e){return "HD"===e}prepare(){return async function(){return function(){if(!ht(self))return null;if(null!=Lb||null!=Rb)return null;if(null!=Cb)return Cb;const e=fetch(kt());return Cb=function(e){let t,r,n,i,s;function a(){t=new Uint8Array(s.buffer),r=new Int16Array(s.buffer),n=new Int32Array(s.buffer),i=new Float32Array(s.buffer);}function o(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a:o,f:function(e){const r=t.length,n=Math.max(e>>>0,Math.ceil(1.2*r)),i=Math.ceil((n-r)/65536);try{return s.grow(i),a(),!0}catch(e){return !1}},g:o,b:l,c:l,d:l,e:l}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,u):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,u))).then(e=>{const o=e.instance.exports;return (0,o.g)(),s=o.f,a(),new Pb({setStyle:o.h,setAOOptions:o.i,setMetricOptions:o.j,setStructuralOptions:o.k,setFacadeOptions:o.l,setFauxFacadeOptions:o.m,setFacadeClassifierOptions:o.n,addFeature:o.o,addFacade:o.p,generateMesh:o.q,getLastError:o.r,getOuterRingLength:o.s,getMeshCount:o.t,getPositionsPtr:o.u,getPositionsLength:o.v,getNormalsPtr:o.w,getNormalsLength:o.x,getAOPtr:o.y,getAOLength:o.z,getUVPtr:o.A,getUVLength:o.B,getFauxFacadePtr:o.C,getFauxFacadeLength:o.D,getIndicesPtr:o.E,getIndicesLength:o.F,getBuildingPart:o.G,getRingCount:o.H,getRingPtr:o.I,getRingLength:o.J,malloc:o.K,free:o.L,heapU8:t,heap16:r,heap32:n,heapF32:i})})}(e).then(e=>{Cb=null,Lb=e;}).catch(e=>{lt("Could not load building-gen"),Cb=null,Rb=e;}),Cb}()}()}createBucket(e){return new Nb(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return !0}canCastShadows(){return !0}is3D(e){return !0}queryRadius(e){return 0}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){let c=this.layout.get("building-height").evaluate(t,r);const h=this.layout.get("building-base").evaluate(t,r),d=e.tile.getBucket(this).getFootprint(t);if(d){if(0!==d.hiddenFlags)return !1;c=d.height;}const[p,f]=Av(s,n,h,c,new _e(0,0),a,null,[0,0],1,s.center.lat,e.tileID.canonical),m=e.queryGeometry;return _v(p,f,m.isPointQuery()?m.screenBounds:m.screenGeometry)}},line:class extends Oo{constructor(e,t,r,n){const i=Ev();super(e,i,t,r,n),i.layout&&(this.layout=new oo(i.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null;}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Ei,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}else "line-gradient-use-theme"===e&&(this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER);}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(Vv)return Vv;const e=Ev();return Vv=new kv(e.paint.properties["line-width"].specification),Vv.useIntegerZoom=!0,Vv})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e);}createBucket(e){return new Bh(e)}getProgramIds(){const e=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return "default"!==this.paint.get("line-blend-mode")&&e.push("lineBlendComposite"),e}getDefaultProgramParams(e,t,r){if("lineBlendComposite"===e)return {};const n=Tv(this);return {config:new Ac(this,{zoom:t,lut:r}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,r=Rv(Hb("line-width",this,t),Hb("line-gap-width",this,t)),n=Hb("line-offset",this,t);return r/2+Math.abs(n)+Xb(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,r,n,i,s){if(e.queryGeometry.isAboveHorizon)return !1;const a=Zb(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),o=e.pixelToTileUnitsFactor/2*Rv(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),l=this.paint.get("line-offset").evaluate(t,r);return l&&(n=function(e,t){const r=[],n=new _e(0,0);for(let i=0;i=3)for(let t=0;t"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?qb():Promise.resolve()}hasOffscreenPass(){return "default"!==this.paint.get("line-blend-mode")&&0!==this.paint.get("line-opacity").constantOr(1)&&0!==this.paint.get("line-width").constantOr(1)&&"none"!==this.visibility}resize(){this._destroyLineBlendFbo();}onRemove(e){this._destroyLineBlendFbo(e.painter&&e.painter.context&&e.painter.context.gl||void 0);}_clear(){this._destroyLineBlendFbo();}_destroyLineBlendFbo(e){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),e&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(e),this.lineBlendDensityReadback=null;}},symbol:Nv,background:class extends Oo{constructor(e,t,r,n){super(e,{layout:jv||(jv=new ho({visibility:new lo(po.layout_background.visibility)})),paint:Gv||(Gv=new ho({"background-pitch-alignment":new lo(po.paint_background["background-pitch-alignment"]),"background-color":new lo(po.paint_background["background-color"]),"background-pattern":new lo(po.paint_background["background-pattern"]),"background-opacity":new lo(po.paint_background["background-opacity"]),"background-emissive-strength":new lo(po.paint_background["background-emissive-strength"]),"background-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}getProgramIds(){return [this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,r){return {overrideFog:!1}}is3D(e){return "viewport"===this.paint.get("background-pitch-alignment")}},raster:Qv,"raster-particle":ow,sky:class extends Oo{constructor(e,t,r,n){super(e,{layout:rw||(rw=new ho({visibility:new lo(po.layout_sky.visibility)})),paint:nw||(nw=new ho({"sky-type":new lo(po.paint_sky["sky-type"]),"sky-atmosphere-sun":new lo(po.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new lo(po.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new lo(po.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new lo(po.paint_sky["sky-gradient-radius"]),"sky-gradient":new co(po.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new lo(po.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new lo(po.paint_sky["sky-atmosphere-color"]),"sky-opacity":new lo(po.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp();}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0;}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0);}_updateColorRamp(){this.colorRamp=xv({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return !0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return !1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const r=this.paint.get("sky-atmosphere-sun"),n=!r,i=e.style.light,s=i.properties.get("position");return n&&"viewport"===i.properties.get("anchor")&<("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?uw(s.azimuthal,90-s.polar,t):uw(r[0],90-r[1],t)}const r=this.paint.get("sky-gradient-center");return uw(r[0],90-r[1],t)}isSky(){return !0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position");}hasOffscreenPass(){return !0}getProgramIds(){const e=this.paint.get("sky-type");return "atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends Oo{constructor(e,t,r,n){super(e,{paint:iw||(iw=new ho({}))},t,null);}},model:class extends Oo{constructor(e,t,r,n){super(e,{layout:sw||(sw=new ho({visibility:new lo(po.layout_model.visibility),"model-id":new uo(po.layout_model["model-id"]),"model-allow-density-reduction":new lo(po.layout_model["model-allow-density-reduction"])})),paint:aw||(aw=new ho({"model-opacity":new uo(po.paint_model["model-opacity"]),"model-rotation":new uo(po.paint_model["model-rotation"]),"model-scale":new uo(po.paint_model["model-scale"]),"model-translation":new uo(po.paint_model["model-translation"]),"model-color":new uo(po.paint_model["model-color"]),"model-color-mix-intensity":new uo(po.paint_model["model-color-mix-intensity"]),"model-type":new lo(po.paint_model["model-type"]),"model-cast-shadows":new lo(po.paint_model["model-cast-shadows"]),"model-receive-shadows":new lo(po.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new lo(po.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new uo(po.paint_model["model-emissive-strength"]),"model-roughness":new uo(po.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new uo(po.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new lo(po.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new lo(po.paint_model["model-front-cutoff"]),"model-elevation-reference":new lo(po.paint_model["model-elevation-reference"]),"model-line-cutout-mode":new lo(po.paint_model["model-line-cutout-mode"]),"model-color-use-theme":new uo({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this.layer=e,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}mayUse(e){return "Standard"===e}prepare(){return async function(){return Promise.resolve()}()}createBucket(e){return new dw(e)}getProgramIds(){return ["model"]}is3D(e){return !0}hasShadowPass(){return !0}canCastShadows(){return !0}hasLightBeamPass(){return !0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(e){return e instanceof _w?8191:0}queryRenderedFeatures(e,t,r){const n=t.getSource();if(!(n&&n instanceof zw))return {};const i=n,s={};s[this.id]=[];const a=s[this.id];let o=0;for(const n of i.models){const i=t.getFeatureState(this.sourceLayer,n.id),s={type:"Unknown",id:n.id,properties:n.featureProperties},l=this.paint.get("model-rotation").evaluate(s,i),u=this.paint.get("model-scale").evaluate(s,i),c=this.paint.get("model-translation").evaluate(s,i),h=this.paint.get("model-elevation-reference");let p=[];nx(p,n,r,n.position,l,u,c,"ground"===h,"ground"===h,!1),"globe"===r.projection.name&&(p=Qg(p,r));const f=d([],r.projMatrix,p),m=ex(e.isPointQuery()?e.screenBounds:e.screenGeometry,r,f,n.aabb);if(null!=m){const e=new Pw(void 0,0,0,0,n.id);e.layer=this.layer,e.properties=structuredClone(n.featureProperties),e.properties.layer=this.id,e.properties.uri=n.uri,e.properties.orientation=n.orientation,e.sourceLayer=this.sourceLayer,e.geometry={type:"Point",coordinates:[n.position.lng,n.position.lat]},e.state=i,e.source=this.source,a.push({featureIndex:o,feature:e,intersectionZ:m});}++o;}return s}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){if(!this.modelManager)return !1;const c=this.modelManager,h=e.tile.getBucket(this);if(!(h&&h instanceof dw))return !1;for(const r in h.instancesPerModel){const n=h.instancesPerModel[r],i=void 0!==t.id?t.id:t.properties&&Object.hasOwn(t.properties,"id")?t.properties.id:void 0;if(Object.hasOwn(n.idToFeaturesIndex,i)){const t=n.features[n.idToFeaturesIndex[i]],a=c.getModel(r,u||this.scope);if(!a)return !1;let o=[];const l=new Ml(0,0),p=h.canonical;let f=Number.MAX_VALUE;for(let r=0;r{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&&(this._channel.port1.close(),this._channel.port2.close()),this._callback=()=>{};}}class Cw{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new qc(new ad(this.rawTileData)).layers,this.sourceLayerCoder=new Cw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t){const{tilespaceGeometry:r,transform:n,tileTransform:i,pixelPosMatrix:s,availableImages:a,worldview:o}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,u=r.bufferedTilespaceBounds,c=this.grid.queryKeys(u.min.x,u.min.y,u.max.x,u.max.y,(e,t,n,i)=>ih(r.bufferedTilespaceGeometry,e-l,t-l,n+l,i+l));c.sort(Ow);let h=null;n.elevation&&c.length>0&&(h=pw.create(n.elevation,this.tileID));const d={};let p;for(let l=0;l(m||(m=Gl(e,this.tileID.canonical,i)),a.queryIntersectsFeature(r,e,o,m,this.z,n,s,h,l,t.scope)));}return d}loadMatchingFeature(e,t,r,n,i,s){const{featureIndex:a,bucketIndex:o,sourceLayerIndex:l,layoutVertexArrayOffset:u}=t,c=this.bucketLayerIDs[o],h=r.layers,d=Object.keys(h);if(d.length&&!at(d,c))return;const p=r.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(a),y=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ");return void lt(`Failed to create expression for promoteId: ${t}`)}this.promoteIdExpression=e.value;}r=this.promoteIdExpression.evaluate({zoom:0},e);}else r=e.properties[n];"boolean"==typeof r&&(r=Number(r));}return r}}function Lw(e,t,r,n,i){return nt(e,(e,s)=>{const a=t instanceof oo?t.get(s):null;return a&&a.evaluate?a.evaluate(r,n,void 0,i):a})}function Ow(e,t){return t-e}function Uw(e,t){const r={};if(!t)return r;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0])),n.updateExpressions&&n.updateExpressions(e);for(const t of e)r[t.fqid]=n;}}return r}ea(Rw,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Nw=32,jw=33,Gw=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,r=0,n=0,i=0,s=0,a=0,o=0;for(1&t?i=s=a=Nw:r=n=o=Nw;(t>>=1)>1;){const e=r+i>>1,l=n+s>>1;1&t?(i=r,s=n,r=a,n=o):(r=i,n=s,i=a,s=o),a=e,o=l;}const l=4*e;Gw[l+0]=r,Gw[l+1]=n,Gw[l+2]=i,Gw[l+3]=s;}const $w=new Uint16Array(2178),qw=new Uint8Array(1089),Hw=new Uint16Array(1089);function Xw(e){return 0===e?-.03125:32===e?.03125:0}const Zw={Other:0,Symbol:1,FillExtrusion:2,HdRoadCoverage:3},Ww=(()=>({type:2,extent:Xn,loadGeometry:()=>[[new _e(0,0),new _e(8193,0),new _e(8193,8193),new _e(0,8193),new _e(0,0)]]}))();class Yw{constructor(){this.tasks=new Map,rt(["process"],this),this.invoker=new Dw(this.process),this.nextId=0;}add(e,t){const r=this.nextId++,n=function({type:e,renderSourceType:t,zoom:r}){r=r||0;const n=t===Zw.Symbol;return "message"===e?0:"maybePrepare"!==e||n?"parseTile"!==e||n?"parseTile"===e&&n?300-r:"maybePrepare"===e&&n?400-r:500:200-r:100-r}(t);if(0===n){try{e();}finally{}return null}return this.tasks.set(r,{fn:e,metadata:t,priority:n,id:r}),this.invoker.trigger(),{cancel:()=>{this.tasks.delete(r);}}}process(){try{const e=this.pick();if(!e)return;this.tasks.delete(e.id),this.tasks.size>0&&this.invoker.trigger(),e.fn();}finally{}}pick(){let e=null,t=1/0;for(const r of this.tasks.values())r.priority=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n>>1^-(1&e[t]);return e}function s_(e,t){switch(t){case "uint32":return e;case "uint16":for(let t=0;t>4|(61440&r)>>8|(240&n)<<4|61440&n,e[t+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return e;case "uint8":for(let t=0;t>6|(192&n)>>4|(192&i)>>2|192&s,e[t+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,e[t+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,e[t+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}var a_=Uint8Array,o_=Uint16Array,l_=Int32Array,u_=new a_([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),c_=new a_([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),h_=new a_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d_=function(e,t){for(var r=new o_(31),n=0;n<31;++n)r[n]=t+=1<>1|(21845&x_)<<1;g_[x_]=((65280&(b_=(61680&(b_=(52428&b_)>>2|(13107&b_)<<2))>>4|(3855&b_)<<4))>>8|(255&b_)<<8)>>1;}var v_=function(e,t,r){for(var n=e.length,i=0,s=new o_(t);i>l]=u;return a},w_=new a_(288);for(x_=0;x_<144;++x_)w_[x_]=8;for(x_=144;x_<256;++x_)w_[x_]=9;for(x_=256;x_<280;++x_)w_[x_]=7;for(x_=280;x_<288;++x_)w_[x_]=8;var __=new a_(32);for(x_=0;x_<32;++x_)__[x_]=5;var A_=v_(w_,9),I_=v_(__,5),M_=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},S_=function(e,t,r){var n=t/8|0;return (e[n]|e[n+1]<<8)>>(7&t)&r},B_=function(e,t){var r=t/8|0;return (e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},T_=function(e){return (e+7)/8|0},P_=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],z_=function(e,t,r){var n=new Error(t||P_[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,z_),!r)throw n;return n},E_=new a_(0);var k_="undefined"!=typeof TextDecoder&&new TextDecoder;try{k_.decode(E_,{stream:!0});}catch(e){}const V_={gzip_data:"gzip"};class F_ extends Error{constructor(e){super(e),this.name="MRTError";}}const D_={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},C_={uint32:1,uint16:2,uint8:4},R_={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let L_;class O_{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e;}getLayer(e){const t=this.layers[e];if(!t)throw new F_(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new F_("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length= ${r} but got buffer of length ${t.length}`);const n=function(e){const t={headerLength:0,x:0,y:0,z:0,layers:[]};let r;for(;r=e.nextField(void 0);)1===r?t.headerLength=e.readFixed32():2===r?t.x=e.readVarint():3===r?t.y=e.readVarint():4===r?t.z=e.readVarint():5===r&&t.layers.push(t_(e,e.readVarint()+e.pos));return t}(new L_(t.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new F_(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new U_(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let n of e.blockIndices){const i=r.dataIndex[n],s=i.firstByte-e.firstByte,a=i.lastByte-e.firstByte;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:s,lastByte:a,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map(e=>e.filter)};r._blocksInProgress.add(n),t.push(o);}return new N_(t,()=>{t.forEach(e=>r._blocksInProgress.delete(e.blockIndex));},(e,n)=>{if(t.forEach(e=>r._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e);});})}}class U_{constructor({version:e,name:t,units:r,tileSize:n,pixelFormat:i,buffer:s,dataIndex:a},o){if(this.version=e,1!==this.version)throw new F_(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=D_[i],this.dataIndex=a,this.bandShape=[n+2*s,n+2*s,C_[this.pixelFormat]],this._decodedBlocks=new Fw(o?o.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return C_[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data);}getBlockForBand(e){let t=0;switch(typeof e){case "string":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===e)return {bandIndex:t+i,blockIndex:r,blockBandIndex:i};t+=n.bands.length;}break;case "number":for(const[r,n]of this.dataIndex.entries()){if(e>=t&&ethis.cacheSize)throw new F_(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:t,lastByte:r,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:r}=this.getBlockForBand(e);if(t<0)throw new F_(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new F_(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[t],s=this.bandShape.reduce((e,t)=>e*t,1),a=r*s,o=n.subarray(a,a+s);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:i.offset,scale:i.scale}}}O_.setPbf=function(e){L_=e;};class N_{constructor(e,t,r){this.tasks=e,this._onCancel=t,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0);}}function j_(e,t,r){try{t=function(e){if(!e.variants)return e;if(!Array.isArray(e.variants))throw new Error("variants must be an array");for(const t of e.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(t.capabilities))throw new Error("capabilities must be an array");if(1===t.capabilities.length&&"meshopt"===t.capabilities[0])return Object.assign(e,t)}return e}(t);}catch(e){return new Error("Failed to process TileJSON variants",{cause:e})}const n=Je(Object.assign({},t,e),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return e.url&&t.tiles&&e.tiles&&(n.tiles=t.tiles),n.tiles=r.canonicalizeTileset(n,e.url),n}O_.performDecoding=function(e,t){const r=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:i,pixelFormat:s,blockShape:a,blockIndex:o,filters:l,codec:u}=e,c=r.subarray(n,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let d;if("gzip_data"!==u)throw new F_(`Unhandled codec: ${u}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve((a=function(e){31==e[0]&&139==e[1]&&8==e[2]||z_(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)}(r=e),a+8>r.length&&z_(6,"invalid gzip data"),function(e,t,r,n){var i=e.length;if(!i||t.f&&!t.l)return r||new a_(0);var s=!r,a=s||2!=t.i,o=t.i;s&&(r=new a_(3*i));var l=function(e){var t=r.length;if(e>t){var n=new a_(Math.max(2*t,e));n.set(r),r=n;}},u=t.f||0,c=t.p||0,h=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,y=8*i;do{if(!d){u=S_(e,c,1);var g=S_(e,c+1,3);if(c+=3,!g){var x=e[(P=T_(c)+4)-4]|e[P-3]<<8,b=P+x;if(b>i){o&&z_(0);break}a&&l(h+x),r.set(e.subarray(P,b),h),t.b=h+=x,t.p=c=8*b,t.f=u;continue}if(1==g)d=A_,p=I_,f=9,m=5;else if(2==g){var v=S_(e,c,31)+257,w=S_(e,c+10,15)+4,_=v+S_(e,c+5,31)+1;c+=14;for(var A=new a_(_),I=new a_(19),M=0;M>4)<16)A[M++]=P;else {var E=0,k=0;for(16==P?(k=3+S_(e,c,3),c+=2,E=A[M-1]):17==P?(k=3+S_(e,c,7),c+=3):18==P&&(k=11+S_(e,c,127),c+=7);k--;)A[M++]=E;}}var V=A.subarray(0,v),F=A.subarray(v);f=M_(V),m=M_(F),d=v_(V,f),p=v_(F,m);}else z_(1);if(c>y){o&&z_(0);break}}a&&l(h+131072);for(var D=(1<>4;if((c+=15&E)>y){o&&z_(0);break}if(E||z_(2),L<256)r[h++]=L;else {if(256==L){R=c,d=null;break}var O=L-254;L>264&&(O=S_(e,c,(1<<(j=u_[M=L-257]))-1)+f_[M],c+=j);var U=p[B_(e,c)&C],N=U>>4;if(U||z_(3),c+=15&U,F=y_[N],N>3){var j=c_[N];F+=B_(e,c)&(1<y){o&&z_(0);break}a&&l(h+131072);var G=h+O;if(he.length)&&(r=e.length),new a_(e.subarray(0,r))}(r,0,h):r.subarray(0,h)}(r.subarray(a,-8),{i:2},new a_(((i=r)[(s=i.length)-4]|i[s-3]<<8|i[s-2]<<16|i[s-1]<<24)>>>0),n)));var r,n,i,s,a;const o=V_[t];if(!o)throw new Error(`Unhandled codec: ${t}`);const l=new globalThis.DecompressionStream(o);return new Response(new Blob([e]).stream().pipeThrough(l)).arrayBuffer().then(e=>new Uint8Array(e))}(c,u).then(e=>(function(e,t){let r;for(;r=e.nextField();)if(2===r)r_(e,e.readVarint()+e.pos,t);else if(3===r)throw new Error("Not implemented")}(new L_(e),h),new(0,R_[s])(h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case "delta_filter":n_(e,a);break;case "zigzag_filter":i_(e);break;case "bitshuffle_filter":s_(e,s);break;default:throw new F_(`Unhandled filter "${l[t]}"`)}return {layerName:t,blockIndex:o,data:e}}).catch(e=>{throw e})}))},ea(N_,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),ea(O_,"MapboxRasterTile"),ea(U_,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const G_=new Map,$_=new Map;class q_{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(e,t){const r=this.toIdx(e,t);return {min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function H_(e,t,r,n){let i=0,s=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(n[a])<1e-15){if(r[a]t[a])return null}else {const o=1/n[a];let l=(e[a]-r[a])*o,u=(t[a]-r[a])*o;if(l>u){const e=l;l=u,u=e;}if(l>i&&(i=l),us)return null}return i}function X_(e,t,r,n,i,s,a,o,l,u,c){const h=n-e,d=i-t,p=s-r,f=a-e,m=o-t,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*f-c[0]*y,b=c[0]*m-c[1]*f,v=h*g+d*x+p*b;if(Math.abs(v)<1e-15)return null;const w=1/v,_=u[0]-e,A=u[1]-t,I=u[2]-r,M=(_*g+A*x+I*b)*w;if(M<0||M>1)return null;const S=A*p-I*d,B=I*h-_*p,T=_*d-A*h,P=(c[0]*S+c[1]*B+c[2]*T)*w;return P<0||M+P>1?null:(f*S+m*B+y*T)*w}function Z_(e,t,r){return (e-t)/(r-t)}function W_(e,t,r,n,i,s,a,o,l){const u=1<{const s=n?1:0,a=(e+1)*r-s,o=t*r,l=(t+1)*r-s;i[0]=e*r,i[1]=o,i[2]=a,i[3]=l;};let a=new q_(n);const o=[];for(let t=0;t=1;n/=2){const e=r.at(-1);a=new q_(n);for(let t=0;t0;){const{idx:o,t:p,nodex:f,nodey:m,depth:y}=d.pop();if(this.leaves[o]){W_(f,m,y,e,t,r,n,c,h);const o=1<=e[2])return p}continue}let g=0;for(let d=0;d=l[u[r]]&&(u.splice(r,0,d),t=!0);t||(u[g]=d),g++;}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (t+1)*this.stride+(e+1)}static pack(e,t){const r=[0,0,0,0],n=rA.getUnpackVector(t);let i=Math.floor((e+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new vh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,i=t*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(t){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-t*this.dim,l=-r*this.dim;for(let t=s;t>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=nA[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new sA(a,s,i,void 0,e)}constructor(e,t=64,r=Float64Array,n=ArrayBuffer,i){if(isNaN(e)||e<0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const s=nA.indexOf(this.ArrayType),a=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-o%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${r}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new r(i,8+o+l,2*e),this._pos=2*e,this._finished=!0;else {const i=this.data=new n(8+a+o+l);this.ids=new this.IndexArrayType(i,8,e),this.coords=new r(i,8+o+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+s]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e;}}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return aA(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this;iA[0]=0,iA[1]=i.length-1,iA[2]=0;let o=3;const l=[];for(;o>0;){const u=iA[--o],c=iA[--o],h=iA[--o];if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=e&&o<=r&&u>=t&&u<=n&&l.push(i[a]);}continue}const d=h+c>>1,p=s[2*d],f=s[2*d+1];p>=e&&p<=r&&f>=t&&f<=n&&l.push(i[d]),(0===u?e<=p:t<=f)&&(iA[o++]=h,iA[o++]=d-1,iA[o++]=1-u),(0===u?r>=p:n>=f)&&(iA[o++]=d+1,iA[o++]=c,iA[o++]=1-u);}return l}within(e,t,r){const n=[];return this.withinInto(e,t,r,n),n}withinInto(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this;iA[0]=0,iA[1]=i.length-1,iA[2]=0;let o=3,l=0;const u=r*r;for(;o>0;){const c=iA[--o],h=iA[--o],d=iA[--o];if(h-d<=a){for(let r=d;r<=h;r++)cA(s[2*r],s[2*r+1],e,t)<=u&&(n[l++]=i[r]);continue}const p=d+h>>1,f=s[2*p],m=s[2*p+1];cA(f,m,e,t)<=u&&(n[l++]=i[p]),(0===c?e-r<=f:t-r<=m)&&(iA[o++]=d,iA[o++]=p-1,iA[o++]=1-c),(0===c?e+r>=f:t+r>=m)&&(iA[o++]=p+1,iA[o++]=h,iA[o++]=1-c);}return l}}function aA(e,t,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;oA(e,t,a,n,i,s),aA(e,t,r,n,a-1,1-s),aA(e,t,r,a+1,i,1-s);}function oA(e,t,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);oA(e,t,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=t[2*r+s];let o=n,l=i;for(lA(e,t,n,r),t[2*i+s]>a&&lA(e,t,n,i);oa;)l--;}t[2*n+s]===a?lA(e,t,n,l):(l++,lA(e,t,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function lA(e,t,r,n){uA(e,r,n),uA(t,2*r,2*n),uA(t,2*r+1,2*n+1);}function uA(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function cA(e,t,r,n){const i=e-r,s=t-n;return i*i+s*s}t.$=class{constructor(e){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(e&&e.maxTextureMemoryMB?e.maxTextureMemoryMB:256)*1024,this.currentFrameAtlases=new Set,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures();});}beginFrame(){this.currentFrameAtlases.clear();}calculateTextureMemory(e){return e.image?Math.ceil(e.image.width*e.image.height*4*(e.patternPositions.size>0?1.33:1)):0}evictTexture(e){const t=this.textures.get(e);if(t){const r=this.calculateTextureMemory(e);t.destroy(),this.textures.delete(e),this.textureAccessTimes.delete(e),this.textureMemoryUsed-=r,e.uploaded=!1;}}evictTexturesIfNeeded(e){for(;this.textureMemoryUsed+e>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[r]of this.textures.entries()){if(this.currentFrameAtlases.has(r))continue;const n=this.textureAccessTimes.get(r)||0;n{let n=e===s-1?e-2:0===e?e:e-1;return n+=r?24575:0,[n,t]};for(let e=0;e{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:n,sourceMapId:this.mapId});}}}receive(e){const t=e.data;if(!t)return;const r=t.id;if(r&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[r];delete this.cancelCallbacks[r],e&&e.cancel();}else if(t.mustQueue||ht(self)){const e=this.callbacks[r],n=this.scheduler.add(()=>this.processTask(r,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,t);}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const r=this.callbacks[e];delete this.callbacks[e],r&&(t.error?r(na(t.error)):r(null,na(t.data)));}else {const r=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?ra(t):null,data:ra(n,r)},r);}:()=>{},i=na(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:r,scope:s}=i;this.parent.getWorkerSource(t.sourceMapId,{type:e[0],source:r,scope:s,uid:0})[e[1]](i,n);}else n(new Error(`Could not find function ${t.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}},t.a$=class{constructor(e,t,r,n){this.context=e,this.format=n,this.size=r,this.texture=e.gl.createTexture();const[i,s,a]=this.size,{gl:o}=e;o.bindTexture(o.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&o.texImage3D(o.TEXTURE_3D,0,this.format,i,s,a,0,np(this.format),ip(this.format),t.data);}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}},t.a0=cp,t.a1=gr,t.a2=op,t.a3=Yv,t.a4=Kr,t.a5=class{static calculate(e,t,r){const n=new Set,i=new Map,s=new Set,a=new Set;for(const r of Object.values(e))for(const[e,o]of Object.entries(r.floors)){s.add(e),o.isDefault&&a.add(e),o.conflicts&&i.set(e,o.conflicts);const r=e===t,l=o.connections&&t&&o.connections.has(t);(r||l)&&n.add(e);}const o=e=>{const t=i.get(e)||new Set;for(const r of n)if((i.get(r)||new Set).has(e)||t.has(r))return !0;return !1};if(r)for(const e of r)s.has(e)&&(o(e)||n.add(e));for(const e of a)n.has(e)||o(e)||n.add(e);return n}},t.a6=sA,t.a7=Fw,t.a8=Hx,t.a9=wh,t.aA=Qv,t.aB=yf,t.aC=Zw,t.aD=Bm,t.aE=Sm,t.aF=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new _e(1/0,1/0),max:new _e(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const r=Vm(new _e(0,0),new _e(Xn,Xn),e),n=[];if(t&&!Em(r,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Em(r,t))continue;const i=Fm(t.min,t.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope});}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(r).buckets[e.layer];n&&n.updateFootprints(r.toUnwrapped(),t);}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})));}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const r=e.getOrder(),n=e.getClipMask(),i=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Vm(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:r,clipMask:n,clipScope:i});}this._sourceIds.push(e.getSourceId());}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Pm(e.min,t.min)||Pm(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const r=(e,t)=>e+t;return e.length-t.length||e.reduce(r,"").localeCompare(t.reduce(r,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[t];e=r.priority!==n.priority||!zm(r,n)||r.order!==n.order||r.clipMask!==n.clipMask||!Ae(r.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t;}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Sm&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const r=t[e].priority;for(;e1){let t=0,r=e(t);for(;t!==r;){let n=t;const i=t;for(;n!==r;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement();}},t.aG=Jr,t.aH=Jt,t.aI=2,t.aJ=Ku,t.aK=Mu,t.aL=ku,t.aM=Pu,t.aN=gu,t.aO=Bu,t.aP=Ql,t.aQ=Kl,t.aR=fu,t.aS=au,t.aT=bu,t.aU=Au,t.aV=Iu,t.aW=Su,t.aX=Ym,t.aY=/^(.*)-transition$/,t.aZ=class extends Pw{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer);}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},t.a_=sp,t.aa=Bh,t.ab=Ml,t.ac=Sl,t.ad=vp,t.ae=zl,t.af=O_,t.ag=Dl,t.ah=ix,t.ai=zw,t.aj=rx,t.ak=3,t.al=2,t.am=0,t.an=1,t.ao=Jh,t.ap=em,t.aq=2,t.ar=_h,t.as=ad,t.at=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.length=this.buf.length;}writeTag(e,t){this.writeVarint(e<<3|t);}realloc(e){let t=this.length||16;for(;t=0&&e<128)return this.pos>=this.length&&this.realloc(1),void(this.buf[this.pos++]=e);e>268435455||e<0?function(e,t){let r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7);}(r,0,t),function(e,t){const r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))));}(n,t);}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))));}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e);}writeBoolean(e){this.writeVarint(+e);}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,r){for(let n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=n;continue}if(n<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);n<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:(n<65536?e[r++]=n>>12|224:(e[r++]=n>>18|240,e[r++]=n>>12&63|128),e[r++]=n>>6&63|128),e[r++]=63&n|128);}return r}(this.buf,e,this.pos);const r=this.pos-t;r>=128&&ld(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r;}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4;}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8;}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t),this.buf.set(e,this.pos),this.pos+=t;}writeRawMessage(e,t){this.pos++;const r=this.pos;e(t,this);const n=this.pos-r;n>=128&&ld(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;}writeMessage(e,t,r){this.writeTag(e,2),this.writeRawMessage(t,r);}writePackedVarint(e,t){t.length&&this.writeMessage(e,ud,t);}writePackedSVarint(e,t){t.length&&this.writeMessage(e,cd,t);}writePackedBoolean(e,t){t.length&&this.writeMessage(e,pd,t);}writePackedFloat(e,t){t.length&&this.writeMessage(e,hd,t);}writePackedDouble(e,t){t.length&&this.writeMessage(e,dd,t);}writePackedFixed32(e,t){t.length&&this.writeMessage(e,fd,t);}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,md,t);}writePackedFixed64(e,t){t.length&&this.writeMessage(e,yd,t);}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,gd,t);}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t);}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t);}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t);}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t);}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t);}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t);}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t);}writeStringField(e,t){this.writeTag(e,2),this.writeString(t);}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t);}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t);}writeBooleanField(e,t){this.writeVarintField(e,+t);}},t.au=_e,t.av=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return ct(e.expression.evaluate(t))}interpolate(e,t,r){return {x:wr(e.x,t.x,r),y:wr(e.y,t.y,r),z:wr(e.z,t.z,r),azimuthal:wr(e.azimuthal,t.azimuthal,r),polar:wr(e.polar,t.polar,r)}}},t.aw=oo,t.ax=ho,t.ay=bh,t.az=ow,t.b=xh,t.b$=Ws,t.b0=class{constructor(e,t,r,n,i,s){this.tileID=e,this.uid=et(),this.uses=0,this.tileSize=t,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection),this.worldview=s,this._hasAppearances=null;}registerFadeDuration(e){const t=e+this.timeAdded;t0&&(this.frcCoveragePolygons=e.frcCoveragePolygons),this.hasDeferredRoadStructure=!!e.hasDeferredRoadStructure,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!e.hasTunnelGeometry;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ym){if(this.hasSymbolBuckets=!0,!r)break;t.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ym&&t.hasRTLText){this.hasRTLText=!0,Ja();break}}this.queryPadding=0;for(const e in this.buckets){const r=this.buckets[e],n=t.style.getOwnLayer(e);if(!n)continue;const i=n.queryRadius(r)||0;this.queryPadding=Math.max(this.queryPadding,i);}e.imageAtlas&&(this.imageAtlas=t.style.imageManager.imageAtlasCache.getOrCache(e.imageAtlas)),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness;}else this.collisionBoxArray=new Du;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=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";}}loadModelData(e,t,r){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets=Object.assign({},this.buckets,Uw(e.buckets,t.style)),e.featureIndex&&(this.latestFeatureIndex=e.featureIndex));}getBucket(e){return this.buckets[e.fqid]}upload(e,t){for(const r in this.buckets){const n=this.buckets[r];if(n.uploadPending()){let r={},i=[],s={zoom:0,pitch:0,brightness:0,worldview:""};if(t){if(t.style){i=t.style.listImages();const e=n.layers[0],s=e.sourceLayer||"_geojsonTileLayer",a=t.style.getLayerSourceCache(e);a&&(r=a._state.getState(s,void 0));}s={zoom:t.transform.zoom||0,pitch:t.transform.pitch||0,brightness:t.style.getBrightness()||0,worldview:t.worldview||""};}n.upload(e,this.tileID.canonical,r,i,s);}}const r=e.gl,n=this.imageAtlas;n&&t&&(this.imageAtlasTexture=t.style.imageManager.imageAtlasCache.getTextureForAtlas(n,e,r.RGBA8),n.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new sp(e,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new sp(e,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,r){if(this.imageAtlas&&this.imageAtlasTexture&&t){const n=t.style.getLut(r);this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,r,n);}if(!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=t.style.getBrightness(),i=t.style.listImages(),s=i.length,a=t.style._changes.getUpdatedPaintProperties(),o=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>a.has(e.fqid))),l=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>e.hasTransition&&e.hasTransition())),u=this._firstPrepareComplete&&s!==this._lastAvailableImagesCount;null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(t));const c=this._lastUpdatedBrightness!==n;this._lastAvailableImagesCount=s,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||n||this._hasAppearances||o||l||u)&&(!(this._hasAppearances||o||l||u)&&this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)<.001||(this.updateBuckets(t,c,void 0,u||o||l,a,i),this._lastUpdatedBrightness=n));}evaluateQueryRenderedFeaturePadding(){let e=0;for(const t in this.buckets){const r=this.buckets[t];r.evaluateQueryRenderedFeaturePadding&&(e=Math.max(e,r.evaluateQueryRenderedFeaturePadding()));}return e}queryRenderedFeatures(e,t,r,n,i,s,a){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return {};const o=this.evaluateQueryRenderedFeaturePadding(),l=function(e,t){const r=b([],[.5*e.width,.5*-e.height,1]);return p(r,r,[1,-1,0]),d(r,r,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(r)}(i,this.tileID);return this.latestFeatureIndex.query(e,{tilespaceGeometry:t,pixelPosMatrix:l,transform:n,availableImages:r,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:o,scope:a})}querySourceFeatures(e,t){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),i=t?t.sourceLayer:"",s=n._geojsonTileLayer||n[i];if(!s)return;const a=go(t&&t.filter),{z:o,x:l,y:u}=this.tileID.canonical,c={z:o,x:l,y:u};for(let t=0;te)r=!1;else if(t)if(this.expirationTimee.appearances&&e.appearances.length>0))return !0;return !1}updateBuckets(e,t,r,n,i,s){if(!this.latestFeatureIndex)return;if(!e.style)return;const a=s||e.style.listImages(),o=e.style.getBrightness(),l=i||new Set;for(const i in this.buckets){if(!e.style.hasLayer(i))continue;const s=this.buckets[i],u=s.layers[0],c=u.sourceLayer||"_geojsonTileLayer",h=e.style.getLayerSourceCache(u),d=s.layers.some(e=>l.has(e.fqid)),p=(n||d)&&s instanceof Ym?e.style.getOwnLayer(i):void 0;let f=r&&r[c]||{};h&&!r&&(f=h._state.getState(c,void 0));const m=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},y=Object.keys(f).length>0&&!t;s.hasAppearances=s.layers.some(e=>e.appearances&&e.appearances.length>0);const g=y?s.stateDependentLayers:s.layers;if(y&&0!==s.stateDependentLayers.length||t||d||n){const r=this.latestFeatureIndex.loadVTLayers()[c];if(s.update(f,r,a,m,g,t,o,this.tileID.canonical),(n||d)&&(!t||t&&s instanceof Ym&&(!s.text.uboBinder||s.text.uboBinder.isLightConstant||!s.icon.uboBinder||s.icon.uboBinder.isLightConstant))&&s instanceof Ym&&p&&"symbol"===p.type){const e=s;e.text&&e.text.uboBinder&&e.text.uboBinder.updateDynamicExpressions(p,r,this.tileID.canonical,a,f,o),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.updateDynamicExpressions(p,r,this.tileID.canonical,a,f,o);}if(s instanceof Ym){const t=s,r=e.context;t.text&&t.text.uboBinder&&t.text.uboBinder.upload(r),t.icon&&t.icon.uboBinder&&t.icon.uboBinder.upload(r);}}if(y&&0!==s.stateDependentLayers.length||t||s.hasAppearances){const t={zoom:e.transform.zoom,pitch:e.transform.pitch,brightness:e.style.getBrightness()||0,worldview:e.worldview},r=s.updateAppearances(this.tileID.canonical,f,a,t,e.imageManager,y&&0!==s.stateDependentLayers.length);if(r&&r.hasUboChanges){const t=e.context;s instanceof Ym&&s.text&&s.text.uboBinder&&s.text.uboBinder.upload(t),s instanceof Ym&&s.icon&&s.icon.uboBinder&&s.icon.uboBinder.upload(t);}}(s instanceof Bh||s instanceof Ec)&&e._terrain&&e._terrain.enabled&&h&&s.uploadPending()&&e._terrain._clearRenderCacheForTile(h.id,this.tileID);const x=e&&e.style&&e.style.getOwnLayer(i);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(s)||0));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,r=Gw[t+0],n=Gw[t+1],i=Gw[t+2],s=Gw[t+3],a=r+i>>1,o=n+s>>1,l=a+o-n,u=o+r-a,c=n*jw+r,h=s*jw+i,d=o*jw+a,p=Math.hypot(($w[2*c+0]+$w[2*h+0])/2-$w[2*d+0],($w[2*c+1]+$w[2*h+1])/2-$w[2*d+1])>=16;qw[d]=qw[d]||(p?1:0),e<1022&&(qw[d]=qw[d]||qw[(n+u>>1)*jw+(r+l>>1)]||qw[(s+u>>1)*jw+(i+l>>1)]);}const i=new Ql,s=new bu;let a=0;function o(e,t){const r=t*jw+e;return 0===Hw[r]&&(i.emplaceBack($w[2*r+0],$w[2*r+1],e*Xn/Nw,t*Xn/Nw),Hw[r]=++a),Hw[r]-1}function l(e,t,r,n,i,a){const u=e+r>>1,c=t+n>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&qw[c*jw+u])l(i,a,e,t,u,c),l(r,n,i,a,u,c);else {const l=o(e,t),u=o(r,n),c=o(i,a);s.emplaceBack(l,u,c);}}return l(0,0,Nw,Nw,Nw,0),l(Nw,Nw,0,0,0,Nw),{vertices:i,indices:s}}(this.tileID.canonical,t);n=e.vertices,i=e.indices;}else {n=new Ql,i=new bu;for(const{x:e,y:t}of r)n.emplaceBack(e,t,0,0);const e=No(n.int16.subarray(0,4*n.length),void 0,4);for(let t=0;t0&&(a=h(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,n,t,i,a,s),this._makeGlobeTileDebugTextBuffer(e,n,t,i,a,s);}_globePoint(e,t,r,n,i,s,a){let o=Rf(e,t,r);if(s){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/Xn+r.x)/i+h,p=(t/Xn+r.y)/i;d=(d-l)*n._pixelsPerMercatorPixel+l,p=(p-u)*n._pixelsPerMercatorPixel+u;const f=[d*n.worldSize,p*n.worldSize,0];$(f,f,s),o=Ef(o,f,a);}return $(o,o,i)}_makeGlobeTileDebugBorderBuffer(e,t,r,n,i,s){const a=new Kl,o=new Pu,l=new Jl,u=(e,u,c,h,d)=>{const p=(c-e)/(d-1),f=(h-u)/(d-1),m=a.length;for(let c=0;cu*e+t;for(let e=0;e0?Math.acos(r/n)*Oe:0;let s=0!==e||0!==t?Math.atan2(-t,-e)*Oe+90:0;return s<0&&(s+=360),[n,s,i]},t.bC=Kb,t.bD=(e,t,r,n,i,s)=>{const a=e.transform,o="globe"===a.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(o){const e=Gf(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=a.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(a.projection),u_matrix:e.translatePosMatrix(t.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Tt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Yb,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[t.canonical.x,t.canonical.y,1<({u_camera_to_center_distance:new lc(e),u_extrude_scale:new mc(e),u_device_pixel_ratio:new lc(e),u_matrix:new fc(e),u_inv_rot_matrix:new fc(e),u_merc_center:new uc(e),u_tile_id:new cc(e),u_zoom_transition:new lc(e),u_up_dir:new cc(e),u_emissive_strength:new lc(e)}),t.bF=Bl,t.bG=Ze,t.bH=function(e){const t=jt();if(!t)return;const r=t.delete(Rt);e&&r.then(()=>e()).catch(e);},t.bI=dh,t.bJ=u,t.bK=M,t.bL=st,t.bM=Gh,t.bN=Pt,t.bO=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.bP=It,t.bQ=Ix,t.bR=Qg,t.bS=function(e,t){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.bT=l,t.bU=I,t.bV=s,t.bW=re,t.bX=J,t.bY=Hs,t.bZ=go,t.b_=Wl,t.ba=class extends ac{constructor(e){super(e),this.current=new Float32Array(9);}set(e,t,r){if(!this.fetchUniformLocation(e,t))return;const n=this.current;for(let e=0;e<9;e++)if(r[e]!==n[e]){n.set(r),this.gl.uniformMatrix3fv(this.location,!1,n);break}}},t.bb=fc,t.bc=Qf,t.bd=ap,t.be=qc,t.bf=Nc,t.bg=vd,t.bh=Zs,t.bi=Ff,t.bj=P,t.bk=fe,t.bl=qm,t.bm=function(e,t){if(!e||!t)throw new Error("TileProvider name and URL are required");Pt.TILE_PROVIDER_URLS[e]=Tt.resolveURL(t);},t.bn=Pl,t.bo=Br,t.bp=Ke,t.bq=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},t.br=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},t.bs=rt,t.bt=Hv,t.bu=function(e,t){const r=[];for(let n=0;nOt&&(e.getActor().send("enforceCacheSizeLimit",Lt),$t=0);},t.bw=function(e,t){const{x:r,y:n}=e.point,i=$f(r,n,e.worldSize/e._pixelsPerMercatorPixel,0,0);return d(i,i,Nf(zf(t)))},t.bx=function(e){const{x:t,y:r}=e.point,{lng:n,lat:i}=e._center;return $f(t,r,e.worldSize,n,i)},t.by=function(e){const t=e.pixelsPerMeter,r=t/Tl(1,e.center.lat),n=c(new Float64Array(16));return p(n,n,[e.point.x,e.point.y,0]),f(n,n,[r,r,t]),Float32Array.from(n)},t.bz=tm,t.c=rp,t.c$=Mm,t.c0=function(e,t,r,n){return "custom"===e.type?new lw(e,t):new Vw[e.type](e,t,r,n)},t.c1=j,t.c2=Ae,t.c3=mo,t.c4=Ge,t.c5=C,t.c6=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e},t.c7=N,t.c8=No,t.c9=Al,t.cA=function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.cB=function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.cC=function(e){const t=Math.round((e+45+360)%360/90)%4;return qe[t]},t.cD=function(e,t,r){let n=0;for(let r=0;r<2;++r){const i=0;e[r]>i&&(n+=(e[r]-i)*(e[r]-i)),t[r]r?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),n},t.cI=function(e){let t=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of e)t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {min:new _e(t,r),max:new _e(n,i)}},t.cJ=function(){return {API_URL:Pt.API_URL,DRACO_URL:Pt.DRACO_URL,MESHOPT_URL:Pt.MESHOPT_URL,MESHOPT_SIMD_URL:Pt.MESHOPT_SIMD_URL,BUILDING_GEN_URL:Pt.BUILDING_GEN_URL}},t.cK=kt,t.cL=wt,t.cM=function(e,t){return ir(Object.assign(e,{method:"GET"}),t)},t.cN=zt,t.cO=function(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}},t.cP=function(e,t,r,n){const i=t.getNorth(),s=t.getSouth(),a=t.getWest(),l=t.getEast(),u=1<0){const e=180/n;o(f,f,[e/c+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1]);}return f[2]=u,f[5]=e.x,f[8]=e.y,f},t.cQ=cr,t.cR=lp,t.cS=function(e){const t=e.lastIndexOf(Po);return t>=0?e.slice(t+1):""},t.cT=sr,t.cU=function(e){const t=80.051129;e=Ze(e,-80.051129,t)/t*90;const r=Math.pow(Math.abs(Math.sin(Ge(e))),3);return Math.round(r*(xl.length-1))},t.cV=ri,t.cW=Et,t.cX=kl,t.cY=function(e){const t=e.indexOf(Po);return t>=0?e.slice(0,t):e},t.cZ=Eo,t.c_=function(e,t){const{scale:r}=e.tileTransform,n=r*Xn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z)),i=t.inverseAdjustmentMatrix;return new Float32Array([i[0]*n,i[1]*n,i[2]*n,i[3]*n])},t.ca=Xe,t.cb=He,t.cc=function(e){return e*e*e*e*e},t.cd=function([e,t,r]){const n=Math.hypot(e,t,r),i=Math.atan2(e,r),s=.5*Math.PI-Math.acos(-t/n);return new Ml($e(i),$e(s))},t.ce=sh,t.cf=function(e){Gt(),null!=Nt&&Nt.then(t=>{t.keys().then(r=>{for(let n=0;nlt(e.message));}).catch(e=>lt(e.message));}).catch(e=>lt(e.message));},t.cg=function(e){return e>>>=0,e=Math.imul(2747636419^e,2654435769)>>>0,e=Math.imul(e^e>>>16,2654435769)>>>0,(e=Math.imul(e^e>>>16,2654435769)>>>0)/4294967296},t.ch=Nd,t.ci=jd,t.cj=Op,t.ck=Za,t.cl=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},t.cm=Z,t.cn=qt,t.co=Tt,t.cp=eg,t.cq=Mb,t.cr=it,t.cs=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},t.ct=_,t.cu=function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=-r,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},t.cv=b,t.cw=x,t.cx=B,t.cy=function(e,t,r,i){var s=new n(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s},t.cz=de,t.d=256,t.d$=Tv,t.d0=function(e){const t=$g(e,!0);return i([],[t[0],t[1],t[4],t[5]])},t.d1=$g,t.d2=Hg,t.d3=Wa,t.d4=tr,t.d5=function(e,t){var r=new n(3);w(r,t);var i=1/r[0],s=1/r[1],a=1/r[2],o=t[0]*i,l=t[1]*s,u=t[2]*a,c=t[4]*i,h=t[5]*s,d=t[6]*a,p=t[8]*i,f=t[9]*s,m=t[10]*a,y=o+h+m,g=0;return y>0?(g=2*Math.sqrt(y+1),e[3]=.25*g,e[0]=(d-f)/g,e[1]=(p-u)/g,e[2]=(l-c)/g):o>h&&o>m?(g=2*Math.sqrt(1+o-h-m),e[3]=(d-f)/g,e[0]=.25*g,e[1]=(l+c)/g,e[2]=(p+u)/g):h>m?(g=2*Math.sqrt(1+h-o-m),e[3]=(p-u)/g,e[0]=(l+c)/g,e[1]=.25*g,e[2]=(d+f)/g):(g=2*Math.sqrt(1+m-o-h),e[3]=(l-c)/g,e[0]=(p+u)/g,e[1]=(d+f)/g,e[2]=.25*g),e},t.d6=qg,t.d7=w,t.d8=im,t.d9=function(e,t,r=0){return B(((t.x-r)*e.scale-e.x)*Xn,(t.y*e.scale-e.y)*Xn,Pl(t.z,t.y))},t.dA=function(){return !!document.fullscreenElement||!!document.webkitFullscreenElement},t.dB=Cs,t.dC=_i,t.dD=er,t.dE=Xf,t.dF=function(e){return Pt.API_CDN_URL_REGEX.test(e)},t.dG=function(e){return Pt.API_FONTS_REGEX.test(e)},t.dH=Ft,t.dI=function(e){return Pt.API_STYLE_REGEX.test(e)&&!Ft(e)},t.dJ=function(e){return Pt.API_TILEJSON_REGEX.test(e)},t.dK=Vt,t.dL=function(e){return 0===e.indexOf("mapbox:")},t.dM=pn,t.dN=hn,t.dO=function(e){const t=e.navigator?e.navigator.userAgent:null;return !!function(e){if(null==vt){const t=e.navigator?e.navigator.userAgent:null;vt=!!e.safari||!(!t||!(Ne.test(t)||t.match("Safari")&&!t.match("Chrome")));}return vt}(e)&&!(!t||!(t.match("Version/15.4")||t.match("Version/15.5")||t.match(je)))},t.dP=wi,t.dQ=dn,t.dR=ht,t.dS=function(e,t){const r=[];for(const n in e)n in t||r.push(n);return r},t.dT=Mn,t.dU=_l,t.dV=K,t.dW=S,t.dX=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)},t.dY=wr,t.dZ=G,t.d_=function(e,t,r,n){var i=t[0],s=t[1],a=t[2],o=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e[3]=o+n*(r[3]-o),e},t.da=cn,t.db=function(e,t){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r);};for(let t=0;t{}}},t.dc=Zg,t.dd=function(e){const t=[0,0,0],r=c(new Float64Array(16));return d(r,e.pixelMatrix,e.globeMatrix),$(t,t,r),new _e(t[0],t[1])},t.de=Nf,t.df=function(e,t){const r=[0,0,0];return $(r,r,Uf(zf(t.canonical))),$(r,r,e),r},t.dg=Mf,t.dh=Uf,t.di=Gf,t.dj=function(e,t,r){const n=c(new Float64Array(16)),i=(t/(1<0;return 0===n&&!i&&!s},t.dp=ne,t.dq=c,t.dr=h,t.ds=i,t.dt=function(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=c*a-o*u,d=-c*s+o*l,p=u*s-a*l,f=r*h+n*d+i*p;return f?(e[0]=h*(f=1/f),e[1]=(-c*n+i*u)*f,e[2]=(o*n-i*a)*f,e[3]=d*f,e[4]=(c*r-i*l)*f,e[5]=(-o*r+i*s)*f,e[6]=p*f,e[7]=(-u*r+n*l)*f,e[8]=(a*r-n*s)*f,e):null},t.du=fn,t.dv=qs,t.dw=yo,t.dx=function(e){return e.includes(Po)},t.dy=vi,t.dz=function(e,t){const r=eg(e);return null!==r&&!!(t&1<{const c=e.transform,h=c.pitch<15?wr(.07,.7,Ze((14-c.zoom)/5,0,1)):.07,d="none"===r.paint.get("line-trim-color-use-theme").constantOr("default");return {u_matrix:Bv(e,t,r,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_width_scale:s,u_floor_width_scale:a,u_image:0,u_tile_units_to_pixels:Sv(t,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:r.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:Fl(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:u,u_opacity_multiplier:1}},t.e1=e=>({u_matrix:new fc(e),u_texsize:new uc(e),u_pixels_to_tile_units:new mc(e),u_device_pixel_ratio:new lc(e),u_width_scale:new lc(e),u_floor_width_scale:new lc(e),u_image:new oc(e),u_units_to_pixels:new uc(e),u_tile_units_to_pixels:new lc(e),u_alpha_discard_threshold:new lc(e),u_trim_offset:new uc(e),u_trim_fade_range:new uc(e),u_trim_gradient_mix_range:new uc(e),u_trim_color:new dc(e),u_zbias_factor:new lc(e),u_tile_to_meter:new lc(e),u_ground_shadow_factor:new cc(e),u_pattern_transition:new lc(e),u_opacity_multiplier:new lc(e)}),t.e2=(e,t,r,n,i,s,a,o,l,u)=>{const c=e.transform,h=c.calculatePixelsToTileUnitsMatrix(t),d="none"===r.paint.get("line-trim-color-use-theme").constantOr("default"),p=c.pitch<15?wr(.07,.7,Ze((14-c.zoom)/5,0,1)):.07;return {u_matrix:Bv(e,t,r,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:s,u_width_scale:a,u_floor_width_scale:o,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Pv(r)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Sv(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:r.lut).toArray01(),u_zbias_factor:p,u_tile_to_meter:Fl(t.tileID.canonical,0),u_ground_shadow_factor:u,u_opacity_multiplier:1}},t.e3=e=>({u_matrix:new fc(e),u_pixels_to_tile_units:new mc(e),u_device_pixel_ratio:new lc(e),u_width_scale:new lc(e),u_floor_width_scale:new lc(e),u_units_to_pixels:new uc(e),u_dash_image:new oc(e),u_gradient_image:new oc(e),u_image_height:new lc(e),u_texsize:new uc(e),u_tile_units_to_pixels:new lc(e),u_alpha_discard_threshold:new lc(e),u_trim_offset:new uc(e),u_trim_fade_range:new uc(e),u_trim_gradient_mix_range:new uc(e),u_trim_color:new dc(e),u_zbias_factor:new lc(e),u_tile_to_meter:new lc(e),u_ground_shadow_factor:new cc(e),u_opacity_multiplier:new lc(e)}),t.e4=function(e){return [Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},t.e5=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Bg){const r=new Uint32Array(e,0,7),[,,n,i,s,a]=r;t=r.byteLength+i+s+a+s,(n!==e.byteLength||t>=e.byteLength)&<("Invalid b3dm header information.");}return Vg(e,t)},t.e6=Fg,t.e7=function(e,t,r,n,i){const s=function(r,n){if(r)return i(r);if(n){e.url&&n.tiles&&e.tiles&&delete e.tiles;const r=j_(e,n,t);if(r instanceof Error)return i(r);i(null,r);}},a=function(e,t,r){if(!e)return null;if(!t&&!r)return e;r=r||e.worldview_default;const n=Object.values(e.language||{});if(0===n.length)return null;const i=Object.values(e.worldview||{});if(0===i.length)return null;const s=n.every(e=>e===t),a=i.every(e=>e===r);return s&&a?e:t in(e.language_options||{})||r in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(e.data,r,n);return a?Tt.frame(()=>s(null,a)):e.url?sr(t.transformRequest(t.normalizeSourceURL(e.url,null,r,n),Jt.Source),s):Tt.frame(()=>{const{data:t,...r}=e;s(null,r);})},t.e8=async function(e,t){const r=$_.get(e);if(r)return r;const n=G_.get(e);if(void 0!==n)return n;const i=import( +define(["require","exports"],function(e,t){var r=1e-6,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*s-i*n;return a?(e[0]=s*(a=1/a),e[1]=-n*a,e[2]=-i*a,e[3]=r*a,e):null}function s(){var e=new n(9);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function a(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=r[0],p=r[1],f=r[2],m=r[3],y=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return e[0]=d*n+p*a+f*u,e[1]=d*i+p*o+f*c,e[2]=d*s+p*l+f*h,e[3]=m*n+y*a+g*u,e[4]=m*i+y*o+g*c,e[5]=m*s+y*l+g*h,e[6]=x*n+v*a+b*u,e[7]=x*i+v*o+b*c,e[8]=x*s+v*l+b*h,e}function o(){var e=new n(16);return n!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function l(e){var t=new n(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function c(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],y=t[14],g=t[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,M=c*m-h*f,I=c*y-d*f,S=c*g-p*f,B=h*y-d*m,E=h*g-p*m,P=d*g-p*y,z=x*P-v*E+b*B+w*S-_*I+A*M;return z?(e[0]=(o*P-l*E+u*B)*(z=1/z),e[1]=(i*E-n*P-s*B)*z,e[2]=(m*A-y*_+g*w)*z,e[3]=(d*_-h*A-p*w)*z,e[4]=(l*S-a*P-u*I)*z,e[5]=(r*P-i*S+s*I)*z,e[6]=(y*b-f*A-g*v)*z,e[7]=(c*A-d*b+p*v)*z,e[8]=(a*E-o*S+u*M)*z,e[9]=(n*S-r*E-s*M)*z,e[10]=(f*_-m*b+g*x)*z,e[11]=(h*b-c*_-p*x)*z,e[12]=(o*I-a*B-l*M)*z,e[13]=(r*B-n*I+i*M)*z,e[14]=(m*v-f*w-y*x)*z,e[15]=(c*w-h*v+d*x)*z,e):null}function h(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],y=t[13],g=t[14],x=t[15],v=r[0],b=r[1],w=r[2],_=r[3];return e[0]=v*n+b*o+w*h+_*m,e[1]=v*i+b*l+w*d+_*y,e[2]=v*s+b*u+w*p+_*g,e[3]=v*a+b*c+w*f+_*x,e[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*m,e[5]=v*i+b*l+w*d+_*y,e[6]=v*s+b*u+w*p+_*g,e[7]=v*a+b*c+w*f+_*x,e[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*m,e[9]=v*i+b*l+w*d+_*y,e[10]=v*s+b*u+w*p+_*g,e[11]=v*a+b*c+w*f+_*x,e[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*m,e[13]=v*i+b*l+w*d+_*y,e[14]=v*s+b*u+w*p+_*g,e[15]=v*a+b*c+w*f+_*x,e}function d(e,t,r){var n,i,s,a,o,l,u,c,h,d,p,f,m=r[0],y=r[1],g=r[2];return t===e?(e[12]=t[0]*m+t[4]*y+t[8]*g+t[12],e[13]=t[1]*m+t[5]*y+t[9]*g+t[13],e[14]=t[2]*m+t[6]*y+t[10]*g+t[14],e[15]=t[3]*m+t[7]*y+t[11]*g+t[15]):(i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=i,e[2]=s,e[3]=a,e[4]=o,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+o*y+h*g+t[12],e[13]=i*m+l*y+d*g+t[13],e[14]=s*m+u*y+p*g+t[14],e[15]=a*m+c*y+f*g+t[15]),e}function p(e,t,r){var n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function f(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[4],a=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+u*n,e[5]=a*i+c*n,e[6]=o*i+h*n,e[7]=l*i+d*n,e[8]=u*i-s*n,e[9]=c*i-a*n,e[10]=h*i-o*n,e[11]=d*i-l*n,e}function m(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-u*n,e[1]=a*i-c*n,e[2]=o*i-h*n,e[3]=l*i-d*n,e[8]=s*n+u*i,e[9]=a*n+c*i,e[10]=o*n+h*i,e[11]=l*n+d*i,e}function y(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=s*i+u*n,e[1]=a*i+c*n,e[2]=o*i+h*n,e[3]=l*i+d*n,e[4]=u*i-s*n,e[5]=c*i-a*n,e[6]=h*i-o*n,e[7]=d*i-l*n,e}function g(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function x(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function v(e,t,n){var i,s,a,o=n[0],l=n[1],u=n[2],c=Math.sqrt(o*o+l*l+u*u);return c0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function U(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function N(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[0],o=r[1],l=r[2];return e[0]=i*l-s*o,e[1]=s*a-n*l,e[2]=n*o-i*a,e}function j(e,t,r,n){var i=t[0],s=t[1],a=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e}function G(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,e}function $(e,t,r){var n=r[0],i=r[1],s=r[2],a=r[3],o=t[0],l=t[1],u=t[2],c=i*u-s*l,h=s*o-n*u,d=n*l-i*o;return e[0]=o+a*(c+=c)+i*(d+=d)-s*(h+=h),e[1]=l+a*h+s*c-n*d,e[2]=u+a*d+n*h-i*c,e}function H(e){return e[0]=0,e[1]=0,e[2]=0,e}function q(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var X=P,Z=z,W=I;function Y(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function K(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function J(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*r+n*n+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=i*a,e[3]=s*a,e}function Q(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*a,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*a,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*a,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*a,e}function ee(){var e=new n(4);return n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function te(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function re(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+a*o,e[1]=i*l+s*o,e[2]=s*l-i*o,e[3]=a*l-n*o,e}function ne(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l-s*o,e[1]=i*l+a*o,e[2]=s*l+n*o,e[3]=a*l-i*o,e}A(),Y();var ie,se,ae,oe=J,le=(ie=A(),se=S(1,0,0),ae=S(0,1,0),function(e,t,r){var n=U(t,r);return n<-.999999?(N(ie,se,t),W(ie)<1e-6&&N(ie,ae,t),O(ie,ie),function(e,t,r){r*=.5;var n=Math.sin(r);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r);}(e,ie,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(N(ie,t,r),e[0]=ie[0],e[1]=ie[1],e[2]=ie[2],e[3]=1+n,oe(e,e))});function ue(){var e=new n(2);return n!=Float32Array&&(e[0]=0,e[1]=0),e}function ce(e,t){var r=new n(2);return r[0]=e,r[1]=t,r}function he(e,t,r){return e[0]=t,e[1]=r,e}function de(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function pe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function fe(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function me(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function ye(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function ge(e,t){return e[0]*t[0]+e[1]*t[1]}ee(),ee(),s();var xe=pe;function ve(e,t,r,n){const i=3*e,s=3*(r-e)-i,a=1-i-s,o=3*t,l=3*(n-t)-o,u=1-o-l;return function(e,t=1e-6){if(e<=0)return 0;if(e>=1)return 1;let r=e;for(let n=0;n<8;n++){const n=((a*r+s)*r+i)*r-e;if(Math.abs(n)o?n=r:c=r,r=.5*(n+c);}return ((u*r+l)*r+o)*r}}function be(e,t){this.x=e,this.y=t;}function we(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return !1;for(let r=0;rr;){if(n-r>600){const s=n-r+1,a=t-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);_e(e,t,Math.max(r,Math.floor(t-a*l/s+u)),Math.min(n,Math.floor(t+(s-a)*l/s+u)),i);}const s=e[t];let a=r,o=n;for(Ae(e,r,t),i(e[n],s)>0&&Ae(e,r,n);a0;)o--;}0===i(e[r],s)?Ae(e,r,o):(o++,Ae(e,o,n)),o<=t&&(r=o+1),t<=o&&(n=o-1);}}function Ae(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function Me(e,t){return et?1:0}function Ie(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i1)for(let e=0;e=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ze(e,t,r){const n=e[0]-t[0],i=e[1]-t[1],s=e[0]-r[0],a=e[1]-r[1];return n*a-s*i===0&&n*s<=0&&i*a<=0}function Te(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function Ve(e,t,r=!1){let n=!1;for(let i=0,s=t.length;i0&&o<0||a<0&&o>0}function ke(e,t,r,n){return 0!==(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*s[0]&&!(!Fe(e,t,r,n)||!Fe(r,n,e,t));var i,s;}function Ce(e){const t=new be(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new be(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),r.x=1)return 1;const t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}const Ge=ve(.25,.1,.25,1);function $e(e,t,r){return Math.min(r,Math.max(t,e))}function He(e,t,r){return (r=$e((r-e)/(t-e),0,1))*r*(3-2*r)}function qe(e,t,r){const n=r-t,i=((e-t)%n+n)%n+t;return i===t?r:i}function Xe(e,t,r){if(!e.length)return r(null,[]);let n=e.length;const i=new Array(e.length);let s=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(s=e),i[a]=t,0===--n&&r(s,i);});});}function Ze(e,t){const r={};for(let n=0;n{t[e]&&(t[e]=t[e].bind(t));});}function Je(e,t,r){const n={};for(const r in e)n[r]=t.call(this,e[r],r,e);return n}function Qe(e,t,r){const n={};for(const r in e)t.call(this,e[r],r,e)&&(n[r]=e[r]);return n}function et(e){return Array.isArray(e)?e.map(et):"object"==typeof e&&e?Je(e,et):e}function tt(e,t){for(let r=0;r(t.y-e.y)*(r.x-e.x)}function st([e,t,r]){const n=Oe(t+90),i=Oe(r);return {x:e*Math.cos(n)*Math.sin(i),y:e*Math.sin(n)*Math.sin(i),z:e*Math.cos(i),azimuthal:t,polar:r}}function at(e){return ("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function ot(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,n,i)=>{const s=n||i;return t[r]=!s||s.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e;}return t}function lt(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function ut(e){return e>0?1/(1.001-e):1+e}function ct(e){return e>0?1-1/(1.001-e):-e}function ht(e,t,r){return (e-t.min)*(r.max-r.min)/(t.max-t.min)+r.min}let dt,pt,ft,mt,yt,gt;function xt(){return null==dt&&(dt=self.OffscreenCanvas&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),dt}const vt={requestIdleCallback:e=>{if("undefined"!=typeof requestIdleCallback)return requestIdleCallback(e);setTimeout(()=>e({didTimeout:!1,timeRemaining:()=>50}),0);},now:()=>void 0!==mt?mt:performance.now(),setNow(e){mt=e;},restoreNow(){mt=void 0;},frame(e){const t=requestAnimationFrame(e);return {cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:n}=e;yt||(yt=document.createElement("canvas"));const i=yt.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>yt.width||n>yt.height)&&(yt.width=r,yt.height=n),i.clearRect(-t,-t,r+2*t,n+2*t),i.drawImage(e,0,0,r,n),i.getImageData(-t,-t,r+2*t,n+2*t)},resolveURL:e=>(pt||(pt=document.createElement("a")),pt.href=e,pt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==ft&&(ft=window.matchMedia("(prefers-reduced-motion: reduce)")),ft.matches)},hasCanvasFingerprintNoise(){if(void 0!==gt)return gt;if(!xt())return gt=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n0?`?${s}`:""}`}zt.document&&(Bt=zt.document.createElement("img"),Bt.onload=function(){St&&Tt(St),St=null,Pt=!0;},Bt.onerror=function(){Et=!0,St=null;},Bt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const kt="mapbox-tiles";let Ct=500,Dt=50;const Rt=["language","worldview","jobid"];let Lt;function Ot(){try{return caches}catch(e){}}function Ut(){const e=Ot();e&&null==Lt&&(Lt=e.open(kt));}let Nt=1/0;function jt(e){return wt.API_URL_REGEX.test(e)}function Gt(e){return wt.API_SPRITE_REGEX.test(e)}const $t={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze($t);class Ht extends Error{constructor(e,t,r){super(),this.url=r,this.statusText=e,this.status=t;}get message(){return 401===this.status&&jt(this.url)?`${this.statusText}: you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/guides/#access-tokens-and-token-scopes`:this.statusText}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}function qt(e){return "object"==typeof e&&null!==e&&"status"in e&&404===e.status}const Xt=at()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,Zt=/^\w+:/,Wt=/[\r\n]+/;async function Yt(e,t){let r;return r="arrayBuffer"===e.type?await t.arrayBuffer():"json"===e.type?await t.json():await t.text(),{data:r,headers:t.headers}}async function Kt(e,t){return t&&t.throwIfAborted(),(r=e.url).startsWith("file:")||Xt().startsWith("file:")&&!Zt.test(r)?async function(e,t){return new Promise((r,n)=>{const i=new XMLHttpRequest,s=()=>{t.removeEventListener("abort",s),i.abort(),n(t.reason);};t&&t.addEventListener("abort",s),i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t&&t.removeEventListener("abort",s),n(new Error(i.statusText));},i.onload=()=>{if(t&&t.removeEventListener("abort",s),(i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let t=i.response;if("json"===e.type)try{t=JSON.parse(i.response);}catch(e){return void n(e)}const s=new Headers;i.getAllResponseHeaders().trim().split(Wt).forEach(e=>{const t=e.split(": "),r=t.shift(),n=t.join(": ");r&&s.set(r,n);}),r({data:t,headers:s});}else n(new Ht(i.statusText,i.status,e.url));},i.send(e.body);})}(e,t):async function(e,t){const r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Xt(),referrerPolicy:e.referrerPolicy,signal:t}),n=(i=r.url).indexOf("sku=")>0&&jt(i);var i;if("json"===e.type&&r.headers.set("Accept","application/json"),n){let n=null;try{n=await async function(e){if(Ut(),null==Lt)return null;const t=await Lt;let r=Ft(e.url,{persistentParams:Rt});const n=e.headers.get("Range");n&&(r=Vt(r,{range:n}));const i=await t.match(r);if(!i)return null;const s=function(e){if(!e)return !1;const t=new Date(e.headers.get("expires")||0),r=ot(e.headers.get("cache-control")||"");return Number(t)>Date.now()&&!r["no-cache"]}(i);return t.delete(r).catch(e=>nt(e.message)),s&&t.put(r,i.clone()).catch(e=>nt(e.message)),{response:i,fresh:s}}(r);}catch(e){"SecurityError"!==e.message&&nt(e.toString());}if(n&&n.fresh)return t&&t.throwIfAborted(),Yt(e,n.response)}const s=Date.now();let a;try{a=await fetch(r);}catch(t){if("AbortError"===t.name)throw t;throw new Error(`${t.message} ${e.url}`,{cause:t})}if(t&&t.throwIfAborted(),!a.ok)throw new Ht(a.statusText,a.status,e.url);const o=n?a.clone():null,l=await Yt(e,a);return o&&async function(e,t,r){if(Ut(),null==Lt)return;const n=ot(t.headers.get("cache-control")||"");if(n["no-store"])return;const i={status:t.status,statusText:t.statusText,headers:new Headers(t.headers)};n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const s=i.headers.get("expires");if(!s)return;if(new Date(s).getTime()-r<42e4)return;let a=Ft(e.url,{persistentParams:Rt});if(206===t.status){const t=e.headers.get("Range");if(!t)return;i.status=200,a=Vt(a,{range:t});}const o=new Response(200!==(l=t.status)&&404!==l&&[101,103,204,205,304].includes(l)?null:t.body,i);var l;if(Ut(),null!=Lt)try{const e=await Lt;await e.put(a,o);}catch(e){nt(e.message);}}(r,o,s),l}(e,t);var r;}async function Jt(e,t){return Kt(Object.assign(e,{type:"json"}),t)}async function Qt(e,t){return Kt(Object.assign(e,{type:"arrayBuffer"}),t)}function er(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}let tr,rr;function nr(e,t=0){const r=3432918353,n=461845907,i=e.length,s=i-(3&i);let a,o=0|t,l=0;for(;l>>17,a=Math.imul(a,n),o^=a,o=o<<13|o>>>19,o=Math.imul(o,5)+3864292196|0;a=0;const u=3&i;return u>0&&(u>=3&&(a^=(255&e.charCodeAt(l+2))<<16),u>=2&&(a^=(255&e.charCodeAt(l+1))<<8),a^=255&e.charCodeAt(l),a=Math.imul(a,r),a=a<<15|a>>>17,a=Math.imul(a,n),o^=a),o^=i,o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),o^=o>>>16,o>>>0}tr=[],rr=0;class ir{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e;}}class sr extends ir{constructor(e,t={}){super("error",{error:e,...t});}}function ar(e,t,r){r[e]&&r[e].includes(t)||(r[e]=r[e]||[],r[e].push(t));}function or(e,t,r){if(r&&r[e]){const n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1);}}class lr{on(e,t){return this._listeners=this._listeners||{},ar(e,t,this._listeners),this}off(e,t){return or(e,t,this._listeners),or(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},ar(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t);})}fire(e,t){const r="string"==typeof e?new ir(e,t):e,n=r.type;if(this.listens(n)){r.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,r);const t=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)or(n,e,this._oneTimeListeners),e.call(this,r);const i=this._eventedParent;if(i){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(r,e),i.fire(r);}}else r instanceof sr&&console.error(r.error);return this}listens(e){return !!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class ur{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId);}static from(e){return new ur(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,r]=e.split("");return new ur({name:t,iconsetId:r})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return ur.toString(this)}serialize(){return {name:this.name,iconsetId:this.iconsetId}}}var cr,hr={},dr=function(){if(cr)return hr;cr=1;var e={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 t(e){return (e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function i(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{hr.parseCSSColor=function(s){var a,o=s.replace(/ /g,"").toLowerCase();if(o in e)return e[o].slice();if("#"===o[0])return 4===o.length?(a=parseInt(o.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===o.length&&(a=parseInt(o.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=o.indexOf("("),u=o.indexOf(")");if(-1!==l&&u+1===o.length){var c=o.substr(0,l),h=o.substr(l+1,u-(l+1)).split(","),d=1;switch(c){case "rgba":if(4!==h.length)return null;d=n(h.pop());case "rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),d];case "hsla":if(4!==h.length)return null;d=n(h.pop());case "hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),y=m<=.5?m*(f+1):m+f-m*f,g=2*m-y;return [t(255*i(g,y,p+1/3)),t(255*i(g,y,p)),t(255*i(g,y,p-1/3)),d];default:return null}}return null};}catch(e){}return hr}();function pr(e,t,r){return e*(1-r)+t*r}const fr=new Map;class mr{constructor(e,t,r,n=1){this.r=e,this.g=t,this.b=r,this.a=n;}static parse(e){if(!e)return;if(e instanceof mr)return e;if("string"!=typeof e)return;const t=fr.get(e);if(t)return t;const r=dr.parseCSSColor(e);if(!r)return;const n=new mr(r[0]/255,r[1]/255,r[2]/255,r[3]);return fr.set(e,n),n}toString(){const{r:e,g:t,b:r,a:n}=this;return `rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new gr(e,t,r,n,i)}toPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new xr(e,t*i,r*i,n*i,i)}clone(){return new mr(this.r,this.g,this.b,this.a)}}class yr{constructor(e,t,r,n,i,s=!1){if(this.premultiplied=!1,this.premultiplied=s,e){const s=e.image.height,a=s*s;this.premultiplied?(t=0===i?0:t/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1)):(t*=s-1,r*=s-1,n*=s-1),t=Math.max(0,Math.min(s-1,t)),r=Math.max(0,Math.min(s-1,r)),n=Math.max(0,Math.min(s-1,n));const o=Math.floor(t),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(t),h=Math.ceil(r),d=Math.ceil(n),p=t-o,f=r-l,m=n-u,y=e.image.data,g=4*(o+l*a+u*s),x=4*(o+l*a+d*s),v=4*(o+h*a+u*s),b=4*(o+h*a+d*s),w=4*(c+l*a+u*s),_=4*(c+l*a+d*s),A=4*(c+h*a+u*s),M=4*(c+h*a+d*s);this.r=pr(pr(pr(y[g],y[x],m),pr(y[v],y[b],m),f),pr(pr(y[w],y[_],m),pr(y[A],y[M],m),f),p)/255*(this.premultiplied?i:1),this.g=pr(pr(pr(y[g+1],y[x+1],m),pr(y[v+1],y[b+1],m),f),pr(pr(y[w+1],y[_+1],m),pr(y[A+1],y[M+1],m),f),p)/255*(this.premultiplied?i:1),this.b=pr(pr(pr(y[g+2],y[x+2],m),pr(y[v+2],y[b+2],m),f),pr(pr(y[w+2],y[_+2],m),pr(y[A+2],y[M+2],m),f),p)/255*(this.premultiplied?i:1),this.a=i;}else this.r=t,this.g=r,this.b=n,this.a=i;}toArray(){const{r:e,g:t,b:r,a:n}=this;return [255*e,255*t,255*r,n]}toHslaArray(){let{r:e,g:t,b:r,a:n}=this;if(this.premultiplied){if(0===n)return [0,0,0,0];const i=1/n;e*=i,t*=i,r*=i;}const i=Math.min(Math.max(e,0),1),s=Math.min(Math.max(t,0),1),a=Math.min(Math.max(r,0),1),o=Math.min(i,s,a),l=Math.max(i,s,a),u=l-o,c=.5*(o+l);if(0===u)return [0,0,100*c,n];const h=c>.5?u/(2-l-o):u/(l+o);let d;switch(l){case i:d=60*((s-a)/u+(spr(e,t[n],r))}mr.black=new mr(0,0,0,1),mr.white=new mr(1,1,1,1),mr.transparent=new mr(0,0,0,0),mr.red=new mr(1,0,0,1),mr.blue=new mr(0,0,1,1);var br=Object.freeze({__proto__:null,array:vr,color:function(e,t,r){return new mr(pr(e.r,t.r,r),pr(e.g,t.g,r),pr(e.b,t.b,r),pr(e.a,t.a,r))},number:pr});class wr extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}class _r{constructor(e,t=[]){this.parent=e,this.bindings=Object.create(null);for(const[e,r]of t)this.bindings[e]=r;}concat(e){return new _r(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return !!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Ar={kind:"null"},Mr={kind:"number"},Ir={kind:"string"},Sr={kind:"boolean"},Br={kind:"color"},Er={kind:"object"},Pr={kind:"value"},zr={kind:"collator"},Tr={kind:"formatted"},Vr={kind:"resolvedImage"};function Fr(e,t){return {kind:"array",itemType:e,N:t}}function kr(e){if("array"===e.kind){const t=kr(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Cr=[Ar,Mr,Ir,Sr,Br,Tr,Er,Fr(Pr),Vr];function Dr(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Dr(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else {if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Cr)if(!Dr(e,t))return null}return `Expected ${kr(e)} but found ${kr(t)} instead.`}function Rr(e,t){return t.some(t=>t.kind===e.kind)}function Lr(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Or(e,t){return "array"===e.kind&&"array"===t.kind?e.N===t.N&&Or(e.itemType,t.itemType):e.kind===t.kind}class Ur{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Nr{constructor(e,t,r,n,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=i;}}class jr{constructor(e){this.sections=e;}static fromString(e){return new jr([new Nr(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof jr?e:jr.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const r=t.image.getPrimary().id.toString();e.push(["image",r]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r);}return e}}class Gr{constructor(e,t={}){this.id=ur.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1;}toString(){return JSON.stringify(this)}static parse(e){let t,r,n,i;try{({id:t,params:r,sx:n,sy:i}=JSON.parse(e)||{});}catch(e){return null}return t?new Gr(t,{params:r,sx:n,sy:i}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class $r{constructor(e,t,r,n,i=!1){this.primaryId=ur.from(e),this.primaryOptions=t,r&&(this.secondaryId=ur.from(r)),this.secondaryOptions=n,this.available=i;}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return !!this.primaryId}getPrimary(){return new Gr(this.primaryId,this.primaryOptions)}hasSecondary(){return !!this.secondaryId}getSecondary(){return this.secondaryId?new Gr(this.secondaryId,this.secondaryOptions):null}static from(e){return "string"==typeof e?$r.build({name:e}):e}static build(e,t,r,n){return !e||"object"==typeof e&&!("name"in e)?null:new $r(e,r,t,n)}}function Hr(e,t,r,n){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function qr(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof mr)return !0;if(e instanceof Ur)return !0;if(e instanceof jr)return !0;if(e instanceof $r)return !0;if(Array.isArray(e)){for(const t of e)if(!qr(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!qr(e[t]))return !1;return !0}return !1}function Xr(e){if(null===e)return Ar;if("string"==typeof e)return Ir;if("boolean"==typeof e)return Sr;if("number"==typeof e)return Mr;if(e instanceof mr)return Br;if(e instanceof Ur)return zr;if(e instanceof jr)return Tr;if(e instanceof $r)return Vr;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=Xr(t);if(r){if(r===e)continue;r=Pr;break}r=e;}return Fr(r||Pr,t)}return Er}function Zr(e){return null===e?"":"string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):e instanceof jr||e instanceof $r||e instanceof mr?e.toString():JSON.stringify(e)}class Wr{constructor(e,t){this.type=e,this.value=t;}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!qr(e[1]))return t.error("invalid value");const r=e[1];let n=Xr(r);const i=t.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Wr(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof mr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof jr?this.value.serialize():this.value}}class Yr{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}}const Kr={string:Ir,number:Mr,boolean:Sr,object:Er};class Jr{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const i=e[0];if("array"===i){let i,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in Kr)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=Kr[r],n++;}else i=Pr;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++;}r=Fr(i,s);}else r=Kr[i];const s=[];for(;ne.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){t.push(r.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n);}}return t.concat(this.args.map(e=>e.serialize()))}}class Qr{constructor(e){this.type=Tr,this.sections=e;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=e.length-1;++r){const s=e[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let e=null;if(s["font-scale"]&&(e=t.parseObjectValue(s["font-scale"],r,"font-scale",Mr),!e))return null;let a=null;if(s["text-font"]&&(a=t.parseObjectValue(s["text-font"],r,"text-font",Fr(Ir)),!a))return null;let o=null;if(s["text-color"]&&(o=t.parseObjectValue(s["text-color"],r,"text-color",Br),!o))return null;const l=n.at(-1);l.scale=e,l.font=a,l.textColor=o;}else {const s=t.parse(e[r],r,Pr);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new Qr(n)}evaluate(e){return new jr(this.sections.map(t=>{const r=t.content.evaluate(e);return Or(Xr(r),Vr)?new Nr("",r,null,null,null):new Nr(Zr(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r);}return e}}class en{constructor(e,t,r,n){this._imageWarnHistory={},this.type=Vr,this.namePrimary=e,this.nameSecondary=t,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0);}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(rur.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>ur.isEqual(e,t)));}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t]);}outputDefined(){return !1}serializeOptions(e,t){const r={};if(t&&(r.iconset={id:t}),e){r.params={};for(const t in e)e[t]&&(r.params[t]=e[t].serialize());}return Object.keys(r).length>0?r:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t);}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t);}return e}}function tn(e){return nn(e)?"string":sn(e)?"number":an(e)?"boolean":Array.isArray(e)?"array":null===e?"null":rn(e)?"object":typeof e}function rn(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function nn(e){return "string"==typeof e||e instanceof String}function sn(e){return "number"==typeof e||e instanceof Number}function an(e){return "boolean"==typeof e||e instanceof Boolean}const on={"to-boolean":Sr,"to-color":Br,"to-number":Mr,"to-string":Ir};class ln{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0],n=[];let i=Ar;if("to-array"===r){if(!Array.isArray(e[1]))return null;const r=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);i=Fr(t.expectedType.itemType,r);}else {if(!(r>0&&qr(e[1][0])))return null;i=Fr(Xr(e[1][0]),r);}for(let s=0;s4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Hr(t[0],t[1],t[2],t[3]),!r))return new mr(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Yr(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Yr(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?jr.fromString(Zr(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?$r.build(Zr(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):Zr(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Qr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new en(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize());}),e}}const un=["Unknown","Point","LineString","Polygon"];class cn{constructor(e,t,r){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=r;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?un[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){return mr.parse(e)}getConfig(e){return this.options?this.options.get(e):null}}class hn{constructor(e,t,r,n,i){this.name=e,this.type=t,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(e){if(!this._evaluate){const e=hn.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1];}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const r=e[0],n=hn.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==e.length-1)continue;a.push(n),l++,null===o?o=t._forkForSignature():o.errors.length=0;const s=[];let c=!1;for(let t=1;te)).map(dn).join(" | "),n=[];for(let r=1;rr[2]){const t=.5*n;let i=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===i&&(i=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=i;}Ee(t,e);}function Bn(e,t,r,n){const i=Math.pow(2,n.z)*xn,s=[n.x*xn,n.y*xn],a=[];if(!e)return a;for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];Sn(n,t,r,i),a.push(n);}return a}function En(e,t,r,n){const i=Math.pow(2,n.z)*xn,s=[n.x*xn,n.y*xn],a=[];if(!e)return a;for(const r of e){const e=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Ee(t,r),e.push(r);}a.push(e);}if(t[2]-t[0]<=i/2){(o=t)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const e of a)for(const n of e)Sn(n,t,r,i);}var o;return a}class Pn{constructor(e,t){this.type=Sr,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(qr(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;eet?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e);}push(e){this.data.push(e),this._up(this.length++);}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return --this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i;}t[e]=n;}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[n],e=n;}t[e]=i;}}var Tn=8192;const Vn=1/298.257223563,Fn=Vn*(2-Vn),kn=Math.PI/180;function Cn(e){const t=6378.137*kn*1e3,r=Math.cos(e*kn),n=1/(1-Fn*(1-r*r)),i=Math.sqrt(n);return [t*i*r,t*i*n*(1-Fn)]}function Dn(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}function Rn(e,t,r,n){const i=Dn(e[0]-t[0])*r,s=(e[1]-t[1])*n;return Math.sqrt(i*i+s*s)}function Ln(e,t,r,n,i){let s=t[0],a=t[1],o=Dn(r[0]-s)*n,l=(r[1]-a)*i;if(0!==o||0!==l){const t=(Dn(e[0]-s)*n*o+(e[1]-a)*i*l)/(o*o+l*l);t>1?(s=r[0],a=r[1]):t>0&&(s+=o/n*t,a+=l/i*t);}return o=Dn(e[0]-s)*n,l=(e[1]-a)*i,Math.sqrt(o*o+l*l)}function On(e,t){return t.dist-e.dist}function Un(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let r=0;r=e[0]&&e[1]e[1])return [null,null];const r=Nn(e);if(t){if(2===r)return [e,null];const t=Math.floor(r/2);return [[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===r)return [e,null];const t=Math.floor(r/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function $n(e,t){const r=[1/0,1/0,-1/0,-1/0];if(!jn(t,e.length))return r;for(let n=t[0];n<=t[1];++n)Ee(r,e[n]);return r}function Hn(e){const t=[1/0,1/0,-1/0,-1/0];for(let r=0;rt[2]&&(i=e[0]-t[2]),e[1]>t[3]&&(s=e[1]-t[3]),e[3]1?(l=e[o+1][0],u=e[o+1][1]):d>0&&(l+=c/r*d,u+=h/n*d)),c=Dn(t[0]-l)*r,h=(t[1]-u)*n;const p=c*c+h*h;p=i)return i;if(Pe(s,a)){if(ri(e,t))return 0}else if(ri(t,e))return 0;let o=i;for(const i of e)for(let e=0,s=i.length,a=s-1;e=a)continue;const c=s.range1;if(Nn(c)<=l){if(!jn(c,e.length))return NaN;if(t){const t=ti(e,c,r,n,i);if(0===(a=Math.min(a,t)))return a}else for(let t=c[0];t<=c[1];++t){const s=ei(e[t],r,n,i);if(0===(a=Math.min(a,s)))return a}}else {const r=Gn(c,t);if(null!==r[0]){const t=qn($n(e,r[0]),u,n,i);t=o)continue;const h=a.range1,d=a.range2;if(Nn(h)<=u&&Nn(d)<=c){if(!jn(h,e.length)||!jn(d,r.length))return NaN;if(t&&n?o=Math.min(o,Jn(e,h,r,d,i,s)):t||n?t&&!n?o=Math.min(o,Yn(r,d,e,h,i,s)):!t&&n&&(o=Math.min(o,Yn(e,h,r,d,i,s))):o=Math.min(o,Qn(e,h,r,d,i,s)),0===o)return o}else {const a=Gn(h,t),u=Gn(d,n);ii(l,o,i,s,e,r,a[0],u[0]),ii(l,o,i,s,e,r,a[0],u[1]),ii(l,o,i,s,e,r,a[1],u[0]),ii(l,o,i,s,e,r,a[1],u[1]);}}return o}function oi(e,t,r,n,i,s=1/0){let a=s;const o=$n(e,[0,e.length-1]);for(const s of r)if(!(a!==1/0&&qn(o,$n(s,[0,s.length-1]),n,i)>=a)&&(a=Math.min(a,ai(e,t,s,!0,n,i,a)),0===a))return a;return a}function li(e,t,r,n,i,s=1/0){let a=s;const o=$n(e,[0,e.length-1]);for(const s of r){if(a!==1/0&&qn(o,Hn(s),n,i)>=a)continue;const r=si(e,t,s,n,i,a);if(isNaN(r))return r;if(0===(a=Math.min(a,r)))return a}return a}function ui(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class ci{constructor(e,t){this.type=Mr,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(qr(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!hi(e)&&(t=!1);}),t}function di(e){if(e instanceof hn&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild(e=>{t&&!di(e)&&(t=!1);}),t}function pi(e,t){if(e instanceof hn&&t.has(e.name))return !1;let r=!0;return e.eachChild(e=>{r&&!pi(e,t)&&(r=!1);}),r}function fi(e,t){return pi(e,new Set(t))}function mi(e,t,r){return [e,t,r].filter(Boolean).join("")}function yi(e,t){switch(e){case "string":return Zr(t);case "number":return +t;case "boolean":return !!t;case "color":return mr.parse(t);case "formatted":return jr.fromString(Zr(t));case "resolvedImage":return $r.build(Zr(t))}return t}function gi(e,t,r,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&er&&(e=r),e}class xi{constructor(e,t,r,n=!1){this.type=e,this.key=t,this.scope=r,this.featureConstant=n;}static parse(e,t){let r=t.expectedType;if(null==r&&(r=Pr),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const n=t.parse(e[1],1);if(!(n instanceof Wr))return t.error("Key name of 'config' expression must be a string literal.");let i,s=!0;const a=Zr(n.value);if(e.length>=3){const r=t.parse(e[2],2);if(!(r instanceof Wr))return t.error("Scope of 'config' expression must be a string literal.");i=Zr(r.value);}if(t.options){const e=mi(a,i,t._scope),r=t.options.get(e);r&&(s=hi(r.value||r.default));}return new xi(r,a,i,s)}evaluate(e){const t=mi(this.key,this.scope,e.scope),r=e.getConfig(t);if(!r)return null;const{type:n,value:i,values:s,minValue:a,maxValue:o,stepValue:l}=r,u=r.default.evaluate(e);let c=u;if(i){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),c=i.evaluate(e),e.scope=t;}return n&&(c=yi(n,c)),void 0===c||void 0===a&&void 0===o&&void 0===l||("number"==typeof c?c=gi(c,a,o,l):Array.isArray(c)&&(c=c.map(e=>"number"==typeof e?gi(e,a,o,l):e))),void 0!==i&&void 0!==c&&s&&!s.includes(c)&&(c=u,n&&(c=yi(n,c))),(n&&n!==this.type||void 0!==c&&!Or(Xr(c),this.type))&&(c=yi(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class vi{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t;}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const r=e[1];return t.scope.has(r)?new vi(r,t.scope.get(r)):t.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}class bi{constructor(e,t=[],r,n=new _r,i=[],s,a,o){this.registry=e,this.path=t,this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=a,this.iconImageUseTheme=o;}get key(){let e="";for(let t=0;t`[${e}]`).join("")}`;this.errors.push(new wr(r,e));}checkSubtype(e,t,r){const n=Dr(e,t);return n&&this.error(n,..."number"==typeof r?[r]:[]),n}}const wi=new Set(["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"]);function _i(e,t,r){return "assert"===r?new Jr(t,[e]):"coerce"===r?new ln(t,[e]):e}function Ai(e){if(e instanceof vi)return Ai(e.boundExpression);if(e instanceof hn&&"error"===e.name)return !1;if(e instanceof pn)return !1;if(e instanceof Pn)return !1;if(e instanceof ci)return !1;if(e instanceof xi)return !1;const t=e instanceof ln||e instanceof Jr;let r=!0;return e.eachChild(e=>{r=t?r&&Ai(e):r&&e instanceof Wr;}),!!r&&hi(e)&&pi(e,wi)}function Mi(e,t){const r=e.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=e[o],i=e[o+1],n<=t){if(o===r||tt))throw new Yr("Input is not a number.");a=o-1;}return 0}class Ii{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t);}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,Mr);if(!r)return null;const n=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let r=1;r=s)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Ii(i,r,n)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;return n>=t[i-1]?r[i-1].evaluate(e):r[Mi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Si=.95047,Bi=1.08883,Ei=4/29,Pi=6/29,zi=3*Pi*Pi,Ti=Pi*Pi*Pi,Vi=Math.PI/180,Fi=180/Math.PI;function ki(e){return e>Ti?Math.pow(e,1/3):e/zi+Ei}function Ci(e){return e>Pi?e*e*e:zi*(e-Ei)}function Di(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Ri(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Li(e){const t=Ri(e.r),r=Ri(e.g),n=Ri(e.b),i=ki((.4124564*t+.3575761*r+.1804375*n)/Si),s=ki((.2126729*t+.7151522*r+.072175*n)/1);return {l:116*s-16,a:500*(i-s),b:200*(s-ki((.0193339*t+.119192*r+.9503041*n)/Bi)),alpha:e.a}}function Oi(e){let t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Ci(t),r=Si*Ci(r),n=Bi*Ci(n),new mr(Di(3.2404542*r-1.5371385*t-.4985314*n),Di(-.969266*r+1.8760108*t+.041556*n),Di(.0556434*r-.2040259*t+1.0572252*n),e.alpha)}function Ui(e,t,r){const n=t-e;return e+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const Ni={forward:Li,reverse:Oi,interpolate:function(e,t,r){return {l:pr(e.l,t.l,r),a:pr(e.a,t.a,r),b:pr(e.b,t.b,r),alpha:pr(e.alpha,t.alpha,r)}}},ji={forward:function(e){const{l:t,a:r,b:n}=Li(e),i=Math.atan2(n,r)*Fi;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Vi,r=e.c;return Oi({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return {h:Ui(e.h,t.h,r),c:pr(e.c,t.c,r),l:pr(e.l,t.l,r),alpha:pr(e.alpha,t.alpha,r)}}};var Gi=Object.freeze({__proto__:null,hcl:ji,lab:Ni});class $i{constructor(e,t,r,n,i){this.type=e,this.operator=t,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,r,n){let i=0;if("exponential"===e.name)i=Hi(t,e.base,r,n);else if("linear"===e.name)i=Hi(t,1,r,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;i=ve(s[0],s[1],s[2],s[3])(Hi(t,1,r,n));}return i}static parse(e,t){let[r,n,i,...s]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e};}else {if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e};}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,Mr),!i)return null;const a=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Br:t.expectedType&&"value"!==t.expectedType.kind&&(o=t.expectedType);for(let e=0;e=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return "number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new $i(o,r,n,i,a):t.error(`Type ${kr(o)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;if(n>=t[i-1])return r[i-1].evaluate(e);const s=Mi(t,n),a=$i.interpolationFactor(this.interpolation,n,t[s],t[s+1]),o=r[s].evaluate(e),l=r[s+1].evaluate(e);return "interpolate"===this.operator?br[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?ji.reverse(ji.interpolate(ji.forward(o),ji.forward(l),a)):Ni.reverse(Ni.interpolate(Ni.forward(o),Ni.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let e=0;eDr(n,e.type));return new qi(s?Pr:r,i)}evaluate(e){let t,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(e),r&&r instanceof $r&&!r.available&&(t||(t=r),r=null,n===this.args.length))return t;if(null!==r)break}return r}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize());}),e}}const Xi=/[^a-zA-Z0-9_]/;class Zi{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t;}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result);}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Yr("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new Yr("Array index must be an integer. Use at-interpolated for fractional indices");return r[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class Yi{constructor(e,t,r){this.type=e,this.index=t,this.input=r;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Mr),n=t.parse(e[2],2,Fr(t.expectedType||Pr));return r&&n?new Yi(n.type.itemType,r,n):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new Yr(`Array index out of bounds: ${t} < 0.`);if(t>r.length-1)throw new Yr(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t===Math.floor(t))return r[t];const n=Math.floor(t),i=Math.ceil(t),s=r[n],a=r[i];if("number"!=typeof s||"number"!=typeof a)throw new Yr(`Cannot interpolate between non-number values at index ${t}.`);return pr(s,a,t-n)}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Ki{constructor(e,t){this.type=Sr,this.needle=e,this.haystack=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Pr),n=t.parse(e[2],2,Pr);return r&&n?Rr(r.type,[Sr,Ir,Mr,Ar,Pr])?new Ki(r,n):(t.error(`Expected first argument to be of type boolean, string, number or null, but found ${kr(r.type)} instead`),null):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return !1;if(!Lr(t,["boolean","string","number","null"]))throw new Yr(`Expected first argument to be of type boolean, string, number or null, but found ${kr(Xr(t))} instead.`);if(!Lr(r,["string","array"]))throw new Yr(`Expected second argument to be of type array or string, but found ${kr(Xr(r))} instead.`);return r.includes(t)}eachChild(e){e(this.needle),e(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}class Ji{constructor(e,t,r){this.type=Mr,this.needle=e,this.haystack=t,this.fromIndex=r;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Pr),n=t.parse(e[2],2,Pr);if(!r||!n)return null;if(!Rr(r.type,[Sr,Ir,Mr,Ar,Pr]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${kr(r.type)} instead`),null;if(4===e.length){const i=t.parse(e[3],3,Mr);return i?new Ji(r,n,i):null}return new Ji(r,n)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!Lr(t,["boolean","string","number","null"]))throw new Yr(`Expected first argument to be of type boolean, string, number or null, but found ${kr(Xr(t))} instead.`);if(!Lr(r,["string","array"]))throw new Yr(`Expected second argument to be of type array or string, but found ${kr(Xr(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return r.indexOf(t,n)}return r.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Qi{constructor(e,t,r,n,i,s){this.inputType=e,this.type=t,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return t.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`,a);if("number"==typeof e&&Math.floor(e)!==e)return t.error("Numeric branch labels must be integer values.",a);if(r){if(t.checkSubtype(r,Xr(e),a))return null}else r=Xr(e);if(void 0!==i[String(e)])return t.error("Branch labels must be unique.",a);i[String(e)]=s.length;}const u=t.parse(l,a,n);if(!u)return null;n=n||u.type,s.push(u);}const a=t.parse(e[1],1,Pr);if(!a)return null;const o=t.parse(e.at(-1),e.length-1,n);return o?"value"!==a.type.kind&&t.checkSubtype(r,a.type,1)?null:new Qi(r,n,a,i,s,o):null}evaluate(e){const t=this.input.evaluate(e);return (Or(Xr(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise);}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),r=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=r.length,r.push([this.cases[e],[e]])):r[t][1].push(e);}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of r)e.push(1===n.length?i(n[0]):n.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class es{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r;}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class ts{constructor(e,t,r,n){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=n;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Pr),n=t.parse(e[2],2,Mr);if(!r||!n)return null;if(!Rr(r.type,[Fr(Pr),Ir,Pr]))return t.error(`Expected first argument to be of type array or string, but found ${kr(r.type)} instead`),null;if(4===e.length){const i=t.parse(e[3],3,Mr);return i?new ts(r.type,r,n,i):null}return new ts(r.type,r,n)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!Lr(t,["string","array"]))throw new Yr(`Expected first argument to be of type array or string, but found ${kr(Xr(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(r,n)}return t.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}class rs{constructor(e,t){this.type=Fr(Ir),this.str=e,this.delimiter=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Ir),n=t.parse(e[2],2,Ir);return r&&n?new rs(r,n):void 0}evaluate(e){const t=this.str.evaluate(e),r=this.delimiter.evaluate(e);return t.split(r)}eachChild(e){e(this.str),e(this.delimiter);}outputDefined(){return !1}serialize(){return ["split",this.str.serialize(),this.delimiter.serialize()]}}function ns(e,t){return "=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function is(e,t,r,n){return 0===n.compare(t,r)}function ss(e,t,r){const n="=="!==e&&"!="!==e;return class i{constructor(e,t,r){this.type=Sr,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind;}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let s=t.parse(e[1],1,Pr);if(!s)return null;if(!ns(r,s.type))return t.error(`"${r}" comparisons are not supported for type '${kr(s.type)}'.`,1);let a=t.parse(e[2],2,Pr);if(!a)return null;if(!ns(r,a.type))return t.error(`"${r}" comparisons are not supported for type '${kr(a.type)}'.`,2);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${kr(s.type)}' and '${kr(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new Jr(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new Jr(s.type,[a])));let o=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(o=t.parse(e[3],3,zr),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const t=Xr(s),r=Xr(a);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new Yr(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Xr(s),r=Xr(a);if("string"!==e.kind||"string"!==r.kind)return t(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):t(i,s,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize());}),t}}}const as=ss("==",function(e,t,r){return t===r},is),os=ss("!=",function(e,t,r){return t!==r},function(e,t,r,n){return !is(0,t,r,n)}),ls=ss("<",function(e,t,r){return t",function(e,t,r){return t>r},function(e,t,r,n){return n.compare(t,r)>0}),cs=ss("<=",function(e,t,r){return t<=r},function(e,t,r,n){return n.compare(t,r)<=0}),hs=ss(">=",function(e,t,r){return t>=r},function(e,t,r,n){return n.compare(t,r)>=0});class ds{constructor(e,t,r,n,i,s){this.type=Ir,this.number=e,this.locale=t,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,Mr);if(!r)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=t.parseObjectValue(n.locale,2,"locale",Ir),!i))return null;let s=null;if(n.currency&&(s=t.parseObjectValue(n.currency,2,"currency",Ir),!s))return null;let a=null;if(n.unit&&(a=t.parseObjectValue(n.unit,2,"unit",Ir),!a))return null;let o=null;if(void 0!==n["min-fraction-digits"]&&(o=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",Mr),!o))return null;let l=null;return void 0===n["max-fraction-digits"]||(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",Mr),l)?new ds(r,i,s,a,o,l):null}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class ps{constructor(e){this.type=Mr,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?(t.error(`Expected argument of type string or array, but found ${kr(r.type)} instead.`),null):new ps(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Yr(`Expected value to be of type string or array, but found ${kr(Xr(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize());}),e}}function fs(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const ms={"==":as,"!=":os,">":us,"<":ls,">=":hs,"<=":cs,array:Jr,at:Wi,"at-interpolated":Yi,boolean:Jr,case:es,coalesce:qi,collator:pn,format:Qr,image:en,in:Ki,"index-of":Ji,interpolate:$i,"interpolate-hcl":$i,"interpolate-lab":$i,length:ps,let:Zi,literal:Wr,match:Qi,number:Jr,"number-format":ds,object:Jr,slice:ts,step:Ii,string:Jr,"to-boolean":ln,"to-color":ln,"to-number":ln,"to-string":ln,var:vi,within:Pn,distance:ci,config:xi,split:rs};function ys(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,a=Hr(t,r,n,s);if(a)throw new Yr(a);return new mr(t/255,r/255,n/255,s)}function gs(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,a=function(e,t,r,n){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'h' must be between 0 and 360.`}(t,r,n,s);if(a)throw new Yr(a);const o=`hsla(${t}, ${r}%, ${n}%, ${s})`,l=mr.parse(o);if(!l)throw new Yr(`Failed to parse HSLA color: ${o}`);return l}function xs(e,t){return e in t}function vs(e,t){const r=t[e];return void 0===r?null:r}function bs(e){return {type:e}}function ws(e){if(e instanceof xi)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...ws(e)]);}),t}function _s(e){if(e instanceof hn&&"is-active-floor"===e.name)return !0;let t=!1;return e.eachChild(e=>{!t&&_s(e)&&(t=!0);}),t}function As(e){return {result:"success",value:e}}function Ms(e){return {result:"error",value:e}}function Is(e,t){return !!e&&!!e.parameters&&e.parameters.includes(t)}function Ss(e){return "data-driven"===e["property-type"]}function Bs(e){return Is(e.expression,"measure-light")}function Es(e){return Is(e.expression,"zoom")}function Ps(e){return !!e.expression&&e.expression.interpolated}function zs(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function Ts(e){return e}function Vs(e,t){const r="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],i=n||!(n||void 0!==e.property),s=e.type||(Ps(t)?"exponential":"interval");if(r&&((e={...e}).stops&&(e.stops=e.stops.map(e=>[e[0],mr.parse(e[1])])),e.default=mr.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Gi[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let a,o,l;if("exponential"===s)a=Ds;else if("interval"===s)a=Cs;else if("categorical"===s){a=ks,o=Object.create(null);for(const t of e.stops)o[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);a=Rs;}if(n){const r={},n=[];for(let t=0;te[0]),evaluate:({zoom:r},n)=>Ds({stops:i,base:e.base},t,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:$i.interpolationFactor.bind(void 0,r),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:r})=>a(e,t,r,o,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[e.property]:void 0;return void 0===i?Fs(e.default,t.default):a(e,t,i,o,l)}}}function Fs(e,t,r){return void 0!==e?e:void 0!==t?t:void 0!==r?r:void 0}function ks(e,t,r,n,i){return Fs(typeof r===i?n[r]:void 0,e.default,t.default)}function Cs(e,t,r){if(!sn(r))return Fs(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];const i=Mi(e.stops.map(e=>e[0]),r);return e.stops[i][1]}function Ds(e,t,r){const n=void 0!==e.base?e.base:1;if(!sn(r))return Fs(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];const s=Mi(e.stops.map(e=>e[0]),r),a=function(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}(r,n,e.stops[s][0],e.stops[s+1][0]),o=e.stops[s][1],l=e.stops[s+1][1];let u=br[t.type]||Ts;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Gi[e.colorSpace];u=(e,r)=>t.reverse(t.interpolate(t.forward(e),t.forward(r),a));}return "function"==typeof o.evaluate?{evaluate(...e){const t=o.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==r)return u(t,r,a)}}:u(o,l,a)}function Rs(e,t,r){return "color"===t.type?r=mr.parse(r):"formatted"===t.type?r=jr.fromString(r.toString()):"resolvedImage"===t.type?r=$r.build(r.toString()):tn(r)===t.type||"enum"===t.type&&t.values[r]||(r=void 0),Fs(r,e.default,t.default)}hn.register(ms,{error:[{kind:"error"},[Ir],(e,[t])=>{throw new Yr(t.evaluate(e))}],typeof:[Ir,[Pr],(e,[t])=>kr(Xr(t.evaluate(e)))],"to-rgba":[Fr(Mr,4),[Br],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Fr(Mr,4),[Br],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Br,[Mr,Mr,Mr],ys],rgba:[Br,[Mr,Mr,Mr,Mr],ys],hsl:[Br,[Mr,Mr,Mr],gs],hsla:[Br,[Mr,Mr,Mr,Mr],gs],has:{type:Sr,overloads:[[[Ir],(e,[t])=>xs(t.evaluate(e),e.properties())],[[Ir,Er],(e,[t,r])=>xs(t.evaluate(e),r.evaluate(e))]]},get:{type:Pr,overloads:[[[Ir],(e,[t])=>vs(t.evaluate(e),e.properties())],[[Ir,Er],(e,[t,r])=>vs(t.evaluate(e),r.evaluate(e))]]},"feature-state":[Pr,[Ir],(e,[t])=>vs(t.evaluate(e),e.featureState||{})],properties:[Er,[],e=>e.properties()],"geometry-type":[Ir,[],e=>e.geometryType()],worldview:[Ir,[],e=>e.globals.worldview||""],"is-active-floor":[Sr,bs(Ir),(e,t)=>{if(!(e.globals&&e.globals.activeFloors&&e.globals.activeFloors.size>0))return !1;if(0===t.length)return !0;const r=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return r.has(n)})}],id:[Pr,[],e=>e.id()],zoom:[Mr,[],e=>e.globals.zoom],pitch:[Mr,[],e=>e.globals.pitch||0],"distance-from-center":[Mr,[],e=>e.distanceFromCenter()],"measure-light":[Mr,[Ir],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Mr,[],e=>e.globals.heatmapDensity||0],"line-progress":[Mr,[],e=>e.globals.lineProgress||0],"raster-value":[Mr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Mr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Mr,[],e=>e.globals.skyRadialProgress||0],accumulated:[Pr,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Mr,bs(Mr),(e,t)=>{let r=0;for(const n of t)r+=n.evaluate(e);return r}],"*":[Mr,bs(Mr),(e,t)=>{let r=1;for(const n of t)r*=n.evaluate(e);return r}],"-":{type:Mr,overloads:[[[Mr,Mr],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[Mr],(e,[t])=>-t.evaluate(e)]]},"/":[Mr,[Mr,Mr],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[Mr,[Mr,Mr],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[Mr,[],()=>Math.LN2],pi:[Mr,[],()=>Math.PI],e:[Mr,[],()=>Math.E],"^":[Mr,[Mr,Mr],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[Mr,[Mr],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Mr,[Mr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Mr,[Mr],(e,[t])=>Math.log(t.evaluate(e))],log2:[Mr,[Mr],(e,[t])=>Math.log2(t.evaluate(e))],sin:[Mr,[Mr],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Mr,[Mr],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Mr,[Mr],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Mr,[Mr],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Mr,[Mr],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Mr,[Mr],(e,[t])=>Math.atan(t.evaluate(e))],min:[Mr,bs(Mr),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Mr,bs(Mr),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Mr,[Mr],(e,[t])=>Math.abs(t.evaluate(e))],round:[Mr,[Mr],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[Mr,[Mr],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Mr,[Mr],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Sr,[Ir,Pr],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[Sr,[Pr],(e,[t])=>e.id()===t.value],"filter-type-==":[Sr,[Ir],(e,[t])=>e.geometryType()===t.value],"filter-<":[Sr,[Ir,Pr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n{const r=e.id(),n=t.value;return typeof r==typeof n&&r":[Sr,[Ir,Pr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Sr,[Pr],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>n}],"filter-<=":[Sr,[Ir,Pr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Sr,[Pr],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<=n}],"filter->=":[Sr,[Ir,Pr],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Sr,[Pr],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>=n}],"filter-has":[Sr,[Pr],(e,[t])=>t.value in e.properties()],"filter-has-id":[Sr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Sr,[Fr(Ir)],(e,[t])=>t.value.includes(e.geometryType())],"filter-id-in":[Sr,[Fr(Pr)],(e,[t])=>t.value.includes(e.id())],"filter-in-small":[Sr,[Ir,Fr(Pr)],(e,[t,r])=>r.value.includes(e.properties()[t.value])],"filter-in-large":[Sr,[Ir,Fr(Pr)],(e,[t,r])=>function(e,t,r,n){for(;r<=n;){const i=r+n>>1;if(t[i]===e)return !0;t[i]>e?n=i-1:r=i+1;}return !1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:Sr,overloads:[[[Sr,Sr],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[bs(Sr),(e,t)=>{for(const r of t)if(!r.evaluate(e))return !1;return !0}]]},any:{type:Sr,overloads:[[[Sr,Sr],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[bs(Sr),(e,t)=>{for(const r of t)if(r.evaluate(e))return !0;return !1}]]},"!":[Sr,[Sr],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Sr,[Ir],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return !r||r(t.evaluate(e))}],upcase:[Ir,[Ir],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Ir,[Ir],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Ir,bs(Pr),(e,t)=>t.map(t=>Zr(t.evaluate(e))).join("")],"resolved-locale":[Ir,[zr],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Mr,[Mr,Mr,Pr],(e,t)=>{const[r,n,i]=t.map(t=>t.evaluate(e));if(r>n)return r;if(r===n)return r;let s;if("string"==typeof i)s=function(e){let t=0;if(0===e.length)return t;for(let r=0;rJSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){const t=e;return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Os(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&Object.hasOwn(ms,e[0])}function Us(e,t,r,n,i){const s=new bi(ms,[],t?function(e){const t={color:Br,string:Ir,number:Mr,enum:Ir,boolean:Sr,formatted:Tr,resolvedImage:Vr};return "array"===e.type?Fr(t[e.value]||Pr,e.length):t[e.type]}(t):void 0,void 0,void 0,r,n,i),a=s.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return a?As(new Ls(a,t,r,n,i)):Ms(s.errors)}class Ns{constructor(e,t,r,n){this.kind=e,this._styleExpression=t,this.isLightConstant=r,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!di(t.expression),this.configDependencies=ws(t.expression),this.isIndoorDependent=_s(t.expression);}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s,a){return this._styleExpression.evaluate(e,t,r,n,i,s,void 0,void 0,a)}}class js{constructor(e,t,r,n,i,s){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!di(t.expression),this.isIndoorDependent=_s(t.expression),this.isLightConstant=i,this.isLineProgressConstant=s,this.configDependencies=ws(t.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s){return this._styleExpression.evaluate(e,t,r,n,i,s)}interpolationFactor(e,t,r){return this.interpolationType?$i.interpolationFactor(this.interpolationType,e,t,r):0}}function Gs(e,t,r,n,i){if("error"===(e=Us(e,t,r,n,i)).result)return e;const s=e.value.expression,a=hi(s);if(!a&&!Ss(t))return Ms([new wr("","data expressions not supported")]);const o=fi(s,["zoom","pitch","distance-from-center"]);if(!o&&!Es(t))return Ms([new wr("","zoom expressions not supported")]);const l=fi(s,["measure-light"]);if(!l&&!Bs(t))return Ms([new wr("","measure-light expression not supported")]);const u=fi(s,["line-progress"]);if(!u&&!function(e){return Is(e.expression,"line-progress")}(t))return Ms([new wr("","line-progress expression not supported")]);const c=t.expression&&t.expression.relaxZoomRestriction,h=Hs(s);return h||o||c?h instanceof wr?Ms([h]):h instanceof $i&&!Ps(t)?Ms([new wr("",'"interpolate" expressions cannot be used with this property')]):As(h?new js(a&&u?"camera":"composite",e.value,h.labels,h instanceof $i?h.interpolation:void 0,l,u):new Ns(a&&u?"constant":"source",e.value,l,u)):Ms([new wr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class $s{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,Vs(this._parameters,this._specification));}static deserialize(e){return new $s(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function Hs(e){let t=null;if(e instanceof Zi)t=Hs(e.result);else if(e instanceof qi){for(const r of e.args)if(t=Hs(r),t)break}else (e instanceof Ii||e instanceof $i)&&e.input instanceof hn&&"zoom"===e.input.name&&(t=e);return t instanceof wr||e.eachChild(e=>{const r=Hs(e);r instanceof wr?t=r:t&&r&&t!==r&&(t=new wr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));}),t}class qs{constructor(e,t,r){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){const t=new Int32Array(e);this.width=t[0],this.height=t[1],this.xCellCount=t[2],this.yCellCount=t[3],this.boxUid=t[4],this.circleUid=t[5];const r=this.xCellCount*this.yCellCount,n=[];for(let e=0;ethis.width||n<0||t>this.height)return s;const a=this._nextGen(),{boxCells:o,circleCells:l,boxKeys:u,circleKeys:c,bboxes:h,circles:d,boxSeen:p,circleSeen:f,xCellCount:m}=this,y=this._xCell(e),g=this._yCell(t),x=this._xCell(r),v=this._yCell(n);for(let b=y;b<=x;b++)for(let y=g;y<=v;y++){const g=m*y+b,x=o[g];if(x)for(let o=0;o=d&&n>=f&&(!i||i(u[l]))&&s.push({key:u[l],x1:d,y1:f,x2:m,y2:y});}const v=l[g];if(v)for(let o=0;othis.width||n<0||t>this.height)return s;const a=this._nextGen(),{boxCells:o,boxKeys:l,bboxes:u,boxSeen:c,xCellCount:h,xScale:d,yScale:p}=this,f=this._xCell(e),m=this._yCell(t),y=this._xCell(r),g=this._yCell(n);for(let x=f;x<=y;x++)for(let f=m;f<=g;f++){if(i&&!i(x/d,f/p,(x+1)/d,(f+1)/p))continue;const m=o[h*f+x];if(m)for(let o=0;o=p&&n>=f)&&s.push(l[h]);}}return s}hitTest(e,t,r,n,i){if(r<0||e>this.width||n<0||t>this.height)return !1;const s=this._nextGen(),{boxCells:a,circleCells:o,boxKeys:l,circleKeys:u,bboxes:c,circles:h,boxSeen:d,circleSeen:p,xCellCount:f}=this,m=this._xCell(e),y=this._yCell(t),g=this._xCell(r),x=this._yCell(n);for(let v=m;v<=g;v++)for(let m=y;m<=x;m++){const y=f*m+v,g=a[y];if(g)for(let a=0;a=c[u]&&n>=c[u+1]&&(!i||i(l[o])))return !0}const x=o[y];if(x)for(let a=0;athis.width||o<0||s>this.height)return !1;const l=this._nextGen(),{boxCells:u,circleCells:c,boxKeys:h,circleKeys:d,bboxes:p,circles:f,boxSeen:m,circleSeen:y,xCellCount:g}=this,x=this._xCell(i),v=this._yCell(s),b=this._xCell(a),w=this._yCell(o);for(let i=x;i<=b;i++)for(let s=v;s<=w;s++){const a=g*s+i,o=u[a];if(o)for(let i=0;i>>0,0===this.generation&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}_circlesCollide(e,t,r,n,i,s){const a=n-e,o=i-t,l=r+s;return l*l>a*a+o*o}_circleAndRectCollide(e,t,r,n,i,s,a){const o=(s-n)/2,l=Math.abs(e-(n+o));if(l>o+r)return !1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+r)return !1;if(l<=o||c<=u)return !0;const h=l-o,d=c-u;return h*h+d*d<=r*r}}const Xs={};function Zs(e,t,r={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),Xs[t]={klass:e,omit:r.omit||[]};}Zs(Object,"Object"),Zs(qs,"Grid"),delete be.prototype.constructor,Zs(mr,"Color"),Zs(jr,"Formatted"),Zs(Nr,"FormattedSection"),Zs($r,"ResolvedImage"),Zs($s,"StylePropertyFunction"),Zs(Ls,"StyleExpression",{omit:["_evaluator"]}),Zs(ur,"ImageId"),Zs(Gr,"ImageVariant"),Zs(js,"ZoomDependentExpression"),Zs(Ns,"ZoomConstantExpression"),Zs(hn,"CompoundExpression",{omit:["_evaluate"]});for(const e in ms)Xs[ms[e]._classRegistryKey]||Zs(ms[e],`Expression${e}`);function Ws(e){return e&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}const Ys={Error,TypeError,RangeError,SyntaxError,ReferenceError,URIError,EvalError},Ks=new Set(["message","stack","cause","errors","name","class"]);function Js(e,t){if(null===e)return null;const r=typeof e;if("object"!==r)return "bigint"===r?{$name:"BigInt",value:e.toString()}:e;if(Array.isArray(e)){const r=e.length,n=[];n.length=r;for(let i=0;ie!==r).map(e=>Js(e,t)));const s=r;for(const e in s)Object.hasOwn(s,e)&&(Ks.has(e)||(i[e]=Js(s[e],t)));return i}const n=e.constructor||Object,i=n._classRegistryKey;if(!i)throw new Error(`Can't serialize object of unregistered class "${n.name}".`);const s=n.serialize?n.serialize(e,t):{};if(!n.serialize){const r=Xs[i].omit,n=e;for(const e in n)Object.hasOwn(n,e)&&(r.includes(e)||(s[e]=Js(n[e],t)));}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==i&&(s.$name=i),s}function Qs(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e)){for(let t=0;te>=1536&&e<=1791,ta=e=>e>=1872&&e<=1919,ra=e=>e>=2208&&e<=2303,na=e=>e>=11904&&e<=12031,ia=e=>e>=12032&&e<=12255,sa=e=>e>=12272&&e<=12287,aa=e=>e>=12288&&e<=12351,oa=e=>e>=12352&&e<=12447,la=e=>e>=12448&&e<=12543,ua=e=>e>=12544&&e<=12591,ca=e=>e>=12704&&e<=12735,ha=e=>e>=12736&&e<=12783,da=e=>e>=12784&&e<=12799,pa=e=>e>=12800&&e<=13055,fa=e=>e>=13056&&e<=13311,ma=e=>e>=13312&&e<=19903,ya=e=>e>=19968&&e<=40959,ga=e=>e>=40960&&e<=42127,xa=e=>e>=42128&&e<=42191,va=e=>e>=44032&&e<=55215,ba=e=>e>=63744&&e<=64255,wa=e=>e>=64336&&e<=65023,_a=e=>e>=65040&&e<=65055,Aa=e=>e>=65072&&e<=65103,Ma=e=>e>=65104&&e<=65135,Ia=e=>e>=65136&&e<=65279,Sa=e=>e>=65280&&e<=65519;function Ba(e){for(const t of e)if(Ta(t.charCodeAt(0)))return !0;return !1}function Ea(e){for(const t of e)if(!Pa(t.charCodeAt(0)))return !1;return !0}function Pa(e){return !(ea(e)||ta(e)||ra(e)||wa(e)||Ia(e))}function za(e){return !(e<11904||!(ca(e)||ua(e)||Aa(e)||ba(e)||fa(e)||na(e)||ha(e)||aa(e)||ma(e)||ya(e)||pa(e)||Sa(e)||oa(e)||sa(e)||ia(e)||da(e)||la(e)||_a(e)||xa(e)||ga(e)))}function Ta(e){return !(746!==e&&747!==e&&(e<4352||!(ca(e)||ua(e)||Aa(e)&&!(e>=65097&&e<=65103)||ba(e)||fa(e)||na(e)||ha(e)||!(!aa(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||ma(e)||ya(e)||pa(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||va(e)||oa(e)||sa(e)||(e=>e>=12688&&e<=12703)(e)||ia(e)||da(e)||la(e)&&12540!==e||!(!Sa(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Ma(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||_a(e)||(e=>e>=19904&&e<=19967)(e)||ga(e)||xa(e))))}function Va(e){return 12307===e||12312===e||12313===e||12316===e||12448===e||12540===e||e>=8592&&e<=8595||8208===e||8213===e||8229===e||8741===e||e>=9472&&e<=9547||65294===e||65309===e||65374===e||65507===e}function Fa(e){return !(Ta(e)||function(e){return !!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||aa(e)||la(e)||(e=>e>=57344&&e<=63743)(e)||Aa(e)||Ma(e)||Sa(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function ka(e){return ea(e)||ta(e)||ra(e)||wa(e)||Ia(e)}function Ca(e){return e>=1424&&e<=2303||wa(e)||Ia(e)}function Da(e,t){return !(!t&&Ca(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Ra(e){for(const t of e)if(Ca(t.charCodeAt(0)))return !0;return !1}const La={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Oa=null,Ua=La.unavailable,Na=null;const ja=function(e){e&&(Ua=La.error),Oa&&Oa(e);};function Ga(){$a.fire(new ir("pluginStateChange",{pluginStatus:Ua,pluginURL:Na}));}const $a=new lr,Ha=function(){return Ua},qa=function(){if(Ua!==La.deferred||!Na)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ua=La.loading,Ga(),Na&&Qt({url:Na}).then(()=>{Ua=La.loaded,Ga();}).catch(e=>{ja(e);});},Xa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ua===La.loaded||null!=Xa.applyArabicShaping,isLoading:()=>Ua===La.loading,setState(e){Ua=e.pluginStatus,Na=e.pluginURL;},isParsing:()=>Ua===La.parsing,isParsed:()=>Ua===La.parsed,getPluginURL:()=>Na};class Za{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const r of e)if(!Da(r.charCodeAt(0),t))return !1;return !0}(e,Xa.isLoaded())}}class Wa{constructor(e,t,r,n,i){this.property=e,this.value=t,this.expression=function(e,t,r,n,i){if(zs(e))return new $s(e,t);if(Os(e)||Array.isArray(e)&&e.length>0){const s=Gs(e,t,r,n,i);if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));return s.value}{let r=e;return "string"==typeof e&&"color"===t.type&&(r=mr.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>r}}}(void 0===t?e.specification.default:t,e.specification,r,n,i);}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,r,n){return this.property.possiblyEvaluate(this,e,t,r,n)}}class Ya{constructor(e,t,r,n){this.property=e,this.value=new Wa(e,void 0,t,r,n);}transitioned(e,t){return new Ja(this.property,this.value,t,{...e.transition,...this.transition},e.now)}untransitioned(){return new Ja(this.property,this.value,null,{},0)}}class Ka{constructor(e,t,r,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return et(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Ya(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Wa(this._values[e].property,null===t?void 0:et(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent());}setTransitionOrValue(e,t){t&&(this._options=t);const r=this._properties.properties;if(e)for(const t in e){const n=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);r[e]&&this.setTransition(e,n);}else Object.hasOwn(r,t)&&this.setValue(t,n);}}getTransition(e){return et(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Ya(this._values[e].property)),this._values[e].transition=et(t)||void 0;}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);const n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n);}return e}transitioned(e,t){const r=new Qa(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(e,t._values[n]);return r}untransitioned(){const e=new Qa(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class Ja{constructor(e,t,r,n,i){const s=n.delay||0,a=n.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+s,this.end=this.begin+a,e.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(e,t,r){const n=e.now||0,i=this.value.possiblyEvaluate(e,t,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function_stop":{"type":"array","minimum":0,"maximum":24,"length":2,"value":["number","color"]},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"camera":{"camera-projection":{"type":"enum","default":"perspective","values":{"perspective":1,"orthographic":1}}},"colorTheme":{"data":{"type":"string","expression":1}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"projection":{"name":{"type":"enum","default":"mercator","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1}},"center":{"type":"array","minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"parallels":{"type":"array","minimum":[-90,-90],"maximum":[90,90],"length":2,"value":"number"}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-outline-color":{"type":"color","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","default":"flat","values":{"terrain":1,"flat":1}},"fill-extrusion-base-alignment":{"type":"enum","default":"terrain","values":{"terrain":1,"flat":1}},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-extrusion-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"fill-extrusion-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":1},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"use-theme":1,"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"building-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"building-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-dasharray":{"type":"array","minimum":0,"value":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-trim-offset":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number"},"line-trim-fade-range":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-trim-color":{"type":"color","default":"transparent","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-blend-mode":{"type":"enum","default":"default","values":{"default":1,"multiply":1,"additive":1},"expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"circle-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"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"],"expression":{"interpolated":1,"parameters":["heatmap-density"]},"use-theme":1},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"icon-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1,"overridable":1},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"text-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"text-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":1},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven","appearance":1}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-value"]},"use-theme":1},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-range":{"type":"array","length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-hue-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-resampling":{"type":"enum","default":"linear","values":{"linear":1,"nearest":1},"expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-elevation-reference":{"type":"enum","default":"sea","values":{"sea":1,"ground":1},"expression":1}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-particle-speed"]},"use-theme":1},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":1,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"hillshade-shadow-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-accent-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_background":{"background-pitch-alignment":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_sky":{"sky-type":{"type":"enum","default":"atmosphere","values":{"gradient":1,"atmosphere":1},"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":1,"parameters":["sky-radial-progress"]},"use-theme":1},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":1},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":1},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-rotation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-scale":{"type":"array","default":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-translation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"model-color-mix-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-type":{"type":"enum","default":"common-3d","values":{"common-3d":1,"location-indicator":1}},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"model-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"model-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"model-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"model-line-cutout-mode":{"type":"enum","default":"enabled","values":{"enabled":1,"disabled":1,"enabled-above-cutout":1},"expression":1}},"promoteId":{"*":{"type":"*"}}}');function lo(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function uo(e){if(Array.isArray(e))return e.map(uo);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={},r=e;for(const e in r)t[e]=uo(r[e]);return t}return lo(e)}function co(e){if(!0===e||!1===e)return !0;if(!Array.isArray(e)||0===e.length)return !1;switch(e[0]){case "has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case "in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case "any":case "all":for(const t of e.slice(1))if(!co(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function ho(e,t="",r=null,n="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};co(e)||(e=vo(e));const i=e;let s=!0;try{s=function(e){if(!mo(e))return e;let t=uo(e);return fo(t),t=po(t),t}(i);}catch(e){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 `);}let a=null,o=null;if("background"!==n&&"sky"!==n&&"slot"!==n){o=oo[`filter_${n}`];const e=Us(s,o,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(t,r,n)=>e.value.evaluate(t,r,{},n);}let l=null,u=null;if(s!==i){const e=Us(i,o,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,r,n,i,s)=>e.value.evaluate(t,r,{},n,void 0,void 0,i,s),u=!hi(e.value.expression);}return {filter:a,dynamicFilter:l||void 0,needGeometry:xo(s),needFeature:!!u}}function po(e){if(!Array.isArray(e))return e;const t=function(e){if(yo.has(e[0]))for(let t=1;tpo(e))}function fo(e){let t=!1;const r=[];if("case"===e[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function go(e,t){return et?1:0}function xo(e){if(!Array.isArray(e))return !1;if("within"===e[0]||"distance"===e[0])return !0;for(let t=1;t"===t||"<="===t||">="===t?bo(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(vo))):"all"===t?["all"].concat(e.slice(1).map(vo)):"none"===t?["all"].concat(e.slice(1).map(vo).map(Ao)):"in"===t?wo(e[1],e.slice(2)):"!in"===t?Ao(wo(e[1],e.slice(2))):"has"===t?_o(e[1]):"!has"!==t||Ao(_o(e[1]));var r;}function bo(e,t,r){switch(e){case "$type":return [`filter-type-${r}`,t];case "$id":return [`filter-id-${r}`,t];default:return [`filter-${r}`,e,t]}}function wo(e,t){if(0===t.length)return !1;switch(e){case "$type":return ["filter-type-in",["literal",t]];case "$id":return ["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(go)]]:["filter-in-small",e,["literal",t]]}}function _o(e){switch(e){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",e]}}function Ao(e){return ["!",e]}const Mo="";function Io(e,t){return t?`${e}${Mo}${t}`:e}function So(e){const t=e.indexOf(Mo);return t>=0?e.slice(t+1):""}let Bo;const Eo=()=>Bo||(Bo=new ao({"icon-size":new io(oo.layout_symbol["icon-size"]),"icon-image":new io(oo.layout_symbol["icon-image"]),"icon-rotate":new io(oo.layout_symbol["icon-rotate"]),"icon-offset":new io(oo.layout_symbol["icon-offset"]),"text-size":new io(oo.layout_symbol["text-size"]),"text-rotate":new io(oo.layout_symbol["text-rotate"]),"text-offset":new io(oo.layout_symbol["text-offset"])}));let Po;const zo=()=>Po||(Po=new ao({"icon-opacity":new io(oo.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new io(oo.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new io(oo.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new io(oo.paint_symbol["text-emissive-strength"]),"icon-color":new io(oo.paint_symbol["icon-color"]),"icon-halo-color":new io(oo.paint_symbol["icon-halo-color"]),"icon-halo-width":new io(oo.paint_symbol["icon-halo-width"]),"icon-halo-blur":new io(oo.paint_symbol["icon-halo-blur"]),"icon-translate":new io(oo.paint_symbol["icon-translate"]),"text-opacity":new io(oo.paint_symbol["text-opacity"]),"text-occlusion-opacity":new io(oo.paint_symbol["text-occlusion-opacity"]),"text-color":new io(oo.paint_symbol["text-color"],{runtimeType:Br,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new io(oo.paint_symbol["text-halo-color"]),"text-halo-width":new io(oo.paint_symbol["text-halo-width"]),"text-halo-blur":new io(oo.paint_symbol["text-halo-blur"]),"text-translate":new io(oo.paint_symbol["text-translate"]),"symbol-z-offset":new io(oo.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}));class To{constructor(e,t,r,n,i,s){this._conditionSpec=e,this._propertiesSpec=r;const a=Us(e,oo.appearance.condition);if("success"===a.result&&(this.condition=a.value),this.name=t,r){this.layoutProperties=new ro(Eo()),this.unevaluatedLayout=new eo(Eo(),n,i,s),this.paintProperties=new ro(zo()),this.unevaluatedPaint=new eo(zo(),n,i,"");for(const e in r)e in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(e,r[e]):e in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(e,r[e]);}}isActive(e){return !(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,t,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""));}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t={...this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},...this.unevaluatedPaint?this.unevaluatedPaint.serialize():{}};return Object.keys(t).length>0&&(e.properties=t),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),n=this.hasLayoutProperty("icon-rotate");return e||t||r||n}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return e||t||r}hasIconPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasTextPaintProperties(){return !!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||"symbol-z-offset"===e)&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&void 0!==this.unevaluatedLayout._values[e].value}hasPaintProperty(e){return this.unevaluatedPaint&&void 0!==this.unevaluatedPaint._values[e].value}}const Vo="-transition",Fo=new Set(["fill","line","background","hillshade","raster"]);class ko extends lr{constructor(e,t,r,n,i,s){if(super(),this.id=e.id,this.fqid=Io(this.id,r),this.type=e.type,this.scope=r,this.lut=n,this.options=i,this.iconImageUseTheme=s,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new eo(t.layout,this.scope,i,this.iconImageUseTheme)),t.paint)){this._transitionablePaint=new Ka(t.paint,this.scope,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ro(t.paint);}}onAdd(e){}onRemove(e){}isDraped(e){return !this.is3D(!0)&&Fo.has(this.type)}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),"visibility"===e&&this.possiblyEvaluateVisibility());}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new To(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme));}),this.appearancesVersion++;}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}));}getPaintProperty(e){return e.endsWith(Vo)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return !!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const r=this._transitionablePaint,n=r._properties.properties;if(e.endsWith(Vo)){const i=e.slice(0,-11);return n[i]&&r.setTransition(i,t||void 0),!1}if(!n[e])return !1;const i=r._values[e],s=i.value.isDataDriven(),a=i.value;r.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const o=r._values[e].value,l=o.isDataDriven(),u=e.endsWith("pattern")||"line-dasharray"===e;return l||s||u||this._handleOverridablePaintPropertyUpdate(e,a,o)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,r){return null}_handleOverridablePaintPropertyUpdate(e,t,r){return !1}isHidden(e){return !!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){const e={id:this.id,type:this.type,slot:this.slot,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 0!==this.appearances.length&&(e.appearances=this.appearances.map(e=>e.serialize())),Qe(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}is3D(e){return !1}hasElevation(){return !1}mayUse(e){return !1}prepare(){return Promise.resolve()}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof to&&Ss(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}for(const e of this.appearances)if(!di(e.condition.expression))return !0;return !1}compileFilter(e){this._filterCompiled||(this._featureFilter=ho(this.filter,this.scope,e),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,r){return {}}queryRadius(e){}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){}}function Co(e,t,r){if(!e._unevaluatedLayout)return !1;const n=e._unevaluatedLayout.getValue(t);return void 0!==n&&("string"!=typeof n||r(n))}function Do(e,t,r=2){const n=t&&t.length,i=n?t[0]*r:e.length;let s=Ro(e,0,i,r,!0);const a=[];if(!s||s.next===s.prev)return a;let o,l,u;if(n&&(s=function(e,t,r,n){const i=[];for(let r=0,s=t.length;r80*r){o=e[0],l=e[1];let t=o,n=l;for(let s=r;st&&(t=r),i>n&&(n=i);}u=Math.max(t-o,n-l),u=0!==u?32767/u:0;}return Oo(s,a,r,o,l,u,0),a}function Ro(e,t,r,n,i){let s;if(i===function(e,t,r,n){let i=0;for(let s=t,a=r-n;s0)for(let i=t;i=t;i-=n)s=sl(i/n|0,e[i],e[i+1],s);return s&&Qo(s,s.next)&&(al(s),s=s.next),s}function Lo(e,t){if(!e)return e;t||(t=e);let r,n=e;do{if(r=!1,n.steiner||!Qo(n,n.next)&&0!==Jo(n.prev,n,n.next))n=n.next;else {if(al(n),n=t=n.prev,n===n.next)break;r=!0;}}while(r||n!==t);return t}function Oo(e,t,r,n,i,s,a){if(!e)return;!a&&s&&function(e,t,r,n){let i=e;do{0===i.z&&(i.z=Xo(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,r=1;do{let n,i=e;e=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let e=0;e0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(t>1)}(i);}(e,n,i,s);let o=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(s?No(e,n,i,s):Uo(e))t.push(l.i,e.i,u.i),al(e),e=u.next,o=u.next;else if((e=u)===o){a?1===a?Oo(e=jo(Lo(e),t),t,r,n,i,s,2):2===a&&Go(e,t,r,n,i,s):Oo(Lo(e),t,r,n,i,s,1);break}}}function Uo(e){const t=e.prev,r=e,n=e.next;if(Jo(t,r,n)>=0)return !1;const i=t.x,s=r.x,a=n.x,o=t.y,l=r.y,u=n.y,c=Math.min(i,s,a),h=Math.min(o,l,u),d=Math.max(i,s,a),p=Math.max(o,l,u);let f=n.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=h&&f.y<=p&&Yo(i,o,s,l,a,u,f.x,f.y)&&Jo(f.prev,f,f.next)>=0)return !1;f=f.next;}return !0}function No(e,t,r,n){const i=e.prev,s=e,a=e.next;if(Jo(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,d=a.y,p=Math.min(o,l,u),f=Math.min(c,h,d),m=Math.max(o,l,u),y=Math.max(c,h,d),g=Xo(p,f,t,r,n),x=Xo(m,y,t,r,n);let v=e.prevZ,b=e.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==a&&Yo(o,c,l,h,u,d,v.x,v.y)&&Jo(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==a&&Yo(o,c,l,h,u,d,b.x,b.y)&&Jo(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==a&&Yo(o,c,l,h,u,d,v.x,v.y)&&Jo(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==a&&Yo(o,c,l,h,u,d,b.x,b.y)&&Jo(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function jo(e,t){let r=e;do{const n=r.prev,i=r.next.next;!Qo(n,i)&&el(n,r,r.next,i)&&nl(n,i)&&nl(i,n)&&(t.push(n.i,r.i,i.i),al(r),al(r.next),r=e=i),r=r.next;}while(r!==e);return Lo(r)}function Go(e,t,r,n,i,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Ko(a,e)){let o=il(a,e);return a=Lo(a,a.next),o=Lo(o,o.next),Oo(a,t,r,n,i,s,0),void Oo(o,t,r,n,i,s,0)}e=e.next;}a=a.next;}while(a!==e)}function $o(e,t){let r=e.x-t.x;return 0===r&&(r=e.y-t.y,0===r)&&(r=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),r}function Ho(e,t){const r=function(e,t){let r=t;const n=e.x,i=e.y;let s,a=-1/0;if(Qo(e,r))return r;do{if(Qo(e,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const e=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=n&&e>a&&(a=e,s=r.x=r.x&&r.x>=l&&n!==r.x&&Wo(is.x||r.x===s.x&&qo(s,r)))&&(s=r,c=t);}r=r.next;}while(r!==o);return s}(e,t);if(!r)return t;const n=il(r,e);return Lo(n,n.next),Lo(r,r.next)}function qo(e,t){return Jo(e.prev,e,t.prev)<0&&Jo(t.next,e,e.next)<0}function Xo(e,t,r,n,i){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Zo(e){let t=e,r=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(n-o)>=(r-a)*(t-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Yo(e,t,r,n,i,s,a,o){return !(e===a&&t===o)&&Wo(e,t,r,n,i,s,a,o)}function Ko(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&el(r,r.next,e,t))return !0;r=r.next;}while(r!==e);return !1}(e,t)&&(nl(e,t)&&nl(t,e)&&function(e,t){let r=e,n=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==e);return n}(e,t)&&(Jo(e.prev,e,t.prev)||Jo(e,t.prev,t))||Qo(e,t)&&Jo(e.prev,e,e.next)>0&&Jo(t.prev,t,t.next)>0)}function Jo(e,t,r){return (t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Qo(e,t){return e.x===t.x&&e.y===t.y}function el(e,t,r,n){const i=rl(Jo(e,t,r)),s=rl(Jo(e,t,n)),a=rl(Jo(r,n,e)),o=rl(Jo(r,n,t));return i!==s&&a!==o||!(0!==i||!tl(e,r,t))||!(0!==s||!tl(e,n,t))||!(0!==a||!tl(r,e,n))||!(0!==o||!tl(r,t,n))}function tl(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function rl(e){return e>0?1:e<0?-1:0}function nl(e,t){return Jo(e.prev,e,e.next)<0?Jo(e,t,e.next)>=0&&Jo(e,e.prev,t)>=0:Jo(e,t,e.prev)<0||Jo(e,e.next,t)<0}function il(e,t){const r=ol(e.i,e.x,e.y),n=ol(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function sl(e,t,r,n){const i=ol(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function al(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function ol(e,t,r){return {i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ll(e,t,r=1){if(!e)return null;const n="string"==typeof e?$r.from(e).getPrimary():e.getPrimary(),i="string"==typeof e?null:e.getSecondary();for(const e of [n,i]){if(!e)continue;const n=e.id.toString();t.has(n)||t.set(n,[]),e.scaleSelf(r),t.get(n).push(e);}return {primary:n.toString(),secondary:i?i.toString():null}}function ul(e,t,r,n){const i=n.patternDependencies;let s=!1;for(const n of t){const t=n.paint.get(`${e}-pattern`);t.isConstant()||(s=!0),ll(t.constantOr(null),i,r)&&(s=!0);}return s}function cl(e,t,r,n,i,s){const a=s.patternDependencies;for(const o of t){const t=o.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){const e=ll(t.evaluate({zoom:n},r,{},void 0,s.availableImages),a,i);if(!e)continue;const{primary:l,secondary:u}=e;l&&(r.patterns[o.id]=[l,u].filter(Boolean));}}return r}const hl=Tn/Math.PI/2,dl=64,pl=[dl,32,16],fl=-hl,ml=hl;function yl(e,t,r,n=hl){return r=Oe(r),[e*Math.sin(r)*n,-t*n,e*Math.cos(r)*n]}function gl(e,t,r){return yl(Math.cos(Oe(e)),Math.sin(Oe(e)),t,r)}const xl=6371008.8,vl=2*Math.PI*xl;class bl{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new bl(qe(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,n=e.lat*t,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return xl*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,r=t/Math.cos(Math.PI/180*this.lat);return new wl({lng:this.lng-r,lat:this.lat-t},{lng:this.lng+r,lat:this.lat+t})}toEcef(e){return gl(this.lat,this.lng,hl+e*hl/xl)}static convert(e){if(e instanceof bl)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new bl(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new bl(Number("lng"in e?e.lng:e.lon),Number(e.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 [, ]")}}class wl{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]));}setNorthEast(e){return this._ne=e instanceof bl?new bl(e.lng,e.lat):bl.convert(e),this}setSouthWest(e){return this._sw=e instanceof bl?new bl(e.lng,e.lat):bl.convert(e),this}extend(e){const t=this._sw,r=this._ne;let n,i;if(e instanceof bl)n=e,i=e;else {if(!(e instanceof wl))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(wl.convert(e)):this.extend(bl.convert(e)):"object"==typeof e&&null!==e&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(bl.convert(e)):this;if(n=e._sw,i=e._ne,!n||!i)return this}return t||r?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new bl(n.lng,n.lat),this._ne=new bl(i.lng,i.lat)),this}getCenter(){return new bl((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 bl(this.getWest(),this.getNorth())}getSouthEast(){return new bl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:t,lat:r}=bl.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(e){if(e)return e instanceof wl?e:new wl(e)}}function _l(e){return vl*Math.cos(e*Math.PI/180)}function Al(e,t){return e/_l(t)}function Ml(e,t){return e*_l(gn(t))}const Il=85.051129;function Sl(e){return Math.cos(Oe($e(e,-85.051129,Il)))}function Bl(e,t){const r=$e(t,0,25.5),n=Math.pow(2,r);return Sl(e)*vl/(512*n)}function El(e){return 1/Math.cos(e*Math.PI/180)}function Pl(e,t=0){const r=Math.exp(Math.PI*(1-(e.y+t/Tn)/(1<=l?(Tl(e,t,r,u,c,s,h,o,l),Tl(e,u,c,n,i,h,a,o,l)):e.push(a);}function Vl(e,t,r){let n=e[0],i=n.x,s=n.y;t(n);const a=[n];for(let o=1;oe.x+1||ne.y+1)&&nt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Ll(e,t,r){const n=e.loadGeometry(),i=e.extent,s=Tn/i;if(t&&r&&r.projection.isReprojectedInTileSpace){const s=1<{const r=yn((t.x+e.x/i)/s),n=gn((t.y+e.y/i)/s),c=u.project(r,n);e.x=(c.x*a-o)*i,e.y=(c.y*a-l)*i;};for(let t=0;t=i||r.y<0||r.y>=i||(c(r),e.push(r));n[t]=e;}}for(const e of n)for(const t of e)Rl(t,s);return n}function Ol(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?Ll(e):[]}}const Ul={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Nl{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}const jl=new ArrayBuffer(0);class Gl{constructor(){this._reallocCount=0,this.capacity=0,this.length=0;}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=jl),t._refreshViews(),t}_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(e){this.reserve(e),this.length=e;}resizeExact(e){this.reserveExact(e),this.length=e;}reserve(e){e>this.capacity&&this._allocate(Math.max(e,Math.floor(5*this.capacity),128));}reserveExact(e){(e>this.capacity||!this.arrayBuffer)&&this._allocate(e);}_allocate(e){this._reallocCount++,this.capacity=e,this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}reserveForAdditional(e){this.reserve(this.length+e);}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() 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 $l(e,t=1){let r=0,n=0;return {members:e.map(e=>{const i=Ul[e.type].BYTES_PER_ELEMENT,s=r=Hl(r,Math.max(t,i)),a=e.components||1;return n=Math.max(n,i),r+=i*a,{name:e.name,type:e.type,components:a,offset:s}}),size:Hl(r,Math.max(n,t)),alignment:t}}function Hl(e,t){return Math.ceil(e/t)*t}class ql extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=r,e}}ql.prototype.bytesPerElement=4,Zs(ql,"StructArrayLayout2i4");class Xl extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}Xl.prototype.bytesPerElement=6,Zs(Xl,"StructArrayLayout3i6");class Zl extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}Zl.prototype.bytesPerElement=8,Zs(Zl,"StructArrayLayout2i2ui8");class Wl extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Wl.prototype.bytesPerElement=4,Zs(Wl,"StructArrayLayout1f4");class Yl extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e,s=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.float32[s+1]=n,e}}Yl.prototype.bytesPerElement=8,Zs(Yl,"StructArrayLayout2i1f8");class Kl extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}Kl.prototype.bytesPerElement=8,Zs(Kl,"StructArrayLayout3i8");class Jl extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,e}}Jl.prototype.bytesPerElement=8,Zs(Jl,"StructArrayLayout4i8");class Ql extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=5*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,e}}Ql.prototype.bytesPerElement=10,Zs(Ql,"StructArrayLayout5i10");class eu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=s,this.uint8[u+7]=a,this.float32[c+2]=o,e}}eu.prototype.bytesPerElement=12,Zs(eu,"StructArrayLayout2i4ub1f12");class tu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=r,this.float32[i+2]=n,e}}tu.prototype.bytesPerElement=12,Zs(tu,"StructArrayLayout3f12");class ru extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=6*e,o=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,this.float32[o+2]=s,e}}ru.prototype.bytesPerElement=12,Zs(ru,"StructArrayLayout4ui1f12");class nu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.uint16[s+0]=t,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}nu.prototype.bytesPerElement=8,Zs(nu,"StructArrayLayout4ui8");class iu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=6*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,e}}iu.prototype.bytesPerElement=12,Zs(iu,"StructArrayLayout6i12");class su extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,n,i,s,a,o,l,u,c,h)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=r,this.int16[p+2]=n,this.int16[p+3]=i,this.uint16[p+4]=s,this.uint16[p+5]=a,this.uint16[p+6]=o,this.uint16[p+7]=l,this.int16[p+8]=u,this.int16[p+9]=c,this.int16[p+10]=h,this.int16[p+11]=d,e}}su.prototype.bytesPerElement=24,Zs(su,"StructArrayLayout4i4ui4i24");class au extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=10*e,l=5*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,e}}au.prototype.bytesPerElement=20,Zs(au,"StructArrayLayout3i3f20");class ou extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,e}}ou.prototype.bytesPerElement=16,Zs(ou,"StructArrayLayout4f16");class lu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}lu.prototype.bytesPerElement=4,Zs(lu,"StructArrayLayout1ul4");class uu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,e}}uu.prototype.bytesPerElement=4,Zs(uu,"StructArrayLayout2ui4");class cu extends Gl{_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(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,r,n,i,s,a,o,l,u,c,h,d)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.int16[f+4]=s,this.float32[m+3]=a,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[f+14]=c,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}cu.prototype.bytesPerElement=40,Zs(cu,"StructArrayLayout5i4f1i1ul2ui40");class hu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=s,this.int16[l+6]=a,this.int16[l+7]=o,e}}hu.prototype.bytesPerElement=16,Zs(hu,"StructArrayLayout3i2i2i16");class du extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=4*e,o=8*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,e}}du.prototype.bytesPerElement=16,Zs(du,"StructArrayLayout2f1f2i16");class pu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=20*e,l=5*e;return this.uint8[o+0]=t,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,e}}pu.prototype.bytesPerElement=20,Zs(pu,"StructArrayLayout2ub4f20");class fu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,this.uint16[i+2]=n,e}}fu.prototype.bytesPerElement=6,Zs(fu,"StructArrayLayout3ui6");class mu extends Gl{_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(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b){const w=this.length;return this.resize(w+1),this.emplace(w,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w){const _=30*e,A=15*e,M=60*e;return this.int16[_+0]=t,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[A+2]=i,this.float32[A+3]=s,this.uint16[_+8]=a,this.uint16[_+9]=o,this.uint32[A+5]=l,this.uint32[A+6]=u,this.uint32[A+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=d,this.uint16[_+18]=p,this.float32[A+10]=f,this.float32[A+11]=m,this.uint8[M+48]=y,this.uint8[M+49]=g,this.uint8[M+50]=x,this.uint32[A+13]=v,this.int16[_+28]=b,this.uint8[M+58]=w,e}}mu.prototype.bytesPerElement=60,Zs(mu,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class yu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,M,I,S,B,E,P,z,T,V){const F=this.length;return this.resize(F+1),this.emplace(F,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,M,I,S,B,E,P,z,T,V)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,M,I,S,B,E,P,z,T,V,F){const k=20*e,C=40*e,D=80*e;return this.float32[k+0]=t,this.float32[k+1]=r,this.int16[C+4]=n,this.int16[C+5]=i,this.int16[C+6]=s,this.int16[C+7]=a,this.int16[C+8]=o,this.int16[C+9]=l,this.int16[C+10]=u,this.int16[C+11]=c,this.int16[C+12]=h,this.uint16[C+13]=d,this.uint16[C+14]=p,this.uint16[C+15]=f,this.uint16[C+16]=m,this.uint16[C+17]=y,this.uint16[C+18]=g,this.uint16[C+19]=x,this.uint16[C+20]=v,this.uint16[C+21]=b,this.uint16[C+22]=w,this.uint16[C+23]=_,this.uint16[C+24]=A,this.uint16[C+25]=M,this.uint16[C+26]=I,this.uint16[C+27]=S,this.uint32[k+14]=B,this.float32[k+15]=E,this.float32[k+16]=P,this.float32[k+17]=z,this.float32[k+18]=T,this.uint8[D+76]=V,this.uint16[C+39]=F,e}}yu.prototype.bytesPerElement=80,Zs(yu,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class gu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,a){const o=6*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=n,this.float32[o+3]=i,this.float32[o+4]=s,this.float32[o+5]=a,e}}gu.prototype.bytesPerElement=24,Zs(gu,"StructArrayLayout6f24");class xu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=s,e}}xu.prototype.bytesPerElement=20,Zs(xu,"StructArrayLayout5f20");class vu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=s,this.float32[l+5]=a,this.float32[l+6]=o,e}}vu.prototype.bytesPerElement=28,Zs(vu,"StructArrayLayout7f28");class bu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,n,i,s,a,o,l,u,c)}emplace(e,t,r,n,i,s,a,o,l,u,c,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=r,this.float32[d+2]=n,this.float32[d+3]=i,this.float32[d+4]=s,this.float32[d+5]=a,this.float32[d+6]=o,this.float32[d+7]=l,this.float32[d+8]=u,this.float32[d+9]=c,this.float32[d+10]=h,e}}bu.prototype.bytesPerElement=44,Zs(bu,"StructArrayLayout11f44");class wu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,n,i,s,a,o,l)}emplace(e,t,r,n,i,s,a,o,l,u){const c=9*e;return this.float32[c+0]=t,this.float32[c+1]=r,this.float32[c+2]=n,this.float32[c+3]=i,this.float32[c+4]=s,this.float32[c+5]=a,this.float32[c+6]=o,this.float32[c+7]=l,this.float32[c+8]=u,e}}wu.prototype.bytesPerElement=36,Zs(wu,"StructArrayLayout9f36");class _u extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=r,e}}_u.prototype.bytesPerElement=8,Zs(_u,"StructArrayLayout2f8");class Au extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=6*e;return this.uint32[3*e+0]=t,this.uint16[s+2]=r,this.uint16[s+3]=n,this.uint16[s+4]=i,e}}Au.prototype.bytesPerElement=12,Zs(Au,"StructArrayLayout1ul3ui12");class Mu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Mu.prototype.bytesPerElement=2,Zs(Mu,"StructArrayLayout1ui2");class Iu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m)}emplace(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=s,this.float32[g+5]=a,this.float32[g+6]=o,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=y,e}}Iu.prototype.bytesPerElement=64,Zs(Iu,"StructArrayLayout16f64");class Su extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s,a)}emplace(e,t,r,n,i,s,a,o){const l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=s,this.float32[u+3]=a,this.float32[u+4]=o,e}}Su.prototype.bytesPerElement=20,Zs(Su,"StructArrayLayout4ui3f20");class Bu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}Bu.prototype.bytesPerElement=2,Zs(Bu,"StructArrayLayout1i2");class Eu extends Gl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}Eu.prototype.bytesPerElement=1,Zs(Eu,"StructArrayLayout1ub1");class Pu extends Nl{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]}}Pu.prototype.size=40;class zu extends cu{get(e){return new Pu(this,e)}}Zs(zu,"CollisionBoxArray");class Tu extends Nl{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(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}Tu.prototype.size=60;class Vu extends mu{get(e){return new Tu(this,e)}}Zs(Vu,"PlacedSymbolArray");class Fu extends Nl{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}Fu.prototype.size=80;class ku extends yu{get(e){return new Fu(this,e)}}Zs(ku,"SymbolInstanceArray");class Cu extends Wl{getoffsetX(e){return this.float32[1*e+0]}}Zs(Cu,"GlyphOffsetArray");class Du extends ql{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Zs(Du,"SymbolLineVertexArray");class Ru extends Nl{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]}}Ru.prototype.size=12;class Lu extends Au{get(e){return new Ru(this,e)}}Zs(Lu,"FeatureIndexArray");class Ou extends uu{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Zs(Ou,"FillExtrusionCentroidArray");class Uu extends Nl{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Uu.prototype.size=6;class Nu extends Xl{get(e){return new Uu(this,e)}}Zs(Nu,"FillExtrusionWallArray");const ju=$l([{name:"a_pos",components:2,type:"Int16"}],4),Gu=$l([{name:"a_road_z_offset",components:1,type:"Float32"}],4),$u=$l([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),Hu=$l([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);class qu{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,r,n,i){let s=this.segments.at(-1);return e>qu.MAX_VERTEX_ARRAY_LENGTH&&nt(`Max vertices per segment is ${qu.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!s||s.vertexLength+e>qu.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n||void 0!==i&&s&&void 0!==s.batchIndex&&s.batchIndex!==i)&&(s={vertexOffset:t,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(s.sortKey=n),void 0!==i&&(s.batchIndex=i),this.segments.push(s)),s}prepareSegment(e,t,r,n,i){return this._prepareSegment(e,t.length,r.length,n,i)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy();}static simpleSegment(e,t,r,n){return new qu([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Xu(e,t){return 256*(e=$e(Math.floor(e),0,255))+$e(Math.floor(t),0,255)}qu.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Zs(qu,"SegmentVector");const Zu=$l([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Wu=$l([{name:"a_pattern_b",components:4,type:"Uint16"}]),Yu=$l([{name:"a_dash",components:4,type:"Uint16"}]);class Ku{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,r,n){this.ids.push(Ju(e)),this.positions.push(t,r,n);}eachPosition(e,t){const r=Ju(e);let n=0,i=this.ids.length-1;for(;n>1;this.ids[e]>=r?i=e:n=e+1;}for(;this.ids[n]===r;)t(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(e,t){const r=new Float64Array(e.ids),n=new Uint32Array(e.positions);return Qu(r,n,0,r.length-1),t&&(t.add(r.buffer),t.add(n.buffer)),{ids:r,positions:n}}static deserialize(e){const t=new Ku;let r;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==r&&t.uniqueIds.push(e),r=e;return t.indexed=!0,t}}function Ju(e){const t=+e;return Number.isSafeInteger(t)?t:nr(String(e))}function Qu(e,t,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(e[s]i);if(s>=a)break;ec(e,s,a),ec(t,3*s,3*a),ec(t,3*s+1,3*a+1),ec(t,3*s+2,3*a+2);}a-r`u_${e}`),this.type=r,this.context=n;}setUniform(e,t,r,n,i){const s=n.constantOr(this.value);t.set(e,i,s instanceof mr?s.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):s);}getBinding(e,t){return "color"===this.type?new lc(e):new nc(e)}}class fc{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1;}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern;}setUniform(e,t,r,n,i){let s=null;"u_pattern"!==i&&"u_dash"!==i||(s=this.pattern),"u_pattern_b"===i&&(s=this.patternTransition),"u_pixel_ratio"===i&&(s=this.pixelRatio),s&&t.set(e,i,s);}getBinding(e,t){return "u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new ac(e):new nc(e)}}class mc{constructor(e,t,r,n){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0})),this.paintVertexArray=new n;}populatePaintArray(e,t,r,n,i,s,a,o){const l=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new Za(0,{brightness:s,worldview:o}),t,{},i,n,a):"constant"===this.expression.kind&&this.expression.value,c=dc(this.lutExpression,t,{},n,i,s,a,o);this.paintVertexArray.resize(e),this._setPaintValue(l,e,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,a,o){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:a,worldview:o},r,n,void 0,i):"constant"===this.expression.kind&&this.expression.value,u=dc(this.lutExpression,r,n,i,void 0,a,void 0,o);this._setPaintValue(e,t,l,u?null:this.context.lut);}_setPaintValue(e,t,r,n){if("color"===this.type){const i=hc(r.toPremultipliedRenderColor(n));for(let r=e;r`u_${e}_t`),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0})),this.paintVertexArray=new s;}populatePaintArray(e,t,r,n,i,s,a,o){const l=this.expression.evaluate(new Za(this.context.zoom,{brightness:s,worldview:o}),t,{},i,n,a),u=this.expression.evaluate(new Za(this.context.zoom+1,{brightness:s,worldview:o}),t,{},i,n,a),c=dc(this.lutExpression,t,{},n,i,s,a,o),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,a,o){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:a,worldview:o},r,n,void 0,i),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:a,worldview:o},r,n,void 0,i),c=dc(this.lutExpression,r,n,i,void 0,a,void 0,o);this._setPaintValue(e,t,l,u,c?null:this.context.lut);}_setPaintValue(e,t,r,n,i){if("color"===this.type){const s=hc(r.toPremultipliedRenderColor(i)),a=hc(n.toPremultipliedRenderColor(i));for(let r=e;r!0){this.binders={},this._buffers=[],this.context=t;const n=[],i=e;for(const s in e.paint._values){const a=i.paint.get(s);if(s.endsWith("-use-theme"))continue;if(!r(s))continue;if(!(a instanceof to&&Ss(a.property.specification)))continue;const o=wc(s,e.type),l=a.value,u=a.property.specification.type,c=!!a.property.useIntegerZoom,h="line-dasharray"===s||s.endsWith("pattern"),d=i.paint.get(`${s}-use-theme`),p="line-dasharray"===s&&"constant"!==i.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||p)if("source"===l.kind||p||h){const t=Mc(s,u,"source");this.binders[s]=h?new gc(l,o,u,t,e.id):new mc(l,o,u,t),n.push(`/a_${s}`);}else {const e=Mc(s,u,"composite");this.binders[s]=new yc(l,o,u,c,t,e),n.push(`/z_${s}`);}else this.binders[s]=h?new fc(l.value,o):new pc(l.value,o,u,t),n.push(`/u_${s}`);d&&(this.binders[s].lutExpression=d.value);}this.cacheKey=n.sort().join("");}updateExpressions(e){const t=e;for(const e in this.binders){const r=this.binders[e];if(r instanceof mc||r instanceof yc||r instanceof gc){const n=t.paint.get(e);r.expression=n.value;}}}getMaxValue(e){const t=this.binders[e];return t instanceof mc||t instanceof yc?t.maxValue:0}populatePaintArrays(e,t,r,n,i,s,a,o){for(const l in this.binders){const u=this.binders[l];u.context=this.context,(u instanceof mc||u instanceof yc||u instanceof gc)&&u.populatePaintArray(e,t,r,n,i,s,a,o);}}setConstantPatternPositions(e,t){for(const r in this.binders){const n=this.binders[r];n instanceof fc&&n.setConstantPatternPositions(e,t);}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof gc?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,r,n,i,s,a,o,l,u){let c=!1;const h=Object.keys(e),d=0!==h.length&&!o,p=d?h:t.uniqueIds;this.context.lut=i.lut;for(const o in this.binders){const h=this.binders[o];if(h.context=this.context,(h instanceof mc||h instanceof yc||h instanceof gc)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=i.paint.get(o);h.expression=f.value;for(const r of p){const i=e[r.toString()];t.eachPosition(r,(e,t,r)=>{const o=n.feature(e);h.updatePaintArray(t,r,o,i,s,a,l,u);});}if(!d)for(const t of r.uniqueIds){const i=e[t.toString()];r.eachPosition(t,(e,t,r)=>{const o=n.feature(e);h.updatePaintArray(t,r,o,i,s,a,l,u);});}c=!0;}}return c}defines(){const e=[];for(const t in this.binders){const r=this.binders[t];(r instanceof pc||r instanceof fc)&&e.push(...r.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`));}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof pc||n instanceof fc||n instanceof yc)for(const i of n.uniformNames)t.push({name:i,property:r,binding:n.getBinding(e,i)});}return t}setUniforms(e,t,r,n,i){for(const{name:t,property:s,binding:a}of r)this.binders[s].setUniform(e,a,i,n.get(s),t);}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof mc||t instanceof yc||t instanceof gc)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof gc&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer);}}upload(e){for(const t in this.binders){const r=this.binders[t];(r instanceof mc||r instanceof yc||r instanceof gc)&&r.upload(e);}this.updatePaintBuffers();}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof mc||t instanceof yc||t instanceof gc)&&t.destroy();}}}class vc{constructor(e,t,r=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new xc(n,t,r);this.needsUpload=!1,this._featureMap=new Ku,this._featureMapWithoutIds=new Ku,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,r,n,i,s,a,o,l){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,n,i,s,a,o,l);void 0!==t.id?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,r,n,i,s,a,o){for(const l of r)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,i,s,a||0,o)||this.needsUpload;}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1;}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy();}updateExpressions(e){const t=new Set;for(const r of e){const e=this.programConfigurations[r.id];e&&(e.updateExpressions(r),t.add(r.id));}for(const e in this.programConfigurations)t.has(e)||delete this.programConfigurations[e];}}const bc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function wc(e,t){return bc[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const _c={"line-pattern":{source:ru,composite:ru},"fill-pattern":{source:ru,composite:ru},"fill-extrusion-pattern":{source:ru,composite:ru},"line-dasharray":{source:nu,composite:nu}},Ac={color:{source:_u,composite:ou},number:{source:Wl,composite:_u}};function Mc(e,t,r){const n=_c[e];return n&&n[r]||Ac[t][r]}Zs(pc,"ConstantBinder"),Zs(fc,"PatternConstantBinder"),Zs(mc,"SourceExpressionBinder",{omit:["expression"]}),Zs(gc,"PatternCompositeBinder",{omit:["expression"]}),Zs(yc,"CompositeExpressionBinder",{omit:["expression"]}),Zs(xc,"ProgramConfiguration",{omit:["_buffers"]}),Zs(vc,"ProgramConfigurationSet");class Ic{constructor(e,t,r){this.layoutVertexArray=new ql,this.indexArray=new fu,this.lineIndexArray=new uu,this.triangleSegments=new qu,this.lineSegments=new qu,this.programConfigurations=new vc(e,{zoom:t,lut:r}),this.uploaded=!1;}update(e,t,r,n,i,s,a,o){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o);}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ju.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy());}populatePaintArrays(e,t,r,n,i,s,a){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,r,n,i,s,void 0,a);}}Zs(Ic,"FillBufferData");class Sc{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new Ic(e.layers,e.zoom,e.lut),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.sourceLayerIndex=e.sourceLayerIndex,this.sourceLayerName=e.sourceLayerName||"",this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.hasPattern=ul("fill",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ol(a,e);if(!this.layers[0]._featureFilter.filter(new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r,t.availableImages):void 0,d={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Ll(a,r,n),patterns:{},sortKey:h};s.push(d);}i&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const e=cl("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[s].feature,i,s,a,this.index);}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this);}update(e,t,r,n,i,s,a){this.bufferData.update(e,t,r,n,i,s,a,this.worldview),this.hdExt&&this.hdExt.update(e,t,r,n,i,s,a,this.worldview);}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.hdExt&&this.hdExt.updateExpressions(e);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this);}isEmpty(){return this.bufferData.isEmpty()&&(!this.hdExt||this.hdExt.isEmpty())}uploadPending(){return !this.uploaded||this.bufferData.needsUpload()||null!=this.hdExt&&this.hdExt.needsUpload()}upload(e){this.bufferData.upload(e),this.hdExt&&this.hdExt.upload(e);}destroy(){this.bufferData.destroy(),this.hdExt&&this.hdExt.destroy();}addFeature(e,t,r,n,i,s=[],a,o){const l=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,u=this.bufferData.indexArray.length,c=Be(t,500);null!=this.hdExt&&this.hdExt.handleFeature(e,c,r,n,o,this)||this.addGeometry(c,this.bufferData),this.bufferData.populatePaintArrays(e,r,i,s,n,a,this.worldview),this.hdExt&&this.hdExt.populatePaintArrays(e,r,i,s,n,a,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,u,this.bufferData.indexArray.length,l);}addGeometry(e,t,r,n){let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=null;r&&(a=r.elevationSampler.constantElevation(r.elevation,r.bias),null!=a&&(i=a,s=a));const o=r?t:null,l=(e,t,n)=>{if(null!=r)if(t.push(e),null!=a)o.elevatedLayoutVertexArray.emplaceBack(a),n.push(a);else {const t=r.elevationSampler.pointElevation(e,r.elevation,r.bias);o.elevatedLayoutVertexArray.emplaceBack(t),n.push(t),i=Math.min(i,t),s=Math.max(s,t);}};for(const i of e){let e=0;for(const t of i)e+=t.length;const s=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),a=s.vertexLength,o=[],u=[],c=[],h=[],d=[],p=t.layoutVertexArray.length;for(const e of i){if(0===e.length)continue;e!==i[0]&&u.push(o.length/2);const n=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),s=n.vertexLength;r&&d.push(t.layoutVertexArray.length-p),l(e[0],c,h),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(s+e.length-1,s),o.push(e[0].x),o.push(e[0].y);for(let r=1;r0&&r&&n){const e=r.elevation.isTunnel(),t=r.elevation.safeArea,i=n.addVertices(c,h);n.addTriangles(f,i,e);const s=d.length;if(s>0){for(let a=0;a>3,0===s)continue}if(s--,1===i)a+=e.readSVarint(),o+=e.readSVarint(),n&&r.push(n),n=[new be(a,o)];else if(2===i)a+=e.readSVarint(),o+=e.readSVarint(),n&&n.push(new be(a,o));else {if(7!==i)throw new Error(`unknown command ${i}`);n&&n.push(n[0].clone());}}return n&&r.push(n),r}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;for(;e.pos>3,0===n)continue}if(n--,1===r||2===r)i+=e.readSVarint(),s+=e.readSVarint(),io&&(o=i),su&&(u=s);else if(7!==r)throw new Error(`unknown command ${r}`)}return [a,l,o,u]}toGeoJSON(e,t,r){const n=this.extent*Math.pow(2,r),i=this.extent*e,s=this.extent*t,a=this.loadGeometry();function o(e){return [360*(e.x+i)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function l(e){return e.map(o)}let u;if(1===this.type){const e=[];for(const t of a)e.push(t[0]);const t=l(e);u=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};}else if(2===this.type){const e=a.map(l);u=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};}else {if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return [e];const r=[];let n,i;for(let s=0;s=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Dc(this._pbf,t,this.extent,this._keys,this._values)}}function Oc(e){let t=null;const r=e.readVarint()+e.pos;for(;e.pos1){if(Hc(e,t))return !0;for(let n=0;n1?r:r.sub(t)._mult(i)._add(t))}function Kc(e,t){let r,n,i,s=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-n.x)*(t.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function Jc(e,t){let r=!1;for(let n=0,i=e.length-1;nt.y!=a.y>t.y&&t.x<(a.x-s.x)*(t.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function Qc(e,t,r,n,i){for(const s of e)if(t<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new be(t,r),new be(t,i),new be(n,i),new be(n,r)];if(e.length>2)for(const t of s)if(Jc(e,t))return !0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return !1;const s=it(e,t,r[0]);return s!==it(e,t,r[1])||s!==it(e,t,r[2])||s!==it(e,t,r[3])}function th(e,t,r,n,i,s){let a=t.y-e.y,o=e.x-t.x;if(s=s||0){const e=a*a+o*o;if(0===e)return !0;const t=Math.sqrt(e);a/=t,o/=t;}return !((r.x-e.x)*a+(r.y-e.y)*o-s<0||(n.x-e.x)*a+(n.y-e.y)*o-s<0||(i.x-e.x)*a+(i.y-e.y)*o-s<0)}function rh(e,t,r,n,i,s,a){return !(th(e,t,n,i,s,a)||th(t,r,n,i,s,a)||th(r,e,n,i,s,a)||th(n,i,e,t,r,a)||th(i,s,e,t,r,a)||th(s,n,e,t,r,a))}class nh extends be{constructor(e,t,r){super(e,t),this.z=r;}}class ih extends nh{constructor(e,t,r,n){super(e,t,r),this.w=n;}}function sh(e,t,r,n){const i="x"===r?"y":"x",s=(n-e[r])/(t[r]-e[r]);e[i]=Math.round(e[i]+(t[i]-e[i])*s),e[r]=n,Object.hasOwn(e,"z")&&(e.z=pr(e.z,t.z,s)),Object.hasOwn(e,"w")&&(e.w=pr(e.w,t.w,s));}function ah(e,t,r,n){const i=r,s=n;for(const r of ["x","y"]){let n=e,a=t;n[r]>=a[r]&&(n=t,a=e),n[r]i&&sh(n,a,r,i),n[r]s&&sh(a,n,r,s);}}function oh(e,t,r,n,i,s){const a=[];for(let o=0;o=n&&d.x>=n||(c.x>=n?c=new be(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round():d.x>=n&&(d=new be(n,c.y+(n-c.x)/(d.x-c.x)*(d.y-c.y))._round()),c.y>=i&&d.y>=i||(c.y>=i?c=new be(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round():d.y>=i&&(d=new be(c.x+(i-c.y)/(d.y-c.y)*(d.x-c.x),i)._round()),u&&c.equals(u.at(-1))||(u=[c],a.push(u),s&&s.push({progress:{min:f+uh(m,y,c)*p,max:1},parentIndex:o,prevPoint:m,nextPoint:y})),u.push(d),s&&(s.at(-1).progress.max=f+uh(m,y,d)*p,s.at(-1).nextPoint=y)))));}if(s&&h>0)for(let e=c;ee.t-t.t);let a=0,o=0,l=[];for(n.push(l);a!==e.length;){if(o===s.length){for(;a!==e.length;)0!==l.length&&l.at(-1).equals(e[a])||l.push(e[a]),a++;break}s[o].t<=a?(0!==l.length&&l.at(-1).equals(s[o].point)||l.push(s[o].point),Math.trunc(s[o].t),o++):(0!==l.length&&l.at(-1).equals(e[a])||l.push(e[a]),a++);}}function uh(e,t,r){return e.x!==t.x?(r.x-e.x)/(t.x-e.x):e.y!==t.y?(r.y-e.y)/(t.y-e.y):0}function ch(e,{width:t,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==t*r*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(t*r*n);return e.width=t,e.height=r,e.data=i,e}function hh(e,t,r){const{width:n,height:i}=t;n===e.width&&i===e.height||(dh(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r,null),e.width=n,e.height=i,e.data=t.data);}function dh(e,t,r,n,i,s,a,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,u=t.data,c=4===s&&o;for(let o=0;o1&&(a=e[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const d=t/r*(n+1);if(a.isDash){const e=n-Math.abs(d);h=Math.sqrt(c*c+e*e);}else h=n-Math.sqrt(c*c+d*d);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const r=e[t],n=e[t+1];r.zeroLength?e.splice(t,1):n&&n.isDash===r.isDash&&(n.left=r.left,e.splice(t,1));}const r=e[0],n=e.at(-1);r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=e[s];for(let r=0;r1&&(a=e[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128));}}addDash(e,t){const r=this.getKey(e,t);if(this.positions[r])return this.positions[r];const n="round"===t,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return nt("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={};}),this.layoutVertexArray=new eu,this.layoutVertexArray2=new tu,this.patternVertexArray=new tu,this.indexArray=new fu,this.programConfigurations=new vc(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new qu,this.sourceLayerName=e.sourceLayerName||"",this.maxLineLength=0,this.zOffsetVertexArray=new ou,this.elevationIdColVertexArray=new tu,this.elevationGroundScaleVertexArray=new Wl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.showElevationIdDebug=t.showElevationIdDebug,this.terrainEnabled=t.terrainEnabled,this.hasPattern=ul("line",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Pl(r);const s=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===s)this.elevationType="road";else {const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==s&&"ground"!==s&&t?"none":"offset","offset"===this.elevationType&&"none"===s&&nt(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===s;}const a=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==a;const o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ol(s,e);if(!this.layers[0]._featureFilter.filter(new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Ll(s,r,n),patterns:{},sortKey:h};o.push(d);}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:u}=t,c=this.addConstantDashes(l);for(const n of o){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const e=cl("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,l.positions,t.availableImages,t.brightness,t.elevationFeatures,t.elevationParams,t.crossSourceElevationEnabled);u.insert(e[s].feature,i,s,a,this.index);}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this),this.hdExt&&this.hdExt.endPopulate();}addConstantDashes(e){let t=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)t=!0;else {const t=i.value,r=n.value;if(!r)continue;e.addDash(r,t);}}return t}addFeatureDashes(e,t){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===s.kind)continue;let a,o;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:r},e);o="constant"===s.kind?s.value:s.evaluate({zoom:r},e),t.addDash(a,o),e.patterns[n.id]=[t.getKey(a,o)];}}update(e,t,r,n,i,s,a,o,l){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,l);}updateExpressions(e){this.programConfigurations.updateExpressions(e);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures,e.elevationParams,e.crossSourceElevationEnabled);this.hdExt&&(this.hdExt.buildFrcSegments(this),this.hdExt.endPopulate());}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Fc)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Cc)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Ec.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,Pc.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,zc.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Tc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(e,t){let r,n;if(t&&t>0?(r=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(r="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,r)&&Object.hasOwn(e.properties,n))return {start:+e.properties[r],end:+e.properties[n]}}addFeature(e,t,r,n,i,s,a,o,l,u){const c=this.layers[0].layout,h=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,d=this.indexArray.length,p=c.get("line-join").evaluate(e,{}),f=c.get("line-cap").evaluate(e,{}),m=c.get("line-miter-limit"),y=c.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const g=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=c.get("line-z-offset").value;const x=this.layers[0].paint,v=x.get("line-width").value;"constant"!==v.kind&&!1===v.isLineProgressConstant&&(this.variableWidthValue=v);const b=x.get("line-emissive-strength").value;if("constant"!==b.kind&&!1===b.isLineProgressConstant&&(this.variableEmissiveStrengthValue=b),this.isSeaLevelReference){const e=c.get("line-elevation-ground-scale").value;"constant"===e.kind&&0===e.value||(this.elevationGroundScaleValue=e);}if(null==this.hdExt||!this.hdExt.handleFeature(e,t,n,o,l,!!u,p,f,m,y,this))for(let r=0;r0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,i,s,n,a,void 0,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,d,this.indexArray.length,h);}fillNonElevatedRoadSegment(e){for(let t=Math.max(e,this.zOffsetVertexArray.length);t0,h=o&&o.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},n=1;if(o){const e=this.lineClips.end-this.lineClips.start;r=function(e,t,r){return {min:ht(e.min,t,r),max:ht(e.max,t,r)}}(o.progress,{min:0,max:1},r),e>0&&(n=(r.max-r.min)/e);}const i=+t.properties.mapbox_clip_feature_len,s=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(i)||Number.isNaN(s)){for(let t=0;t=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f0,z=this.overscaling<=16?122880/(512*this.overscaling):0;if(r&&"round"===o)if(Ss&&(o="bevel"),"bevel"===o&&(S>2&&(o="flipbevel"),S2*z){const t=y.sub(y.sub(g)._mult(z/e)._round());this.updateDistance(g,t),this.addCurrentVertex(t,v,0,0,m,A),g=t;}this.updateDistance(g,y),M._mult(S),this.addCurrentVertex(y,M,0,0,m,A);const t=y.dist(x);if(t>2*z){const e=y.add(x.sub(y)._mult(z/t)._round());this.updateDistance(y,e),this.addCurrentVertex(e,b,0,0,m,A),y=e;}}else M._mult(S),this.addCurrentVertex(y,M,0,0,m,A);else if("flipbevel"===o){if(S>100)M=b.mult(-1);else {const e=S*v.add(b).mag()/v.sub(b).mag();M._perp()._mult(e*(P?-1:1));}this.addCurrentVertex(y,M,0,0,m,A),this.addCurrentVertex(y,M.mult(-1),0,0,m,A);}else if("bevel"===o||"fakeround"===o){const e=y.dist(g);let t=1;if("offset"===this.elevationType&&"bevel"===o&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=A&&g&&x){const r=4*z;e1){this.lineSoFar=e.w;const r=(t.x-e.x)/c,n=(t.y-e.y)/c,i=(t.z-e.z)/c,s=(t.w-e.w)/c,a=t.x-e.x,o=t.y-e.y,d=Math.sqrt(a*a+o*o);if(0===d)return;const p=-o/d,f=a/d,m=p,y=f,g=-p,x=-f;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u,null!=l&&(this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth,l.variableEmissiveStrength),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){const e=l?l.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(e);}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance;}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance();}}function Ah(e,t,r){return e.xr||e.yr}Zs(_h,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Mh=$l([{name:"a_pos",components:2,type:"Int16"}],4),Ih=$l([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Sh=$l([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Bh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new ql,this.indexArray=new fu,this.segments=new qu,this.programConfigurations=new vc(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){const i=this.layers[0],s=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:i,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ol(i,e);if(!this.layers[0]._featureFilter.filter(new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=a?a.evaluate(c,{},r):void 0,d={id:o,properties:i.properties,type:i.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Ll(i,r,n),patterns:{},sortKey:h};s.push(d);}a&&s.sort((e,t)=>e.sortKey-t.sortKey);let o=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new iu,o=n.projection);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n,l=e[s].feature;this.addFeature(n,i,s,t.availableImages,r,o,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,i,s,a,this.index);}this.hdExt&&this.hdExt.finalize();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview);}updateExpressions(e){this.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Mh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Sh.members)),this.hdExt&&this.hdExt.upload(e)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.hdExt&&this.hdExt.destroy());}addFeature(e,t,r,n,i,s,a,o){this.hdExt&&this.hdExt.beginFeature(e,o,i);for(const r of t)for(const t of r){const r=t.x,n=t.y;if(r<0||r>=Tn||n<0||n>=Tn)continue;if(s){const e=s.projectTilePoint(r,n,i),t=s.upVector(i,r,n);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t);}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),o=a.vertexLength;this.addCircleVertex(r,n,-1,-1),this.addCircleVertex(r,n,1,-1),this.addCircleVertex(r,n,1,1),this.addCircleVertex(r,n,-1,1),this.hdExt&&this.hdExt.writeVertexQuad(r,n),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),a.vertexLength+=4,a.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},n,i,a,void 0,this.worldview);}addCircleVertex(e,t,r,n){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*t+(n+1)/2);}addGlobeExtVertex(e,t){const r=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*r,t[1]*r,t[2]*r);}}Zs(Bh,"CircleBucket",{omit:["layers"]});const Eh=$l([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ph=$l([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),zh=$l([{name:"a_projected_pos",components:4,type:"Float32"}],4);$l([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Th=$l([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Vh=$l([{name:"a_feature_index",components:1,type:"Float32"}],4),Fh=$l([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),kh=$l([{name:"a_texb",components:2,type:"Uint16"}]),Ch=$l([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Dh=$l([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);$l([{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 Rh=$l([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Lh=$l([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);$l([{name:"triangle",components:3,type:"Uint16"}]),$l([{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"}]),$l([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),$l([{type:"Float32",name:"offsetX"}]),$l([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Oh=class e{static getBlockIndices(t){let r=e._blockIndicesTemplate;if(!r){r=e._blockIndicesTemplate=new Uint32Array(t);for(let e=0;et.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${t.maxUniformBlockSize}`);if(this.headerBuffer=r.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.headerBuffer),r.bufferData(r.UNIFORM_BUFFER,e.HEADER_BYTES,r.DYNAMIC_DRAW),this.propertiesBuffer=r.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.propertiesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),this.blockIndicesBuffer=r.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");r.bindBuffer(r.UNIFORM_BUFFER,this.blockIndicesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),r.bindBuffer(r.UNIFORM_BUFFER,null);}writeDataDrivenBlock(t,r){const n=this.headerData,i=4*n[2];if(0===i)return;const s=r*i;if(s+i>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${r} exceeds propertiesData capacity`);const a=n[0],o=n[1],l=o>>>16;for(let r=0;r<9;r++)a&1<this._propsDirtyMax&&(this._propsDirtyMax=u);}rightSizeForTransfer(){const e=-1===this._propsDirtyMax?0:this._propsDirtyMax;e{if(!n)return;const s=r.getUniformBlockIndex(t,e);s!==r.INVALID_INDEX&&(r.uniformBlockBinding(t,s,i),r.bindBufferBase(r.UNIFORM_BUFFER,i,n));},i=3*this.batchIndex;n("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,i),n("SymbolPaintPropertiesUniform",this.propertiesBuffer,i+1),n("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,i+2);}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null);}}};Oh.HEADER_DWORDS=12,Oh.HEADER_BYTES=48,Oh.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],Oh.EVAL_FLAT_ZOOM_OFFSETS=[24,26,28,30,32,34,36,38,40],Oh.EVAL_FLAT_TOTAL=42,Oh._blockIndicesTemplate=null;let Uh=Oh;function Nh(e,t,r,n,i,s,a,o){return !!e&&("constant"===e.kind?"none"===e.value:"none"===e.evaluate({zoom:0,brightness:s,worldview:o},t,r,i,n,a))}function jh(e){if(!(e instanceof to))return !1;const t=e.value;return ("source"===t.kind||"composite"===t.kind)&&t.isStateDependent}Zs(Uh,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});const Gh=["icon","text"].map(e=>[`${e}-color`,`${e}-halo-color`,`${e}-opacity`,`${e}-halo-width`,`${e}-halo-blur`,`${e}-emissive-strength`,`${e}-occlusion-opacity`,"symbol-z-offset",`${e}-translate`]),$h=new Float32Array(Uh.EVAL_FLAT_TOTAL),Hh=[0,0],qh=new WeakMap;class Xh{constructor(e,t,r,n,i="",s,a){this.layer=e,this.zoom=t,this.lut=r,this.isText=n,this.worldview=i,this.maxUniformBufferBindings=s||24,this.uboSizeDwords=a||4096,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.allFormattedSections=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.ubos=[],this.featureCount=0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.cachedConstantPaint=null,this.activeAppearanceByVtIndex=null,this.sharedZoomRanges=new Float32Array(18),this._zoomRangeScratch=new Float32Array(2),this._floorZoom=Math.floor(this.zoom),this.header=new Uint32Array(Uh.HEADER_DWORDS),this.updateHeader(),this.isAllConstant=0===this.header[0];const o=4*this.header[2];this.maxFeaturesPerBatch=0===o?Number.MAX_SAFE_INTEGER:Math.floor(this.uboSizeDwords/o);}updateHeader(){const e=this.layer.paint;let t=0,r=0,n=0,i=0,s=0,a=!0;const o=this._floorZoom,l=Gh[+this.isText];for(let u=0;u<9;u++){const c=l[u],h=u<2,d=8===u,p=e.get(c),f=!(!p||"function"!=typeof p.isConstant||p.isConstant()),m=this._appearancesHavePaintProperties(c);if(!f&&!m){const e=this._layerUnevaluated(c);e&&e.expression&&"camera"===e.expression.kind&&(i|=1<>>16&1<{if(!e)return;this._computeZoomRange(e,t,this._zoomRangeScratch,0);const o=this._zoomRangeScratch[0],l=this._zoomRangeScratch[1];r?o===s&&l===a||(n=!0):(r=!0,s=o,a=l,i=e);};o(this._zoomExprOf(this._layerUnevaluated(e)));for(const t of this.layer.getAppearances()||[])t.hasPaintProperty(e)&&o(this._zoomExprOf(t.getUnevaluatedPaintProperty(e)));return {hasZoom:r,differs:n,representative:i}}evaluateAllProperties(e,t,r,n,i,s,a){const o={brightness:i,worldview:this.worldview},l={feature:e,featureState:t,canonical:r,availableImages:n,params:new Za(this.zoom,o),paramsNext:new Za(this.zoom+1,o),formattedSection:s,activeAppearance:a},u=this.header,c=Gh[+this.isText],h=u[1]>>>16;for(let e=0;e<9;e++){const t=c[e],r=8===e,n=!!(u[1]&1<0)if(null==e.interpolationType){i=s=1;for(const e of a)if(e>t&&et&&a[0]t.hasPaintProperty(e))}hasStateDependentPaint(e){const t=e.paint,r=Gh[+this.isText];for(const e of r)if(jh(t.get(e)))return !0;for(const t of e.getAppearances()||[])for(const e of r){const r=e;if(t.hasPaintProperty(r)&&jh(t.paintProperties.get(r)))return !0}return !1}hasPerFeatureTranslate(){return !!(256&this.header[0])}getCurrentBatchIndex(){return 0===this.maxFeaturesPerBatch?0:Math.floor(this.featureCount/this.maxFeaturesPerBatch)}_writeFeatureBlock(e,t){const r=this.isAllConstant?0:e;let n=Math.floor(r/this.maxFeaturesPerBatch),i=r%this.maxFeaturesPerBatch;this._batchExceedsDeviceLimit(n)&&(n=0,i=0);const s=this.ubos[n];return !!s&&(s.writeDataDrivenBlock(t,i),!0)}_batchExceedsDeviceLimit(e){return 3*e+2>=this.maxUniformBufferBindings}_reevaluateAt(e,t,r,n,i,s){if(!t)return;const a=this.allFeatureVtIndices[e],o=t.feature(a);if(!o)return;const l=this.allFeatureIds[e],u=null!=l&&i[l]||{},c={type:o.type,id:l,properties:o.properties||{},geometry:[]},h=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(a):void 0,d=this.evaluateAllProperties(c,u,r,n,s,(this.allFormattedSections?this.allFormattedSections[e]:void 0)||void 0,h);this._writeFeatureBlock(e,d);}_ensureRangeMaps(){if(!this.featureVertexRangesFromId){this.featureVertexRangesFromId=new Map,this.featureVertexRangesFromVtIndex=new Map;for(let e=0;e{const r=l[e],n=s.get(r);if(!n)return [0,0,0,1];const i=s.get(`${r}-use-theme`),u=Nh(i&&"string"!=typeof i?i.value:void 0,o,{},[],void 0,t,void 0,this.worldview)?null:this.lut;return (this.cameraMask&1<{const r=s.get(l[e]);if(!r)return t;if(this.cameraMask&1<=n?1:0:Math.max(0,Math.min(1,(t-n)/(i-n)));}}const d={fill_np_color:u(0),halo_np_color:u(1),opacity:c(2,1),halo_width:c(3,0),halo_blur:c(4,0),emissive_strength:c(5,0),occlusion_opacity:c(6,1),z_offset:c(7,0),zoomFactors:h};return this.cachedConstantUniforms=d,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,this.cachedConstantPaint=this.layer.paint,d}finalize(){for(const e of this.ubos)e.rightSizeForTransfer();}upload(e){for(const t of this.ubos)t.upload(e);}bind(e,t,r=0){this.ubos[r]&&this.ubos[r].bind(e,t);}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureCount=0,this.maxFeaturesPerBatch=0;}}Zs(Xh,"SymbolPropertyBinderUBO",{omit:["layer","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","cachedConstantPaint","activeAppearanceByVtIndex","featureVertexRangesFromId","featureVertexRangesFromVtIndex"]});const Zh=24;function Wh(e,t,r){return e.sections.forEach(e=>{e.text=function(e,t,r){const n=t.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Xa.applyArabicShaping&&(e=Xa.applyArabicShaping(e)),e}(e.text,t,r);}),e}const Yh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function Kh(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function Jh(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const Qh=4294967296,ed=1/Qh,td="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class rd{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length;}readFields(e,t,r=this.length){let n;for(;n=this.nextField(r);)e(n,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Qh;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Qh;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf,r=t[this.pos++];if(r<128)return r;let n,i=127&r;return n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,r){const n=r.buf;let i,s;if(s=n[r.pos++],i=(112&s)>>4,s<128)return nd(e,i,t);if(s=n[r.pos++],i|=(127&s)<<3,s<128)return nd(e,i,t);if(s=n[r.pos++],i|=(127&s)<<10,s<128)return nd(e,i,t);if(s=n[r.pos++],i|=(127&s)<<17,s<128)return nd(e,i,t);if(s=n[r.pos++],i|=(127&s)<<24,s<128)return nd(e,i,t);if(s=n[r.pos++],i|=(1&s)<<31,s<128)return nd(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this))))}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&td?td.decode(this.buf.subarray(t,e)):function(e,t,r){let n="",i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+u>r)break;1===u?t<128&&(l=t):2===u?(s=e[i+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===u?(s=e[i+1],a=e[i+2],128==(192&s)&&128==(192&a)&&(l=(15&t)<<12|(63&s)<<6|63&a,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=e[i+1],a=e[i+2],o=e[i+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(l=(15&t)<<18|(63&s)<<12|(63&a)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u;}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const r=this.readPackedEnd();for(;this.pos=e)return 0;const t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}skip(e){const t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else {if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8;}}}function nd(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function id(e,t,r){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(n),r.buf.copyWithin(e+n,e,r.pos);}function sd(e,t){const r=e.length;let n=t.buf,i=t.pos,s=t.length;for(let a=0;as)t.pos=i,t.writeVarint(r),n=t.buf,i=t.pos,s=t.length;else {for(;r>127;)n[i++]=r%128|128,r=Math.floor(r/128);n[i++]=r;}}t.pos=i;}function ad(e,t){for(let r=0;r=0&&r>=e&&bd[this.text.charCodeAt(r)];r--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const r=new xd;return r.text=this.text.substring(e,t),r.sectionIndex=this.sectionIndex.slice(e,t),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(gd.forText(e.scale,e.fontStack||t));const r=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function vd(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m=1,y=1){const g=xd.fromFeature(e,i,m,y);h===yd.vertical&&g.verticalizePunctuation(d);let x=[];const v=function(e,t,r,n,i,s,a=1){if(!e)return [];const o=[],l=function(e,t,r,n,i,s,a=1){let o=0;for(let r=0;r0&&l>w&&(w=l);}else {const e=r[o.fontStack];if(!e)continue;e[y]&&(M=e[y]);const n=t[o.fontStack];if(!n)continue;const s=n.glyphs[y];if(!s)continue;if(v=s.metrics,S=8203!==y?Zh:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,r=(e+t)*x;_-r/2;){if(a--,a<0)return !1;o-=e[a].dist(s),s=e[a];}o+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=t.dist(r);}return !0}function Nd(e){let t=0;for(let r=0;ru){const c=(u-l)/s,h=pr(n.x,i.x,c),d=pr(n.y,i.y,c),p=new Od(h,d,0,i.angleTo(n),r);return !a||Ud(e,p,o,a,t)?p:void 0}l+=s;}}function Hd(e,t,r,n,i,s,a,o,l){const u=jd(n,s,a),c=Gd(n,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&x=0&&d+u<=c){const r=new Od(g,x,0,m,t);n&&!Ud(e,r,s,n,i)||p.push(r);}}h+=f;}return o||p.length||a||(p=qd(e,h/2,r,n,i,s,a,!0,l)),p}function Xd(e){let t=0,r=0;for(const n of e)t+=n.w*n.h,r=Math.max(r,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let i=0,s=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const r=n[e];if(!(t.w>r.w||t.h>r.h)){if(t.x=r.x,t.y=r.y,s=Math.max(s,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===r.w&&t.h===r.h){const t=n.pop();t&&et.id?1:e.versiont.version?1:e.sxt.sx?1:e.syt.sy?1:0}function Wd(e){let t=0;for(let r=0;r0,Kd(e,r,this.iconDescriptors,s),Kd(t,r,this.patternDescriptors,s),this.iconDescriptors.sort(Zd),this.patternDescriptors.sort(Zd);let a=0;a=Yd(a,Wd(i)),a=Yd(a,1);const o=n?n.data:"";o&&(a=Yd(a,Wd(o))),a=Yd(a,1);for(const e of this.iconDescriptors)a=Yd(a,Wd(e.id)),a=Yd(a,e.version),a=Yd(a,e.sx),a=Yd(a,e.sy);a=Yd(a,1);for(const e of this.patternDescriptors)a=Yd(a,Wd(e.id)),a=Yd(a,e.version),a=Yd(a,e.sx),a=Yd(a,e.sy);this.hash=a;}subsetOf(e){return this.scope===e.scope&&this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,Zd)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,Zd)}isSubsetArray(e,t,r){let n=0,i=0;if(e.length>t.length)return !1;for(;n0&&u>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;s.texStorage2D(s.TEXTURE_2D,e,this.format,l,u),this.size=[l,u];}this.size&&(c?s.texSubImage2D(s.TEXTURE_2D,0,a,o,Qd(this.format),ep(this.format),e):"data"in e&&e.data&&s.texSubImage2D(s.TEXTURE_2D,0,a,o,r,n,Qd(this.format),ep(this.format),e.data)),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D);}bind(e,t,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,r,n,i){const{context:s}=this,{gl:a}=s;a.bindTexture(a.TEXTURE_2D,this.texture),t!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?e===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,n),this.wrapT=n),i!==this.compareMode&&(i?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_FUNC,i)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_COMPARE_MODE,a.NONE),this.compareMode=i);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class rp{static getImagePositionScale(e,t,r){if(t&&e){const{sx:t,sy:r}=e;return {x:t,y:r}}return {x:r,y:r}}constructor(e,t,r,n){this.paddedRect=e;const{pixelRatio:i,version:s,stretchX:a,stretchY:o,content:l,sdf:u,usvg:c}=t;this.pixelRatio=i,this.stretchX=a,this.stretchY=o,this.content=l,this.version=s,this.padding=r,this.sdf=u,this.usvg=c,this.scale=rp.getImagePositionScale(n,c,i);}get tl(){return [this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return [this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return [(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function np(e,t,r){const n=Gr.parse(e),i=function(e,t,r=[1,1]){return {x:0,y:0,w:(e.data?e.data.width:e.width*r[0])+2*t,h:(e.data?e.data.height:e.height*r[1])+2*t}}(t,r,[n.sx,n.sy]);return {bin:i,imagePosition:new rp(i,t,r,n),imageVariant:n}}function ip(e,t){const r=[];for(const[n,i]of e.entries()){const e=Gr.parse(n);e&&(r.push({key:n,value:i,variant:e}),t&&t.set(n,e));}r.sort((e,t)=>{const r=e.variant.id.toString().localeCompare(t.variant.id.toString());return 0!==r?r:e.variant.sx!==t.variant.sx?e.variant.sx-t.variant.sx:e.variant.sy!==t.variant.sy?e.variant.sy-t.variant.sy:e.key.localeCompare(t.key)});const n=new Map;for(const e of r)n.set(e.key,e.value);return n}class sp{constructor(e){this.sourceAtlasHash=e;}}class ap{constructor(e,t,r,n,i=""){const s=new Map,a=new Map;this.haveRenderCallbacks=[];const o=[],l=void 0!==n,u=l?new Map:void 0,c=l?ip(e,u):e,h=l?ip(t,u):t;this.addImages(c,s,1,o),this.addImages(h,a,2,o);const{w:d,h:p}=Xd(o),f=new fh({width:d||1,height:p||1});for(const[e,t]of c.entries()){const r=s.get(e).paddedRect;fh.copy(t.data,f,{x:0,y:0},{x:r.x+1,y:r.y+1},t.data,null,t.sdf);}for(const[e,t]of h.entries()){const n=a.get(e),i=n.paddedRect;let s=n.padding;const o=i.x+s,l=i.y+s,u=t.data.width,c=t.data.height;s=s>1?s-1:s,fh.copy(t.data,f,{x:0,y:0},{x:o,y:l},t.data,r),fh.copy(t.data,f,{x:0,y:c-s},{x:o,y:l-s},{width:u,height:s},r),fh.copy(t.data,f,{x:0,y:0},{x:o,y:l+c},{width:u,height:s},r),fh.copy(t.data,f,{x:u-s,y:0},{x:o-s,y:l},{width:s,height:c},r),fh.copy(t.data,f,{x:0,y:0},{x:o+u,y:l},{width:s,height:c},r),fh.copy(t.data,f,{x:u-s,y:c-s},{x:o-s,y:l-s},{width:s,height:s},r),fh.copy(t.data,f,{x:0,y:c-s},{x:o+u,y:l-s},{width:s,height:s},r),fh.copy(t.data,f,{x:0,y:0},{x:o+u,y:l+c},{width:s,height:s},r),fh.copy(t.data,f,{x:u-s,y:0},{x:o-s,y:l+c},{width:s,height:s},r);}this.lut=r,this.image=f,this.iconPositions=s,this.patternPositions=a,l&&(this.contentDescriptor=new Jd(c,h,n,r,i,u));}addImages(e,t,r,n){for(const[i,s]of e.entries()){const{bin:e,imagePosition:a,imageVariant:o}=np(i,s,r);t.set(i,a),n.push(e),s.hasRenderCallback&&this.haveRenderCallbacks.push(o.id);}}patchUpdatedImages(e,t,r,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const i of e.getUpdatedImages(r)){for(const n of this.iconPositions.keys()){const s=Gr.parse(n);if(ur.isEqual(s.id,i)){const s=e.getImage(i,r);this.patchUpdatedImage(this.iconPositions.get(n),s,t,null);}}for(const s of this.patternPositions.keys()){const a=Gr.parse(s);if(ur.isEqual(a.id,i)){const a=e.getImage(i,r);this.patchUpdatedImage(this.patternPositions.get(s),a,t,n||this.lut);}}}}patchUpdatedImage(e,t,r,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[i,s]=e.tl,a=e.sdf;if(this.lut||a){const e={width:t.data.width,height:t.data.height},o=new fh(e);fh.copy(t.data,o,{x:0,y:0},{x:0,y:0},e,n,a),r.update(o,{position:{x:i,y:s},recreateWhenResize:!1});}else r.update(t.data,{position:{x:i,y:s},recreateWhenResize:!1});}}Zs(rp,"ImagePosition"),Zs(ap,"ImageAtlas",{omit:["lut"]}),Zs(sp,"ImageAtlasReference");class op{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client";}loadGlyphRange(e,t,r,n,i){if("server"===this.fontstackCompositing)return void op.loadGlyphRange(e,t,r,n,i);const s=e.split(",").map(e=>e.trim()).filter(e=>e.length>0);0!==s.length?1!==s.length?this._loadMultipleFonts(s,t,r,n,i):this._loadFont(s[0],t,r,n,i):i(new Error("Empty fontstack"));}_loadMultipleFonts(e,t,r,n,i){const s=e.map(()=>null),a={completed:0,firstError:null,callbackCalled:!1},o=(t,r,n)=>{if(!a.callbackCalled&&(r&&!a.firstError&&(a.firstError=r),n&&(s[t]=n),a.completed++,a.completed===e.length)){a.callbackCalled=!0;const e=s.filter(e=>null!==e);if(0===e.length)return void i(a.firstError||new Error("All fonts failed to load"));const t=this._composeGlyphs(e);i(null,t);}};for(let i=0;i{o(i,e,t);});}_loadFont(e,t,r,n,i){const s=`${e}:${t}`;if(this.cachedRanges.has(s)){const e=this.cachedRanges.get(s);return void vt.frame(()=>i(null,e))}const a=this.pendingRequests.get(s);a?a.push(i):(this.pendingRequests.set(s,[i]),op.loadGlyphRange(e,t,r,n,(e,t)=>{e||this.cachedRanges.set(s,t||null);const r=this.pendingRequests.get(s);if(this.pendingRequests.delete(s),r)for(const n of r)n(e,t);}));}_composeGlyphs(e){const t={};let r,n;for(const i of e)if(void 0===r&&void 0!==i.ascender&&(r=i.ascender),void 0===n&&void 0!==i.descender&&(n=i.descender),i.glyphs)for(const e in i.glyphs)void 0===t[e]&&(t[e]=i.glyphs[e]);return {glyphs:t,ascender:r,descender:n}}}op.loadGlyphRange=async function(e,t,r,n,i){const s=256*t,a=s+255;let o;try{const t=await n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${s}-${a}`),$t.Glyphs),{data:i}=await Qt(t),l={},u=function(e){return function(e){const t={glyphs:[]};let r;for(;r=e.nextField();)1===r&&fd(e,e.readVarint()+e.pos,t);return t}(new rd(e))}(i);for(const e of u.glyphs)l[e.id]=e;o={glyphs:l,ascender:u.ascender,descender:u.descender};}catch(e){return i(e)}i(null,o);};const lp=1e20,up=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);up[e]=t*Math.abs(t);}function cp(e,t,r,n,i,s,a,o,l){for(let u=t;u-1);l++,s[l]=o,a[l]=u,a[l+1]=lp;}for(let o=0,l=0;o{if(r){n.ascender=r.ascender,n.descender=r.descender;for(const e in r.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=r.glyphs[+e]);n.ranges[t]=!0;}for(const i of n.requests[t]||[])i(e,r);delete n.requests[t];}));}getGlyphs(e,t){const r=[],n=this.url||wt.GLYPHS_URL;for(const t in e)for(const n of e[t])r.push({stack:t,id:n});Xe(r,({stack:e,id:t},r)=>{let i=this.entries[e];i||(i=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=i.glyphs[t];if(void 0!==s)return void r(null,{stack:e,id:t,glyph:s});if(s=this._tinySDF(i,e,t),s)return i.glyphs[t]=s,void r(null,{stack:e,id:t,glyph:s});const a=Math.floor(t/256);if(256*a>65535)return nt("glyphs > 65535 not supported"),void r(null,{stack:e,id:t,glyph:s});if(i.ranges[a])return void r(null,{stack:e,id:t,glyph:s});let o=i.requests[a];o||(o=i.requests[a]=[],this.glyphLoader.loadGlyphRange(e,a,n,this.requestManager,(e,t)=>{if(t){i.ascender=t.ascender,i.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(i.glyphs[+e]=t.glyphs[+e]);i.ranges[a]=!0;}for(const r of o)r(e,t);delete i.requests[a];})),o.push((n,i)=>{n?r(n):i&&r(null,{stack:e,id:t,glyph:i.glyphs[t]||null});});},(e,r)=>{if(e)t(e);else if(r){const e={};for(const{stack:t,id:n,glyph:i}of r)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e);}});}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==mp.none&&(this.localGlyphMode===mp.all?!!this.localFontFamily:!!this.localFontFamily&&(ya(e)||va(e)||oa(e)||la(e)||aa(e)||ma(e)||(t=e)>=131072&&t<=173791||(e=>e>=66736&&e<=66815)(e)));var t;}_tinySDF(e,t,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=e.tinySDF;if(!i){let r="400";dp.test(t)?r="900":pp.test(t)?r="500":fp.test(t)&&(r="200"),i=e.tinySDF=new yp.TinySDF({fontFamily:n,fontWeight:r,fontSize:48,buffer:6,radius:16}),i.fontWeight=r;}const s=i.fontWeight;if(this.localGlyphs[s][r])return this.localGlyphs[s][r];const a=String.fromCodePoint(r),{data:o,width:l,height:u,glyphWidth:c,glyphHeight:h,glyphLeft:d,glyphTop:p,glyphAdvance:f}=i.draw(a);return this.localGlyphs[s][r]={id:r,bitmap:new ph({width:l,height:u},o),metrics:{width:c/2,height:h/2,left:d/2,top:p/2-27,advance:f/2,localGlyph:!0}}}}function gp(e,t){return e+t[1]-t[0]}function xp(e,t,r,n,i=1){const s=[],a=e.imagePrimary,o=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=(e.right-e.left)*i,h=(e.bottom-e.top)*i,d=a.stretchX||[[0,l]],p=a.stretchY||[[0,u]],f=d.reduce(gp,0),m=p.reduce(gp,0),y=l-f,g=u-m;let x=0,v=f,b=0,w=m,_=0,A=y,M=0,I=g;if(a.content&&n){const e=a.content;x=bp(d,0,e[0]),b=bp(p,0,e[1]),v=bp(d,e[0],e[2]),w=bp(p,e[1],e[3]),_=e[0]-x,M=e[1]-b,A=e[2]-e[0]-v,I=e[3]-e[1]-w;}const S=(n,s,l,u)=>{const d=Ap(n.stretch-x,v,c,e.left*i),p=Mp(n.fixed-_,A,n.stretch,f),y=Ap(s.stretch-b,w,h,e.top*i),g=Mp(s.fixed-M,I,s.stretch,m),S=Ap(l.stretch-x,v,c,e.left*i),B=Mp(l.fixed-_,A,l.stretch,f),E=Ap(u.stretch-b,w,h,e.top*i),P=Mp(u.fixed-M,I,u.stretch,m),z=new be(d,y),T=new be(S,y),V=new be(S,E),F=new be(d,E),k=new be(p/o,g/o),C=new be(B/o,P/o),D=t*Math.PI/180;if(D){const e=Math.sin(D),t=Math.cos(D),r=[t,-e,e,t];z._matMult(r),T._matMult(r),F._matMult(r),V._matMult(r);}const R=n.stretch+n.fixed,L=l.stretch+l.fixed,O=s.stretch+s.fixed,U=u.stretch+u.fixed,N=e.imageSecondary;return {tl:z,tr:T,bl:F,br:V,texPrimary:{x:a.paddedRect.x+1+R,y:a.paddedRect.y+1+O,w:L-R,h:U-O},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+O,w:L-R,h:U-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:C,minFontScaleX:A/o/c,minFontScaleY:I/o/h,isSDF:r}};if(a.stretchX||a.stretchY){const e=wp(d,y,f),t=wp(p,g,m);for(let r=0;r0?[t,-r]:n<0?[-t,r]:0===t?[r,t]:[r,-t]}(r);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const f=t.positionedLines.length,m=p/f;let y=t.top-r[1];for(let e=0;es)&&(s=t.x),(!e||t.y>a)&&(a=t.y);}const l=Math.min(s-n,a-i);let u=l/2;const c=new zn([],Ep);if(0===l)return new be(n,i);for(let t=n;th.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-h.d<=t||(u=n.h/2,c.push(new Pp(n.p.x-u,n.p.y-u,u,e)),c.push(new Pp(n.p.x+u,n.p.y-u,u,e)),c.push(new Pp(n.p.x-u,n.p.y+u,u,e)),c.push(new Pp(n.p.x+u,n.p.y+u,u,e)),d+=4);}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function Ep(e,t){return t.max-e.max}yp.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:a="normal",lang:o=null}={}){this.buffer=t,this.radius=r,this.cutoff=n,this.lang=o;const l=this.size=e+4*t,u=this._createCanvas(l),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${s} ${e}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l);}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(e),a=Math.ceil(r),o=Math.floor(-i),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-o)),u=Math.max(0,Math.min(this.size-this.buffer,a+Math.ceil(n))),c=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(c*h,0),p=new Uint8ClampedArray(d),f={data:p,width:c,height:h,glyphWidth:l,glyphHeight:u,glyphTop:a,glyphLeft:o,glyphAdvance:t};if(0===l||0===u)return f;const{ctx:m,buffer:y,gridInner:g,gridOuter:x}=this;this.lang&&(m.lang=this.lang),m.clearRect(y,y,l,u),m.fillText(e,y-o,y+a);const v=m.getImageData(y,y,l,u);x.fill(lp,0,d),g.fill(0,0,d);let b=3;for(let e=0;ee.y!=o.y>e.y&&e.x<(o.x-i.x)*(e.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Yc(e,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const zp=Object.keys,Tp=Number.POSITIVE_INFINITY,Vp=Math.sqrt(2);function Fp(e,t,r,n,i,s){const a=Pd(e)&&e.collisionPadding?e.collisionPadding:[0,0,0,0],o={top:e.top-a[1],bottom:e.bottom+a[3],left:e.left-a[0],right:e.right+a[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0;}(o,n),s&&(o.left+=s[0],o.right+=s[0],o.top+=s[1],o.bottom+=s[1]),r&&function(e,t,r){if(!t)return;const n=Oe(t),i=new be(r?r[0]:0,r?r[1]:0),s=new be(e.left,e.top),a=new be(e.right,e.top),o=new be(e.left,e.bottom),l=new be(e.right,e.bottom);s._rotateAround(n,i),a._rotateAround(n,i),o._rotateAround(n,i),l._rotateAround(n,i),e.left=Math.min(s.x,a.x,o.x,l.x),e.right=Math.max(s.x,a.x,o.x,l.x),e.top=Math.min(s.y,a.y,o.y,l.y),e.bottom=Math.max(s.y,a.y,o.y,l.y);}(o,r,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function kp(e,[t,r]){let n=0,i=0;if(r===Tp){t<0&&(t=0);const r=t/Vp;switch(e){case "top-right":case "top-left":i=r-7;break;case "bottom-right":case "bottom-left":i=7-r;break;case "bottom":i=7-t;break;case "top":i=t-7;}switch(e){case "top-right":case "bottom-right":n=-r;break;case "top-left":case "bottom-left":n=r;break;case "left":n=t;break;case "right":n=-t;}}else {switch(t=Math.abs(t),r=Math.abs(r),e){case "top-right":case "top-left":case "top":i=r-7;break;case "bottom-right":case "bottom-left":case "bottom":i=7-r;}switch(e){case "top-right":case "bottom-right":case "right":n=-t;break;case "top-left":case "bottom-left":case "left":n=t;}}return [n,i]}function Cp(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f){const m=e.layers[0],y=m.appearances;if(0===y.length)return {iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const g={iconBBox:null,iconVerticalBBox:null},x={textBBox:null,textVerticalBBox:null},{baseIconRotate:v,baseTextRotate:b,iconScaleFactor:w}=function(e,t,r){const n=e.get("icon-rotate").evaluate(t,{},r),i=e.get("text-rotate").evaluate(t,{},r),[s,a]=e.get("icon-size-scale-range");return {baseIconRotate:n,baseTextRotate:i,iconScaleFactor:$e(1,s,a)}}(n,i,s);t&&(g.iconBBox=Fp(t,g.iconBBox,v),r)&&(g.iconVerticalBBox=Fp(r,g.iconVerticalBBox,v+90));const _=tf(h.horizontal);_&&(x.textBBox=Fp(_,x.textBBox,b,1,p)),h.vertical&&(x.textVerticalBBox=Fp(h.vertical,x.textVerticalBBox,b+90,1,p));for(const r of y)r.hasIconLayoutProperties()&&Dp(g,e,m,r,i,s,o,v,a,l,t,u,w,c,f),r.hasTextLayoutProperties()&&Lp(x,m,r,i,s,p,b,d,_,h.vertical);return {iconBBox:g.iconBBox,iconVerticalBBox:g.iconVerticalBBox,textBBox:x.textBBox,textVerticalBBox:x.textVerticalBBox}}function Dp(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f){const{appearanceIconOffset:m,appearanceIconRotate:y,appearanceIconSize:g}=Rp(n,r,i,s,a,o,l,u.iconScaleFactor);let x=null,v=null,b=null;n.hasLayoutProperty("icon-image")?b=function(e,t,r,n,i,s,a,o){let l=null;const u=t.getAppearanceValueAndResolveTokens(r,"icon-image",n,i,o);if(u){const c=e.getResolvedImageFromTokens(u),h=r.hasLayoutProperty("icon-size")?r.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],d=jp(c,Dd(e.zoom,h,e.worldview,o),h,i,e.zoom,n,e.pixelRatio,a,e.worldview,o);l=s.get(d.iconPrimary.toString());}return l}(t,r,n,i,s,h,d,f):c&&(b=c.imagePrimary),b&&(x=zd(b,null,m,p),t.allowVerticalPlacement&&(v=zd(b,null,m,p)));const w=l>0?g/l:1;x&&(e.iconBBox=Fp(x,e.iconBBox,y,1!==w?w:void 0)),v&&(e.iconVerticalBBox=Fp(v,e.iconVerticalBBox,y+90,1!==w?w:void 0));}function Rp(e,t,r,n,i,s,a,o){const l=e.hasLayoutProperty("icon-offset")?t.getAppearanceValueAndResolveTokens(e,"icon-offset",r,n,[]):null,u=l&&Array.isArray(l)?l:i,c=e.hasLayoutProperty("icon-rotate")?t.getAppearanceValueAndResolveTokens(e,"icon-rotate",r,n,[]):null,h="number"==typeof c?c:s,d=e.hasLayoutProperty("icon-size")?t.getAppearanceValueAndResolveTokens(e,"icon-size",r,n,[]):null;return {appearanceIconOffset:u,appearanceIconRotate:h,appearanceIconSize:"number"==typeof d?d*o:a}}function Lp(e,t,r,n,i,s,a,o,l,u){const{appearanceTextOffset:c,appearanceTextRotate:h,appearanceTextSize:d}=Op(r,t,n,i,s,a,o),p=d/o,f=[(c[0]-s[0])*p,(c[1]-s[1])*p],m=0!==f[0]||0!==f[1];l&&(e.textBBox=Fp(l,e.textBBox,h,p,c,m?f:void 0)),u&&(e.textVerticalBBox=Fp(u,e.textVerticalBBox,h+90,p,c,m?f:void 0));}function Op(e,t,r,n,i,s,a){const o=e.hasLayoutProperty("text-offset")?t.getAppearanceValueAndResolveTokens(e,"text-offset",r,n,[]):null,l=o&&Array.isArray(o)?[o[0]*Zh,o[1]*Zh]:i,u=e.hasLayoutProperty("text-rotate")?t.getAppearanceValueAndResolveTokens(e,"text-rotate",r,n,[]):null,c="number"==typeof u?u:s,h=e.hasLayoutProperty("text-size")?t.getAppearanceValueAndResolveTokens(e,"text-size",r,n,[]):null;return {appearanceTextOffset:l,appearanceTextRotate:c,appearanceTextSize:"number"==typeof h?h:a}}function Up(e,t,r,n,i,s,a,o,l){if(!t||!t.usvg)return;const u=kd(n),c=kd(i),h="both"!==s&&"width"!==s||!Vd(n)?1:c.width/u.width,d="both"!==s&&"height"!==s||!Fd(n)?1:c.height/u.height;r.scaleSelf(h,d);const p=r.toString();a.set(p,r),o.set(p,t);const{imagePosition:f}=np(p,t,1);l.set(p,f);}function Np(e,t,r,n,i,s,a,o,l,u){if(!e)return;const c=function(e,t,r,n,i,s,a){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Za(e.maxZoom,{worldview:s}),r,a).evaluate(i,{},r,a),o=t.possiblyEvaluate(new Za(e.minZoom,{worldview:s}),r,a).evaluate(i,{},r,a);return Math.max(n,o)}return t.possiblyEvaluate(new Za(n,{worldview:s}),r,a).evaluate(i,{},r,a)}(t,r,n,i,s,l,u);return e.scaleSelf(c*o*a)}function jp(e,t,r,n,i,s,a,o,l,u){return {iconPrimary:Np(e.getPrimary(),t,r,n,i,s,a,o,l,u),iconSecondary:Np(e.getSecondary(),t,r,n,i,s,a,o,l,u)}}function Gp(e,t,r){if(!t)return;const n=r.get(e.toString()),i=r.get(t.toString());n&&i&&(n.paddedRect.w===i.paddedRect.w&&n.paddedRect.h===i.paddedRect.h||nt(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==i.usvg&&nt(`Mismatch in icon variant image types: ${e.id} and ${t.id}`));}function $p(e,t,r,n){if(!e)return;const i=t.get(r.toString());if(i&&(e.imagePrimary=i),n){const r=t.get(n.toString());e.imageSecondary=r;}}function Hp(e,t){for(const r in e.horizontal)qp(e.horizontal[r],t);qp(e.vertical,t);}function qp(e,t){if(e)for(const r of e.positionedLines)for(const e of r.positionedGlyphs)if(null!==e.image){const r=e.image.toString();e.rect=t.get(r).paddedRect;}}function Xp(e){switch(e){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function Zp(e,t,r,n,i,s,a,o,l){const u=tf(s.horizontal)||s.vertical,c=r.get("icon-text-fit-padding").evaluate(n,{},i);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&s.vertical&&(h=Td(t,s.vertical,l,c,o,a)),u&&(d=Td(t,u,l,c,o,a))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function Wp(e,t){return e*t/24}function Yp(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,M,I,S,B,E=65535){let P=a.textMaxSize.evaluate(t,{},d);void 0===P?P=o*a.textScaleFactor:P*=a.textScaleFactor;const z=e.layers[0].layout,T=Wp(o,a.textScaleFactor),V=tf(r.horizontal)||r.vertical,F=e.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),k=e.getAppearanceFeatureData(t.index);("none"!==y||F)&&k&&(k.textShaping=V,k.iconTextFitPadding=z.get("icon-text-fit-padding").evaluate(t,{},d),k.fontScale=T,k.textScaleFactor=a.textScaleFactor);const C="globe"===p.name,D=e.tilePixelRatio*P/24,R=(G=e.overscaling,e.zoom>18&&G>2&&(G>>=1),Math.max(Tn/(512*G),1)*z.get("symbol-spacing")),L=z.get("text-padding")*e.tilePixelRatio,O=z.get("icon-padding")*e.tilePixelRatio,U=Oe(z.get("text-max-angle")),N="map"===z.get("icon-rotation-alignment")&&"point"!==v,j=R/2;var G;!1===e.hasAnyIconTextFit&&"none"!==y&&(e.hasAnyIconTextFit=!0);const $=(o,l,v)=>{if(l.x<0||l.x>=Tn||l.y<0||l.y>=Tn)return;if(I&&I.length>0&&t.properties&&B&&B(I,t.properties,l,d,S))return;let A=null;if(C){const{x:e,y:t,z:r}=p.projectTilePoint(l.x,l.y,v);A={anchor:new Od(e,t,r,0,void 0),up:p.upVector(v,l.x,l.y)};}!function(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,M,I,S,B,E,P,z,T){const V=e.addToLineVertexArray(t,n);let F,k,C,D,R,L,O,U=0,N=0,j=0,G=0,$=-1,H=-1;const q={};let X=nr("");const Z=r?r.anchor:t,W="none"!==B;let Y=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(b,{},M);Y=e[0]*Zh,K=e[1]*Zh;}else Y=l.layout.get("text-radial-offset").evaluate(b,{},M)*Zh,K=Tp;if(e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(f)L=nf(e),o&&(O=nf(o));else {const r=l.layout.get("text-rotate").evaluate(b,{},M)+90;C=rf(u,Z,t,c,h,d,e,p,r,m,T),o&&(D=rf(u,Z,t,c,h,d,o,g,r,null,z));}}if(s){const n=l.layout.get("icon-rotate").evaluate(b,{},M),i=xp(s,n,_,W,w.iconScaleFactor),a=o?xp(o,n,_,W,w.iconScaleFactor):void 0;k=rf(u,Z,t,c,h,d,s,g,n,null,P);const p=function(e,t,r,n,i,s,a,o,l,u){const c=e.layers[0],h=c.appearances;let d=t.length;if(r&&(d=Math.max(d,r.length)),0===h.length)return d;const[p,f]=n.get("icon-size-scale-range"),m=$e(1,p,f);for(const t of h)if(t.hasLayoutProperty("icon-image")){const r=c.getAppearanceValueAndResolveTokens(t,"icon-image",s,a,u);if(r){const n=e.getResolvedImageFromTokens(r);if(n){const r=t.hasLayoutProperty("icon-size")?t.getUnevaluatedLayoutProperty("icon-size"):i._values["icon-size"],l=jp(n,Dd(e.zoom,r,e.worldview,u),r,a,e.zoom,s,e.pixelRatio,m,e.worldview,u),c=o.get(l.iconPrimary.toString());c&&(d=Math.max(d,vp(c)));}}}return d}(e,i,a,l.layout,l._unevaluatedLayout,b,M,e.iconAtlasPositions,0,A);U=4*p;const f=l.layout.get("icon-size").evaluate(b,{},M,A),m=w.compositeIconSizes?w.compositeIconSizes[0].evaluate(b,{},M,A):0,y=w.compositeIconSizes?w.compositeIconSizes[1].evaluate(b,{},M,A):0,B=ef(e.layerIds[0],e.iconSizeData,f,s.imagePrimary.usvg?1:w.iconScaleFactor,m,y);e.addSymbols(e.icon,i,B,v,x,b,void 0,r,t,V.lineStartIndex,V.lineLength,-1,A,M,I,S,e.symbolInstances.length,p),$=e.icon.placedSymbolArray.length-1,a&&(N=4*p,e.addSymbols(e.icon,a,B,v,x,b,yd.vertical,r,t,V.lineStartIndex,V.lineLength,-1,A,M,I,S,e.symbolInstances.length,p),H=e.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=n,o=i.horizontal[s];F||(X=nr(o.text),f?R=nf(o):F=rf(u,Z,t,c,h,d,o,p,l.layout.get("text-rotate").evaluate(b,{},M),m,T));const y=1===o.positionedLines.length;if(j+=Qp(e,r,t,o,a,l,f,b,m,V,i.vertical?yd.horizontal:yd.horizontalOnly,y?zp(i.horizontal):[s],q,$,w,A,M,e.symbolInstances.length,I),y)break}i.vertical&&(G+=Qp(e,r,t,i.vertical,a,l,f,b,m,V,yd.vertical,["vertical"],q,H,w,A,M,e.symbolInstances.length,I));let J=-1;const Q=(e,t)=>e?Math.max(e,t):t;J=Q(R,J),J=Q(L,J),J=Q(O,J);const ee=J>-1?1:0;e.glyphOffsetArray.length>=65535&&nt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,Z.x,Z.y,Z.z,q.right>=0?q.right:-1,q.center>=0?q.center:-1,q.left>=0?q.left:-1,q.vertical>=0?q.vertical:-1,$,H,X,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,D||e.collisionBoxArray.length,D?D+1:e.collisionBoxArray.length,c,j,G,U,N,ee,0,Y,K,J,0,W?1:0,E);}(e,l,A,o,r,n,s,i,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,L,x,u,0,O,N,g,t,a,c,h,d,f,m,y,E,b,w,_);};if("line"===v)for(const i of oh(t.geometry,0,0,Tn,Tn)){const t=Hd(i,R,U,r.vertical||V,n,24,D,e.overscaling,Tn);for(const r of t)V&&sf(e,V.text,j,r)||$(i,r,d);}else if("line-center"===v){for(const e of t.geometry)if(e.length>1){const t=$d(e,U,r.vertical||V,n,24,D);t&&$(e,t,d);}}else if("Polygon"===t.type)for(const e of Be(t.geometry,0)){const t=Bp(e,16);$(e[0],new Od(t.x,t.y,0,0,void 0),d);}else if("LineString"===t.type)for(const e of t.geometry)$(e,new Od(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)$([t],new Od(t.x,t.y,0,0,void 0),d);}const Kp=255,Jp=Kp*Cd;function Qp(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g,x){const v=Sp(0,n,l,s,a,o,i,e.allowVerticalPlacement,void 0,f.textScaleFactor),b=s.layout.get("text-size").evaluate(o,{},y),w=f.compositeTextSizes?f.compositeTextSizes[0].evaluate(o,{},y):0,_=f.compositeTextSizes?f.compositeTextSizes[1].evaluate(o,{},y):0,A=ef(e.layerIds[0],e.textSizeData,b,f.textScaleFactor,w,_);e.addSymbols(e.text,v,A,l,a,o,c,t,r,u.lineStartIndex,u.lineLength,p,m,y,x,!1,g,v.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*v.length}function ef(e,t,r,n,i,s){const a=t;let o=null;return "source"===a.kind?(o=[Cd*r*n],o[0]>Jp&&nt(`${e}: Value for "text-size" or "icon-size" is >= ${Kp}. Reduce your "text-size" or "icon-size".`)):"composite"===a.kind&&(o=[Cd*i*n,Cd*s*n],(o[0]>Jp||o[1]>Jp)&&nt(`${e}: Value for "text-size" or "icon-size" is >= ${Kp}. Reduce your "text-size" or "icon-size".`)),o}function tf(e){for(const t in e)return e[t];return null}function rf(e,t,r,n,i,s,a,o,l,u,c){let h,d,p,f;if(h=c?c.top:a.top,d=c?c.bottom:a.bottom,p=c?c.left:a.left,f=c?c.right:a.right,Pd(a)&&a.collisionPadding){const e=a.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3];}if(l){const e=new be(p,h),t=new be(f,h),r=new be(p,d),n=new be(f,d),i=Oe(l);let s=new be(0,0);u&&(s=new be(u[0],u[1])),e._rotateAround(i,s),t._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(e.x,t.x,r.x,n.x),f=Math.max(e.x,t.x,r.x,n.x),h=Math.min(e.y,t.y,r.y,n.y),d=Math.max(e.y,t.y,r.y,n.y);}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,p,h,f,d,o,n,i,s),e.length-1}function nf(e){Pd(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function sf(e,t,r,n){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])h&&(h=n);}return n[0]=c,n[1]=h,n}function ff(e,t){let r=!0;for(let n=0;n=0);if(0===s)return 0;s!==t.length&&(r=!1);}return r?2:1}const mf=[0,0];function yf(e,t){for(const r of e.projections){const n=pf(t,e.points[0],r.axis,mf);if(r.projection[1]n[1])return 0}return 1}function gf(e,t){const r=t[0],n=t[1],i=t[2],s=t[3];for(let t=0;t=0)return !0}return !1}class xf{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=vf.fromPoints(this.points),this.projections=[],this.frustumEdges=[X([],this.points[2],this.points[3]),X([],this.points[0],this.points[3]),X([],this.points[4],this.points[0]),X([],this.points[5],this.points[1]),X([],this.points[6],this.points[2]),X([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],r=[e[2],0,-e[0]];this.projections.push({axis:t,projection:pf(this.points,this.points[0],t,[0,0])}),this.projections.push({axis:r,projection:pf(this.points,this.points[0],r,[0,0])});}}static fromInvProjectionMatrix(e,t,r,n){const i=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(r=>{const s=Q([],r,e),a=1/s[3]/t*i;return (o=s)[0]=(l=s)[0]*(u=[a,a,n?1/s[3]:a,a])[0],o[1]=l[1]*u[1],o[2]=l[2]*u[2],o[3]=l[3]*u[3],o;var o,l,u;}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=O([],N([],X([],s[e[0]],s[e[1]]),X([],s[e[2]],s[e[1]]))),r=-U(t,s[e[1]]);return t.concat(r)}),o=[];for(let e=0;eh&&(h=r);}let d=1/0,p=-1/0;for(let t=0;tp&&(p=n);}if(c>p||d>h)return 0}return 1}containsPoint(e){for(const t of this.planes){const r=t[3];if(U([t[0],t[1],t[2]],e)+r<0)return !1}return !0}}class vf{static fromPoints(e){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of e)T(t,t,n),V(r,r,n);return new vf(t,r)}static fromTileIdAndHeight(e,t,r){const n=1<e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}function bf(e){return e*hl/xl}Zs(vf,"Aabb");const wf=[new vf([fl,fl,fl],[ml,ml,ml]),new vf([fl,fl,fl],[0,0,ml]),new vf([0,fl,fl],[ml,0,ml]),new vf([fl,0,fl],[0,ml,ml]),new vf([0,0,fl],[ml,ml,ml])];function _f(e,t,r,n=!0){const i=F([],e._camera.position,e.worldSize),s=[t,r,1,1];Q(s,s,e.pixelMatrixInverse),K(s,s,1/s[3]);const a=O([],X([],s,i)),o=e.globeMatrix,l=[o[12],o[13],o[14]],u=X([],l,i),c=I(u),h=O([],u),d=e.worldSize/(2*Math.PI),p=U(h,a),f=Math.asin(d/c);if(f1?null:function(e,t,r,n){const i=Math.sin(r);return e*(Math.sin((1-n)*r)/i)+t*(Math.sin(n*r)/i)}(e.a[t],e.b[t],e.angle,$e(r,0,1))+e.center[t]}function If(e){if(e.z<=1)return wf[e.z+2*e.y+e.x];const t=zf(Pf(e));return vf.fromPoints(t)}function Sf(e,t,r){return F(e,e,1-r),k(e,e,t,r)}function Bf(e,t,r){for(const n of e)G(n,n,t),F(n,n,r);}function Ef(e,t,r,n){const i=t/e.worldSize,s=e.globeMatrix;if(r.z<=1){const e=If(r).getCorners();return Bf(e,s,i),vf.fromPoints(e)}const a=Pf(r,n),o=zf(a,hl+bf(e._tileCoverLift));Bf(o,s,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(a.contains(e.center)){for(const e of o)T(c,c,e),V(u,u,e);u[2]=0;const t=e.point,r=[t.x*i,t.y*i,0];return T(c,c,r),V(u,u,r),new vf(c,u)}if(e._tileCoverLift>0){for(const e of o)T(c,c,e),V(u,u,e);return new vf(c,u)}const h=[s[12]*i,s[13]*i,s[14]*i],d=a.getCenter(),p=$e(e.center.lat,-85.051129,Il),f=$e(d.lat,-85.051129,Il),m=fn(e.center.lng),y=mn(p);let g=m-fn(d.lng);const x=y-mn(f);g>.5?g-=1:g<-.5&&(g+=1);let v=0;Math.abs(g)>Math.abs(x)?v=g>=0?1:3:(v=x>=0?0:2,k(h,h,[s[4]*i,s[5]*i,s[6]*i],-Math.sin(Oe(x>=0?a.getSouth():a.getNorth()))*hl));const b=o[v],w=o[(v+1)%4],_=new Af(b,w,h),A=[Mf(_,0)||b[0],Mf(_,1)||b[1],Mf(_,2)||b[2]],M=Of(e.zoom);if(M>0){const n=function({x:e,y:t,z:r},n,i,s,a){const o=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*n-(s*=n))*i+s,u=((u+d)*n-s)*i+s,c=(c*n-(a*=n))*i+a,h=(h*n-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,t,e._pixelsPerMercatorPixel,m,y);for(let e=0;eMath.PI/2*1.01}const jf=Oe(85),Gf=Math.cos(jf),$f=Math.sin(jf);function Hf(e,t){const r=e.fovAboveCenter,n=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,i=Math.min(n,e.isOrthographic?-10*t:0),s=(e._camera.position[2]*e.worldSize-i)/Math.cos(e._pitch),a=Math.sin(r)*s/Math.sin(Math.max(Math.PI/2-e._pitch-r,.01));let o=Math.sin(e._pitch)*a+s;const l=s*(1/e._horizonShift);if(!e.elevation||0===e.elevation.exaggeration()){let t=Math.max(e.zoom-17,0);e.isOrthographic&&(t/=10),o*=1+t;}return Math.min(1.01*o,l)}class qf{constructor(e,t,r){this.z=e,this.x=t,this.y=r,this.key=Wf(0,e,e,t,r);}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return 0===e.z||e.z>t&&e.y===this.y>>t}url(e,t){const r=function(e,t,r){const n=2**r,i=2*Math.PI*6378137,s=i*(e/n-.5),a=i*(.5-(t+1)/n);return `${s},${a},${s+i/n},${a+i/n}`}(this.x,this.y,this.z),n=function(e,t,r){let n,i="";for(let s=e;s>0;s--)n=1<this.canonical.z?new Zf(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zf(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Wf(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return Wf(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new Zf(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new Zf(t,this.wrap,t,r,n),new Zf(t,this.wrap,t,r+1,n),new Zf(t,this.wrap,t,r,n+1),new Zf(t,this.wrap,t,r+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,r=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,r=e.wrap;return t===1<new Zf(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new Zf(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<v&&(b(e,u,n,i,o,l),b(u,r,o,l,s,a));}b(h,d,n,s,i,s),b(d,p,i,s,i,a),b(p,f,i,a,n,a),b(f,h,n,a,n,s),m-=v,y-=v,g+=v,x+=v;const w=1/Math.max(g-m,x-y);return {scale:w,x:m*w,y:y*w,x2:g*w,y2:x*w,projection:t}}Zs(qf,"CanonicalTileID"),Zs(Zf,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const Jf=u(new Float32Array(16));class Qf{constructor(e){this.spec=e,this.name=e.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(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new bl(0,0)}projectTilePoint(e,t,r){return {x:e,y:t,z:0}}locationPoint(e,t,r,n=!0){return e._coordinatePoint(e.locationCoordinate(t,r),n)}pixelsPerMeter(e,t){return Al(1,e)*t}pixelSpaceConversion(e,t,r){return 1}farthestPixelDistance(e){return Hf(e,e.pixelsPerMeter)}pointCoordinate(e,t,r,n){const i=e.horizonLineFromTop(!1),s=new be(t,Math.max(i,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,r){const n=new be(t,r);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(e,t.x,t.y);const r=e.horizonLineFromTop();return t.y0?t<-lm+r&&(t=-lm+r):t>lm-r&&(t=lm-r);const s=i/Math.pow(um(t),n);let a=s*Math.sin(n*e),o=i-s*Math.cos(n*e);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:r,f:n}=this,i=n-t,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(e*e+i*i);let o=Math.atan2(e,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(e)*s);const l=$e(Ue(o/r)+this.center[0],-180,180),u=$e(Ue(2*Math.atan(Math.pow(n/a,1/r))-lm),-85.051129,Il);return new bl(l,this.southernCenter?-u:u)}}class hm extends Qf{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:fn(e),y:mn(t),z:0}}unproject(e,t){const r=yn(e),n=gn(t);return new bl(r,n)}}const dm=Oe(Il);class pm extends Qf{project(e,t){const r=(t=Oe(t))*t,n=r*r;return {x:.5*((e=Oe(e))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const e=s*s;i=(r*(1.007226+s*(.015085+e*(.028874*s-.044475-.005916*e)))-t)/(1.007226+s*(.045255+e*(.259866*s-.311325-.005916*11*e))),r=$e(r-i,-dm,dm);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=$e(Ue(e/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=Ue(r);return new bl(a,o)}}const fm=Oe(Il);class mm extends Qf{project(e,t){t=Oe(t),e=Oe(e);const r=Math.cos(t),n=2/Math.PI,i=Math.acos(r*Math.cos(e/2)),s=Math.sin(i)/i,a=.5*(e*n+2*r*Math.sin(e/2)/s)||0,o=.5*(t+Math.sin(t)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(e,t){let r=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),d=Math.sin(r/2),p=2*h*d,f=d*d,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*d+2*r/Math.PI)-e,v=.5*(g*s+n)-t,b=.5*y*(c*f+g*i*h*u)+1/Math.PI,w=y*(p*l/4-g*s*d),_=.125*y*(l*d-g*s*c*p),A=.5*y*(u*h+g*f*i)+.5,M=w*_-A*b;a=(v*w-x*A)/M,o=(x*_-v*b)/M,r=$e(r-a,-Math.PI,Math.PI),n=$e(n-o,-fm,fm);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new bl(Ue(r),Ue(n))}}class ym extends Qf{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Oe(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:r,cosPhi:n}=this;return {x:Oe(e)*n*r+.5,y:-Math.sin(Oe(t))/n*r+.5,z:0}}unproject(e,t){const{scale:r,cosPhi:n}=this,i=-(t-.5)/r,s=$e(Ue((e-.5)/r)/n,-180,180),a=Math.asin($e(i*n,-1,1)),o=$e(Ue(a),-85.051129,Il);return new bl(s,o)}}class gm extends hm{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,r){const n=Tf(e,t,r);return G(n,n,kf(If(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,r){const n=gl(t.lat,t.lng),i=O([],n),s=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;k(n,n,i,Al(1,0)*Tn*s);const a=u(new Float64Array(16));return h(a,e.pixelMatrix,e.globeMatrix),G(n,n,a),new be(n[0],n[1])}pixelsPerMeter(e,t){return Al(1,0)*t}pixelSpaceConversion(e,t,r){const n=Al(1,e)*t,i=pr(Al(1,45)*t,n,r);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,r){const n=Cf(If(r.canonical));return h(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:r}=e,n=kf(If(t));return m(n,n,Oe(r.lng)),f(n,n,Oe(r.lat)),p(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,r,n){return _f(e,t,r,!0)||new zl(0,0)}pointCoordinate3D(e,t,r){const n=this.pointCoordinate(e,t,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(e,t){return !_f(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const r=e.cameraToCenterDistance,n=e._centerAltitude*t,i=e._camera,s=e._camera.forward(),a=E([],F([],s,-r),[0,0,n]),o=e.worldSize/(2*Math.PI),l=[0,0,-o],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=F([],i.up(),c),d=F([],i.right(),c*u),p=O([],E([],E([],s,h),d)),f=[];let m;if(new hf(a,p).closestPointOnSphere(l,o,f)){const t=E([],f,l),r=X([],t,a);m=Math.cos(e.fovAboveCenter)*I(r);}else {const e=X([],a,l),t=X([],l,a);O(t,t);const r=I(e)-o;m=Math.sqrt(r*(r+2*o));const n=Math.acos(m/(o+r))-Math.acos(U(s,t));m*=Math.cos(n);}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=Of(e.zoom);if(r>0){const n=Hf(e,Al(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return pr(t,n+i*(1-Math.cos(s)),Math.pow(r,10))}return t}upVector(e,t,r){return Tf(t,r,e,1)}upVectorScale(e){return {metersToTile:bf(Vf(If(e)))}}}function xm(e){const t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case "mercator":return new hm(e);case "equirectangular":return new om(e);case "naturalEarth":return new pm(e);case "equalEarth":return new am(e);case "winkelTripel":return new mm(e);case "albers":return r?new ym(e):new em(e);case "lambertConformalConic":return r?new ym(e):new cm(e);case "globe":return new gm(e)}throw new Error(`Invalid projection name: ${e.name}`)}const vm=Number.MAX_SAFE_INTEGER,bm=vm-1;function wm(e,t,r,n){return e.ordert.max.x||e.max.xt.max.y||e.max.ynew be((e.x+s.x*Tn)*o-a.x*Tn,(e.y+s.y*Tn)*o-a.y*Tn));}return Em(r,i,e.indices,0,e.indices.length,0,0)}function zm(e,t,r,n){const i=Math.pow(2,n.z-r.z);return new be((e+r.x*Tn)*i-n.x*Tn,(t+r.y*Tn)*i-n.y*Tn)}function Tm(e,t){const r=[];t.grid.queryPoint(e,r);const n=t.indices,i=t.vertices;for(let t=0;tfunction(e){if(!e.condition)return {featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const t=e.condition.expression;return {featureDependent:!hi(t),stateDependent:!di(t),zoomDependent:!fi(t,["zoom"]),pitchDependent:!fi(t,["pitch"]),brightnessDependent:!fi(t,["brightness","measure-light"]),worldviewDependent:!fi(t,["worldview"])}}(e));this.anyFeatureDependent=r.some(e=>e.featureDependent),this.anyStateDependent=r.some(e=>e.stateDependent);}update(e,t){const r=this.lastParams,n=!r||r.zoom!==e.zoom||r.pitch!==(e.pitch||0)||r.brightness!==(e.brightness||0)||r.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const i=t&&this.anyStateDependent;if(!n&&!i&&-2!==this.lastAllFeaturesIndex)return {kind:"no-changes"};if(!this.anyFeatureDependent&&!i){const t=this.evaluateAllFeatures(e);return t===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=t,{kind:"all-features",appearanceIndex:t})}return {kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;te-t),i=new Map;for(const e of n){const t=r.get(e);i.set(e,new qu(t));}return t&&(this.cachedBatchIndices=n,this.cachedBatchSegments=i),{batchIndices:n,batchSegments:i}}snapshotSymbolVertexData(e,t){const r=e*Um;return this.layoutVertexArray.uint16.slice(r,r+t*Um)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*Um);}snapshotIconTransitioningVertexData(e,t){const r=2*e;return this.iconTransitioningVertexArray.uint16.slice(r,r+2*t)}restoreIconTransitioningVertexData(e,t){this.iconTransitioningVertexArray.uint16.set(t,2*e);}updateSymbolVertexData(e,t,r,n,i,s,a,o,l,u,c,h,d){const p=this.layoutVertexArray.uint16,f=e*Um;p[f]=t,p[f+1]=r,p[f+2]=n,p[f+3]=i,p[f+4]=s,p[f+5]=a,p[f+6]=o,p[f+7]=l,p[f+8]=u,p[f+9]=c,p[f+10]=h,p[f+11]=d;}upload(e,t,r,n,i,s){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Eh.members,!!s),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,zh.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,km,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,kh.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Ph.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Th.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,Fh.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,Vh.members,!1))),(r||n)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy());}}Zs(Nm,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class jm{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new qu,this.collisionVertexArray=new pu,this.collisionVertexArrayExt=new ou;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Ch.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Dh.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Zs(jm,"CollisionBuffers");class Gm{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=u([]),this.placementViewportMatrix=u([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.textSizeData=Dd(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=Dd(this.zoom,t["icon-size"],this.worldview,e.availableImages);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(e=>yd[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map;}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||0===t.length)return !1;const r=Array.isArray(e)?e:[e];return t.some(e=>r.some(t=>e.hasLayoutProperty(t)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new Nm(new vc(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new Nm(new vc(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.text.uboBinder=new Xh(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Xh(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.glyphOffsetArray=new Cu,this.lineVertexArray=new Du,this.symbolInstances=new ku;}calculateGlyphDependencies(e,t,r,n,i){for(const r of e){const e=r.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&i&&e<=65535){const e=Yh[r];e&&(t[e.charCodeAt(0)]=!0);}}}calculateEffectiveAppearanceIconSize(e,t,r,n,i,s,a){if(!e.hasLayoutProperty("icon-size"))return a*s;let o=1;const l=e.getUnevaluatedLayoutProperty("icon-size"),u=Dd(this.zoom,l,this.worldview,i),c=Ld(u,t);if("constant"!==u.kind&&"camera"!==u.kind||(o=c.uSize),"composite"===u.kind){const{minZoom:e,maxZoom:t}=u,s=l.possiblyEvaluate(new Za(e,{worldview:this.worldview}),n),a=l.possiblyEvaluate(new Za(t,{worldview:this.worldview}),n),h=s.evaluate(r,{},n,i);o=h+(a.evaluate(r,{},n,i)-h)*c.uSizeT;}return "source"===u.kind&&(o=l.possiblyEvaluate(new Za(this.zoom,{worldview:this.worldview}),n).evaluate(r,{},n,i)),o*s}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return !Im(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return "string"==typeof e?$r.build(e):e}populate(e,t,r,n){const i=this.layers[0],s=i.layout,a="globe"===this.projection.name,o=s.get("text-font"),l=s.get("text-field"),u=s.get("icon-image"),[c,h]=s.get("icon-size-scale-range"),d=$e(t.scaleFactor||1,c,h),[p,f]=s.get("text-size-scale-range"),m=$e(t.scaleFactor||1,p,f),y=("constant"!==l.value.kind||l.value.value instanceof jr&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),g="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,x=this.hasAnyAppearanceLayoutProperty("icon-image"),v=s.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!y&&!g&&!x)return;const b=t.iconDependencies,w=t.glyphDependencies,_=t.availableImages,A=new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),M=e=>{const t=e.id.toString();b.has(t)?b.get(t).push(e):b.set(t,[e]);};for(const t of e){const{feature:e,id:l,index:u,sourceLayerIndex:c}=t,h=i._featureFilter.needGeometry,p=Ol(e,h);if(!i._featureFilter.filter(A,p,r))continue;if(h||(p.geometry=Ll(e,r,n)),a&&1!==e.type&&r.z<=5){const e=p.geometry,t=.98078528056,n=(e,n)=>U(Tf(e.x,e.y,r,1),Tf(n.x,n.y,r,1)){if(!e.getLayoutProperty("icon-image"))return;const{iconPrimary:t,iconSecondary:n}=this.getCombinedIconVariants(e,S,p,r,_,P,d);t&&(M(t),n&&(this.hasAnySecondaryIcon=!0,M(n)));}),f){const e=o.evaluate(p,{},r).join(","),t="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(yd.vertical);for(const r of f.sections)if(r.image){const e=r.image.getPrimary().scaleSelf(this.pixelRatio*m),t=e.id.toString(),n=b.get(t)||[];n.push(e),b.set(t,n);}else {const n=Ba(f.toString()),i=r.fontStack||e,s=w[i]=w[i]||{};this.calculateGlyphDependencies(r.text,s,t,this.allowVerticalPlacement,n);}}}"line"===s.get("symbol-placement")&&(this.features=function(e){const t={},r={},n=[];let i=0;function s(t){n.push(e[t]),i++;}function a(e,t,i){const s=r[e];return delete r[e],r[t]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(e,r,i){const s=t[r];return delete t[r],t[e]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(e,t,r){const n=r?t[0].at(-1):t[0][0];return `${e}:${n.x}:${n.y}`}for(let u=0;u1){s(u);continue}const p=l(d,h,!1),f=l(d,h,!0);if(p in r&&f in t&&r[p]!==t[f]){const e=o(p,f,h),i=a(p,f,n[e].geometry);delete t[p],delete r[f],r[l(d,n[i].geometry,!0)]=i,n[e].geometry=null;}else p in r?a(p,f,h):f in t?o(p,f,h):(s(u),t[p]=i-1,r[f]=i-1);}return n.filter(e=>e.geometry)}(this.features)),"hd-road-markup"===s.get("symbol-elevation-reference")?(this.elevationType="road",this.hdExt&&(this.hdExt.configureCrossSource(r,t.elevationParams,t.crossSourceElevationEnabled,t.terrainEnabled),t.elevationFeatures&&t.elevationFeatures.length>0&&this.hdExt.addElevationFeatures(t.elevationFeatures,r))):s.get("symbol-z-elevate")&&(this.elevationType="offset"),"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey);}getCombinedIconVariants(e,t,r,n,i,s,a){let o;if(e.hasLayoutProperty("icon-image")){const s=t.getAppearanceValueAndResolveTokens(e,"icon-image",r,n,i);o=this.getResolvedImageFromTokens(s);}else {const e=t.getValueAndResolveTokens("icon-image",r,n,i);o=this.getResolvedImageFromTokens(e);}if(o){const r=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],l=Dd(this.zoom,r,this.worldview,i),{iconPrimary:u,iconSecondary:c}=jp(o,l,r,n,this.zoom,s,this.pixelRatio,a,this.worldview,i);return {iconPrimary:u,iconSecondary:c}}return {iconPrimary:void 0,iconSecondary:void 0}}getCombinedIconPrimary(e,t,r,n,i,s,a){return this.getCombinedIconVariants(e,t,r,n,i,s,a).iconPrimary}updateSymbolInstanceIconVertices(e,t,r,n,i,s){const{canonical:a,availableImages:o,globalProperties:l,layer:u,iconScaleFactor:c,featureState:h,layoutIconOffset:d,layoutIconSize:p,layoutIconRotate:f}=s;if(e.placedIconSymbolIndex<0)return {vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const m=r>=0?u.appearances[r]:null;if(m){const r={sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},{iconPrimary:s,iconSecondary:y}=this.getCombinedIconVariants(m,u,n,a,o,r,c);if(!s)return {vertexOffsetDelta:0,hasChanges:!1};const g=s.toString(),x=this.iconAtlasPositions&&this.iconAtlasPositions.get(g);if(x){const{appearanceIconOffset:r,appearanceIconRotate:s}=Rp(m,u,n,a,d,f,p,c),g=u.layout.get("icon-anchor").evaluate(n,h,a);let v=zd(x,y?this.iconAtlasPositions&&this.iconAtlasPositions.get(y.toString()):void 0,r,g);const b=x.sdf,w=u.layout.get("icon-text-fit").constantOr("none");"none"!==w&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(v=Td(v,t.textShaping,w,t.iconTextFitPadding,r,t.fontScale));const _=this.calculateEffectiveAppearanceIconSize(m,l.zoom,n,a,o,c,p),A=0,M=1+(Math.min(Jp,Math.round(_*Cd))<<1),I=xp(v,s,b,"none"!==w,c),S=this.icon.iconTransitioningVertexArray.length>0;t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(i,e.numIconVertices),S&&(t.layoutBasedIconTransitioningVertexData=this.icon.snapshotIconTransitioningVertexData(i,e.numIconVertices)));const B=Math.floor(e.numIconVertices/4),E=Math.min(I.length,B);let P=i;const z=S?this.icon.iconTransitioningVertexArray.uint16:null;for(let r=0;r0||e.numVerticalGlyphVertices>0;if(!v)return {vertexOffsetDelta:v?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const b=r>=0?o.appearances[r]:null;if(b&&t.textShaping){const{appearanceTextOffset:r,appearanceTextRotate:s,appearanceTextSize:v}=Op(b,o,n,a,h,p,d);t.fontScale=Wp(v,t.textScaleFactor);const w=b.getUnevaluatedLayoutProperty("text-size");let _=this.textSizeData,A=y,M=g;b.hasLayoutProperty("text-size")&&(_=Dd(this.zoom,w,this.worldview,x),A="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,M="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);const I=t.textShaping.bottom-h[1],S=t.textShaping.left-h[0],B=t.textShaping.right-h[0];t.textShaping.top=r[1]+(t.textShaping.top-h[1]),t.textShaping.bottom=r[1]+I,t.textShaping.left=r[0]+S,t.textShaping.right=r[0]+B;const E=Sp(0,t.textShaping,r,o,!1,n,u,this.allowVerticalPlacement,s),P=v&&"composite"===_.kind?w.possiblyEvaluate(new Za(A,{}),a).evaluate(n,c,a):f,z=v&&"composite"===_.kind?w.possiblyEvaluate(new Za(M,{}),a).evaluate(n,c,a):m,T=ef(b.name,_,v,l,P,z),V=Array.isArray(T)?T[1]:v,F=0,k=1+(Math.min(Jp,Math.round(V*Cd))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(i,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let t=0;t0){const n=i[0],s=[this.text.uboBinder,this.icon.uboBinder].filter(e=>e&&e.hasStateDependentPaint(n));if(s.length>0){const i=new Set(Object.keys(e).map(e=>{const t=Number(e);return !isNaN(t)&&Number.isSafeInteger(t)&&String(t)===e?t:e}));for(const l of s)l.updateFeatures(i,n,t,o,r,e,a);}}}updateZOffset(){const e=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n);},t=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||s>0)&&(e(this.text.zOffsetVertexArray,i,o),e(this.text.zOffsetVertexArray,s,o)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:r}=n;e>=0&&t(this.icon.zOffsetVertexArray,a,o),r>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,r,n,i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0;}updateAppearances(e,t,r,n,i,s=!1){const a={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!r||!this.featureAppearanceData)return a;const o=t||{},l=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,u=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!l&&!u)return a;const c=this.layers[0],h=c.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===c.appearancesVersion||(this.featureAppearances=new Vm(c.appearances,c.appearancesVersion));const d=this.featureAppearances.update(n,s);if("no-changes"===d.kind)return a;let p=1,f=0,m=!1,y=!1;if(l){const[e,t]=h.get("icon-size-scale-range");p=$e(1,e,t);}let g=1,x=0,v=!1;if(u){const[e,t]=h.get("text-size-scale-range");g=$e(1,e,t);}const b=new Map;if(i&&r)for(const e of r){const t=i.getImage(e,c.scope);if(t){const r=new Gr(e.toString());b.set(r.toString(),t);}}const w=[this.text.uboBinder,this.icon.uboBinder];for(let t=0;tt.isActive({globals:n,feature:A,canonical:e,featureState:_})):-1;M=t>=0?t:-1;}const I=s.activeAppearanceIndex!==M;if(u){const t=h.get("text-size"),n="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,a="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,o={canonical:e,layer:c,featureState:_,availableImages:r,textScaleFactor:g,imageMap:b,layoutTextOffset:h.get("text-offset").evaluate(A,_,e).map(e=>e*Zh),layoutTextSize:t.evaluate(A,_,e),layoutTextRotate:h.get("text-rotate").evaluate(A,_,e),layoutMinZoomSize:t.evaluate(A,{zoom:n},e),layoutMaxZoomSize:t.evaluate(A,{zoom:a},e),layoutTextSizeMinZoom:n,layoutTextSizeMaxZoom:a},l=this.updateSymbolInstanceTextVertices(i,s,M,A,x,o);x+=l.vertexOffsetDelta,v=v||l.hasChanges;}if(l){const t={canonical:e,layer:c,featureState:_,availableImages:r,globalProperties:n,iconScaleFactor:p,layoutIconOffset:h.get("icon-offset").evaluate(A,_,e),layoutIconSize:h.get("icon-size").evaluate(A,_,e,r),layoutIconRotate:h.get("icon-rotate").evaluate(A,_,e)},a=this.updateSymbolInstanceIconVertices(i,s,M,A,f,t);f+=a.vertexOffsetDelta,m=m||a.hasChanges;}if(I){const t=i.featureIndex,s=n?n.brightness:null,a=_||{},o=M>=0?c.appearances[M]:null;for(const n of w)n&&(n.layer=c,y=n.updateFeaturePaintForAppearance(t,A,a,e,r,s,o)||y);}s.activeAppearanceIndex=M;}return m&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),m&&this.icon.iconTransitioningVertexBuffer&&this.icon.iconTransitioningVertexArray.length>0&&this.icon.iconTransitioningVertexArray.length===this.icon.iconTransitioningVertexBuffer.length&&this.icon.iconTransitioningVertexBuffer.updateData(this.icon.iconTransitioningVertexArray),v&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:m||v,hasUboChanges:y}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=xm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const r=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:r}of t)this.lineVertexArray.emplaceBack(e,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,n,i,s,a,o,l,u,c,h,d,p,f,m,y,g){const x=e.indexArray,v=e.layoutVertexArray,b=e.globeExtVertexArray,w=g,_=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,A=e.segments.prepareSegment(4*w,v,x,this.canOverlap?s.sortKey:void 0,_),M=this.glyphOffsetArray.length,I=A.vertexLength,S=this.allowVerticalPlacement&&a===yd.vertical?Math.PI/2:0,B=s.text&&s.text.sections;let E=v.length,P=-1;for(let n=0;n=0)){const t=4*z;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),s=Rd(this.textSizeData,e,i)/Zh;return this.tilePixelRatio*s}getSymbolInstanceIconSize(e,t,r){const n=this.icon.placedSymbolArray.get(r),i=Rd(this.iconSizeData,e,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,r,n){e.emplaceBack(t,-r,-r,n),e.emplaceBack(t,r,-r,n),e.emplaceBack(t,r,r,n),e.emplaceBack(t,-r,r,n);}_updateTextDebugCollisionBoxes(e,t,r,n,i,s,a){for(let a=n;a0}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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const r=e.placedSymbolArray.get(t),n=r.vertexStartIndex+4*r.numGlyphs;for(let t=r.vertexStartIndex;tn[e]-n[t]||i[t]-i[e]),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const r=this.sortKeyRanges.at(-1);r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1});}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesByY=!1;else {this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}Zs(Gm,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),Gm.addDynamicAttributes=Lm;class $m extends Ic{constructor(e,t,r){super(e,t,r),this.elevatedLayoutVertexArray=new Wl;}upload(e){const t=this.uploaded;super.upload(e),!t&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Gu.members));}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),super.destroy();}}Zs($m,"ElevatedFillBufferData");class Hm{constructor(){this.portals=[];}static isOnBorder(e,t){return e<=0&&t<=0||e>=Tn&&t>=Tn}static evaluate(e){if(0===e.length)return new Hm;let t=[];for(const r of e)t.push(...r.portals);if(0===t.length)return new Hm;for(const e of t){const t=e.va,r=e.vb;(Hm.isOnBorder(t.x,r.x)||Hm.isOnBorder(t.y,r.y))&&(e.type="border");}const r=t.filter(e=>"unevaluated"!==e.type),n=t.filter(e=>"unevaluated"===e.type);if(0===n.length)return new Hm;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hashe.hash"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new vc(t,{zoom:r,lut:n},e=>"fill-bridge-guard-rail-color"!==e);}addVertices(e,t){const r=this.unevalVertices.length;for(let r=0;r=i.min.x&&u.x<=i.max.x&&u.y>=i.min.y&&u.y<=i.max.y||c.x>=i.min.x&&c.x<=i.max.x&&c.y>=i.min.y&&c.y<=i.max.y||eh(u,c,a)))continue;if(this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;const h=Xm.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(Xm.computePosHash(u));null!=p?d=p.next:(p=this.vertexHashLookup.get(Xm.computePosHash(c)),d=null!=p?p.prev:h),this.unevalEdges.push({polygonIdx:e,a:r,b:l,hash:h,portalHash:d,isTunnel:n,type:"unevaluated",featureInfo:s});}}addPortalCandidates(e,t,r,n,i){if(0!==t.length){this.vertexHashLookup.clear();for(const i of t){if(0===i.length)continue;const t=i[0];let s=Xm.computeEdgeHash(t[t.length-2],t.at(-1));for(let i=0;i({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset;},n=new qm(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const i=t(),s=t(),a=t(),o=(e,t)=>{e.sort((e,r)=>e.type===t&&r.type!==t?-1:e.type!==t&&r.type===t?1:0);const r=e.findIndex(e=>e.type!==t);return r>=0?r:e.length};let l=0;this.unevalEdges.length>0&&(l=o(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),r(a);const u=t(),c=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=o(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t});}r(u),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(s),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights,4),r(i),this.maskSegments=qu.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=qu.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableBridgeSegments=qu.simpleSegment(0,a.primitiveOffset,0,a.primitiveLength),this.renderableTunnelSegments=qu.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=qu.simpleSegment(0,i.primitiveOffset,0,i.primitiveLength);}update(e,t,r,n,i,s,a,o){this.bridgeProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o),this.tunnelProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,a,o);}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,$u.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,Hu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e));}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy();}populatePaintArrays(e,t,r,n,i){const s=(s,a)=>{for(let o=0;oB(e,t[n].x,t[n].y,r[n]*o),c=A(),h=A(),d=A(),p=A(),f=A(),m=(e,r)=>{const n=a.get(Xm.computePosHash(t[r])),i=n.from,s=n.to;if(!i||!s)return;u(c,i),u(h,r),u(d,s),H(p),q(c,h)||(X(f,h,c),O(p,f)),q(d,h)||(X(f,d,h),E(p,p,O(f,f)));const o=W(p);return o>0?F(e,p,1/o):void 0};let y=Number.POSITIVE_INFINITY;this.sortSubarray(n,i.min,i.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const g=A(),x=A(),v=A(),b=A(),w=A(),_=A(),M=A(),I=A(),S=A(),P=[A(),A(),A(),A()],z=[A(),A(),A(),A()],T=[{coord:new be(0,0),height:0},{coord:new be(0,0),height:0}],V=(e,t)=>e>t;for(let u=i.min;ue.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,i.min,i.max,o),this.sortSubarray(n,s.min,s.max,o);const l=e=>O(e,e),u=[{coord:new be(0,0),height:0},{coord:new be(0,0),height:0}],c=(e,t)=>ee.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let r=0,n=0,i=0,s=t[r].polygonIdx;do{n++,(n===t.length||t[r].hash!==t[n].hash)&&((1===n-r||t[n-1].polygonIdx!==s)&&(ie.portalHashs.hash?r++:s.hash>i.portalHash?n++:(i.type=s.type,r++);}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Tn&&t>=Tn}addFeatureSection(e,t,r,n){return e!==t&&(t=e,r.push({featureIndex:e,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),t}sortSubarray(e,t,r,n){const i=e.slice(t,r);i.sort(n),e.splice(t,i.length,...i);}static computeEdgeHash(e,t){return (e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(Xm.computePosHash(e))<<32n|BigInt(Xm.computePosHash(t))}static computePosHash(e){return ((65535&e.x)<<16|65535&e.y)>>>0}}class Zm{constructor(){this._valid=!1;}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,r){return this.get(e,!0,t,r)}optional(e,t,r){return this.get(e,!1,t,r)}success(){return this._valid}get(e,t,r,n){const i=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==i&&!Number.isNaN(i)?r(n?n(i):i):t&&(this._valid=!1),this}}class Wm{constructor(e,t){this.featureFunc=e,this.vertexFunc=t;}parseFeature(e,t,r){return this.featureFunc(e,t,r)}parseVertex(e,t,r){return this.vertexFunc(e,t,r)}}const Ym=new Wm((e,t,r)=>e.reset(t).require(gh,e=>{r.id=e;}).optional("fixed_height_relative",e=>{r.constantHeight=e;},Jm.decodeRelativeHeight).geometry(e=>{r.bounds=e;},Ce).success(),(e,t,r)=>e.reset(t).require(gh,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height_relative",e=>{r.height=e;},Jm.decodeRelativeHeight).geometry(e=>{r.position=e;},Jm.getPoint).success()),Km=new Wm((e,t,r)=>e.reset(t).require(gh,e=>{r.id=e;}).optional("fixed_height",e=>{r.constantHeight=e;},Jm.decodeMetricHeight).geometry(e=>{r.bounds=e;},Ce).success(),(e,t,r)=>e.reset(t).require(gh,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height",e=>{r.height=e;},Jm.decodeMetricHeight).geometry(e=>{r.position=e;},Jm.getPoint).success());class Jm{static getPoint(e){return ce(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?"1.0.1"===e?Km:void 0:Ym}static parse(e){const t=[],r=[],n=e.length,i=new Zm;for(let s=0;s{return e.a0?F(o,o,1/l):B(o,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,r=Number.POSITIVE_INFINITY,n=0;const[i,s,a,o,l,u,c]=Qm;he(c,e.x,e.y);const h=new cf(c,null);for(let e=0;e0?ge(o,a)/x:0,b=$e(v,0,1),w=Math.abs((v-b)*this.edgeProps[e].len);pe(l,c,f),he(u,p[1],-p[0]);const _=w+Math.abs(ge(l,u));_=0;--s){const a=this.edges[s].a,o=this.edges[s].b,{position:l,height:u,extent:c}=this.vertices[a],{position:h,height:d,extent:p}=this.vertices[o],f=this.vertexProps[a].dir,m=this.vertexProps[o].dir;if(B(t,l[0]/e,l[1]/e,u),B(r,h[0]/e,h[1]/e,d),B(n,f[1],-f[0],0),F(n,n,c),B(i,m[1],-m[0],0),F(i,i,p),this.distSqLines(S(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),S(r[0]-.5*i[0],r[1]-.5*i[1],r[2]-.5*i[2]),S(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),S(r[0]+.5*i[0],r[1]+.5*i[1],r[2]+.5*i[2]))<=.0025000000000000005)continue;const y=this.vertices.length,g=de(ue(),l,h);this.vertices.push({position:fe(g,g,.5),height:.5*(u+d),extent:.5*(c+p),index:.5*((void 0!==this.vertices[a].index?this.vertices[a].index:a)+(void 0!==this.vertices[o].index?this.vertices[o].index:o))});const x=de(ue(),f,m);this.vertexProps.push({dir:ye(x,x)}),this.edges.splice(s,1),this.edgeProps.splice(s,1),this.edges.push({a,b:y}),this.edges.push({a:y,b:o});const v=pe(ue(),this.vertices[y].position,l),b=me(v),w={vec:v,dir:fe(ue(),v,1/b),len:b};this.edgeProps.push(w),this.edgeProps.push(w);}}distSqLines(e,t,r,n){const i=P(A(),t,e),s=P(A(),n,r),a=P(A(),e,r),o=U(i,i),l=U(i,s),u=U(i,a),c=U(s,s),h=U(s,a),d=o*c-l*l;if(0===d)return D(j(i,r,n,U(a,s)/U(s,s)),e);const p=(o*h-l*u)/d;return D(j(i,e,t,(l*h-u*c)/d),j(s,r,n,p))}static serialize(e,t){const r={id:e.id,heightRange:{min:e.heightRange.min,max:e.heightRange.max},safeArea:(n=e.safeArea,{min:{x:n.min.x,y:n.min.y},max:{x:n.max.x,y:n.max.y}})};var n;return null!=e.constantHeight?(r.constantHeight=e.constantHeight,r):0===e.vertices.length?(r.vertices=[],r.vertexProps=[],r.edges=[],r.edgeProps=[],r):(r.vertices=e.vertices.map(e=>({position:ry(e.position),height:e.height,extent:e.extent,index:e.index})),r.vertexProps=e.vertexProps.map(e=>({dir:ry(e.dir)})),r.edges=e.edges.map(e=>({a:e.a,b:e.b})),r.edgeProps=e.edgeProps.map(e=>({vec:ry(e.vec),dir:ry(e.dir),len:e.len})),r)}static deserialize(e){const t=function(e){return {min:new be(e.min.x,e.min.y),max:new be(e.max.x,e.max.y)}}(e.safeArea);if(null!=e.constantHeight)return new sy(e.id,t,e.constantHeight);if(!e.vertices||0===e.vertices.length){const r=Object.create(sy.prototype);return r.id=e.id,r.constantHeight=void 0,r.heightRange={min:e.heightRange.min,max:e.heightRange.max},r.safeArea=t,r.vertices=[],r.vertexProps=[],r.edges=[],r.edgeProps=[],r}const r=Object.create(sy.prototype);return r.id=e.id,r.constantHeight=void 0,r.heightRange={min:e.heightRange.min,max:e.heightRange.max},r.safeArea=t,r.vertices=e.vertices.map(e=>({position:ny(e.position),height:e.height,extent:e.extent,index:e.index})),r.vertexProps=(e.vertexProps||[]).map(e=>({dir:ny(e.dir)})),r.edges=(e.edges||[]).map(e=>({a:e.a,b:e.b})),r.edgeProps=(e.edgeProps||[]).map(e=>({vec:ny(e.vec),dir:ny(e.dir),len:e.len})),r}}class ay{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*Tn,this.yOffset=(e.y*this.zScale-t.y)*Tn);}pointTransform(e){return ce(e[0]*this.zScale+this.xOffset,e[1]*this.zScale+this.yOffset)}pointTransformInPlace(e){e[0]=e[0]*this.zScale+this.xOffset,e[1]=e[1]*this.zScale+this.yOffset;}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,r){const n=this.constantElevation(t,r);return null!=n?n:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),r))}computeBiasedHeight(e,t){return t<=0?e:e+t*He(0,t,e>=0?e:Math.abs(.5*e))}}function oy(e){if(0===e)return [0,0,0];const t=fs(e);return [t(),t(),t()]}function ly(e,t){let r=0,n=e.length-1;for(;r<=n;){const i=r+n>>1;e[i].feature.ide.id===i);if(e&&n)return {tileId:n,feature:e}}if(!r||0===r.length)return;const s=ly(r,i);if(!(s<0)){if(n)for(let e=s;et?1:e0))return t;t=t.left;}}return null}contains(e){for(var t=this._root,r=this._compare;t;){var n=r(e,t.key);if(0===n)return !0;t=n<0?t.left:t.right;}return !1}remove(e){var t=this.find(e);if(!t)return !1;if(this.splay(t),t.left)if(t.right){var r=this.minNode(t.right);r.parent!==t&&(this.replace(r,r.right),r.right=t.right,r.right.parent=r),this.replace(t,r),r.left=t.left,r.left.parent=r;}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return !1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t;}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var r=t.left,n=t.right,i=null;r&&(r.parent=null,i=this.maxNode(r),this.splay(i),this._root=i),n&&(r?i.right=n:this._root=n,n.parent=i),this._size--;}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key);}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,r=[],n=!1,i=0;!n;)t?(r.push(t),t=t.left):r.length>0?(e(t=r.pop(),i++),t=t.right):n=!0;return this}range(e,t,r,n){const i=[],s=this._compare;let a,o=this._root;for(;0!==i.length||o;)if(o)i.push(o),o=o.left;else {if(o=i.pop(),a=s(o.key,t),a>0)break;if(s(o.key,e)>=0&&r.call(n,o))return this;o=o.right;}return this}keys(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.key),e=e.right):n=!0;return r}values(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.data),e=e.right):n=!0;return r}at(e){for(var t=this._root,r=[],n=!1,i=0;!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right;}else n=!0;return null}load(e=[],t=[],r=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return r&&py(e,t,0,n-1,this._compare),this._root=dy(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,r,n,i){return new hy(r,i).load(e,t,n)}}function dy(e,t,r,n,i){const s=i-n;if(s>0){const a=n+Math.floor(s/2),o={key:t[a],data:r[a],parent:e};return o.left=dy(o,t,r,n,a),o.right=dy(o,t,r,a+1,i),o}return null}function py(e,t,r,n,i){if(r>=n)return;const s=e[r+n>>1];let a=r-1,o=n+1;for(;;){do{a++;}while(i(e[a],s)<0);do{o--;}while(i(e[o],s)>0);if(a>=o)break;let r=e[a];e[a]=e[o],e[o]=r,r=t[a],t[a]=t[o],t[o]=r;}py(e,t,r,o,i),py(e,t,o+1,n,i);}const fy=11102230246251565e-32,my=134217729,yy=(3+8*fy)*fy;function gy(e,t,r,n,i){let s,a,o,l,u=t[0],c=n[0],h=0,d=0;c>u==c>-u?(s=u,u=t[++h]):(s=c,c=n[++d]);let p=0;if(hu==c>-u?(a=u+s,o=s-(a-u),u=t[++h]):(a=c+s,o=s-(a-c),c=n[++d]),s=a,0!==o&&(i[p++]=o);hu==c>-u?(a=s+u,l=a-s,o=s-(a-l)+(u-l),u=t[++h]):(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=n[++d]),s=a,0!==o&&(i[p++]=o);for(;h0:(r[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(r[1]-e[1])>0}isAbove(e){return !this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new Sy(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function By(e,t){return e[0]===t[0]&&e[1]===t[1]}function Ey(e,t,r){const n=function(e,t,r,n,i,s){const a=(t-s)*(r-i),o=(e-i)*(n-s),l=a-o;if(0===a||0===o||a>0!=o>0)return l;const u=Math.abs(a+o);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,r,n,i,s,a){let o,l,u,c,h,d,p,f,m,y,g,x,v,b,w,_,A,M;const I=e-i,S=r-i,B=t-s,E=n-s;b=I*E,d=my*I,p=d-(d-I),f=I-p,d=my*E,m=d-(d-E),y=E-m,w=f*y-(b-p*m-f*m-p*y),_=B*S,d=my*B,p=d-(d-B),f=B-p,d=my*S,m=d-(d-S),y=S-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,vy[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,vy[1]=v-(g+h)+(h-_),M=x+g,h=M-x,vy[2]=x-(M-h)+(g-h),vy[3]=M;let P=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,vy),z=22204460492503146e-32*a;if(P>=z||-P>=z)return P;if(h=e-I,o=e-(I+h)+(h-i),h=r-S,u=r-(S+h)+(h-i),h=t-B,l=t-(B+h)+(h-s),h=n-E,c=n-(E+h)+(h-s),0===o&&0===l&&0===u&&0===c)return P;if(z=11093356479670487e-47*a+yy*Math.abs(P),P+=I*c+E*o-(B*u+S*l),P>=z||-P>=z)return P;b=o*E,d=my*o,p=d-(d-o),f=o-p,d=my*E,m=d-(d-E),y=E-m,w=f*y-(b-p*m-f*m-p*y),_=l*S,d=my*l,p=d-(d-l),f=l-p,d=my*S,m=d-(d-S),y=S-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Ay[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Ay[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Ay[2]=x-(M-h)+(g-h),Ay[3]=M;const T=gy(4,vy,4,Ay,by);b=I*c,d=my*I,p=d-(d-I),f=I-p,d=my*c,m=d-(d-c),y=c-m,w=f*y-(b-p*m-f*m-p*y),_=B*u,d=my*B,p=d-(d-B),f=B-p,d=my*u,m=d-(d-u),y=u-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Ay[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Ay[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Ay[2]=x-(M-h)+(g-h),Ay[3]=M;const V=gy(T,by,4,Ay,wy);b=o*c,d=my*o,p=d-(d-o),f=o-p,d=my*c,m=d-(d-c),y=c-m,w=f*y-(b-p*m-f*m-p*y),_=l*u,d=my*l,p=d-(d-l),f=l-p,d=my*u,m=d-(d-u),y=u-m,A=f*y-(_-p*m-f*m-p*y),g=w-A,h=w-g,Ay[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Ay[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Ay[2]=x-(M-h)+(g-h),Ay[3]=M;const F=gy(V,wy,4,Ay,_y);return _y[F-1]}(e,t,r,n,i,s,u)}(e[0],e[1],t[0],t[1],r[0],r[1]);return n>0?-1:n<0?1:0}function Py(e,t){const r=e.point,n=t.point;return r[0]>n[0]?1:r[0]n[1]?1:-1:function(e,t,r){return e.left!==t.left?e.left?1:-1:0!==Ey(r,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,r)}function zy(e,t,r){const n=new Sy(t,!1,e,e.isSubject),i=new Sy(t,!0,e.otherEvent,e.isSubject);return By(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=i.contourId=e.contourId,Py(i,e.otherEvent)>0&&(e.otherEvent.left=!0,i.left=!1),e.otherEvent.otherEvent=i,e.otherEvent=n,r.push(i),r.push(n),r}function Ty(e,t){return e[0]*t[1]-e[1]*t[0]}function Vy(e,t){return e[0]*t[0]+e[1]*t[1]}function Fy(e,t,r){const n=function(e,t,r,n){const i=[t[0]-e[0],t[1]-e[1]],s=[n[0]-r[0],n[1]-r[1]];function a(e,t,r){return [e[0]+t*r[0],e[1]+t*r[1]]}const o=[r[0]-e[0],r[1]-e[1]];let l=Ty(i,s),u=l*l;const c=Vy(i,i);if(u>0){const t=Ty(o,s)/l;if(t<0||t>1)return null;const n=Ty(o,i)/l;return n<0||n>1?null:0===t||1===t?[a(e,t,i)]:0===n||1===n?[a(r,n,s)]:[a(e,t,i)]}if(l=Ty(o,i),u=l*l,u>0)return null;const h=Vy(i,o)/c,d=h+Vy(i,s)/c,p=Math.min(h,d),f=Math.max(h,d);return p<=1&&f>=0?1===p?[a(e,p>0?p:0,i)]:0===f?[a(e,f<1?f:1,i)]:[a(e,p>0?p:0,i),a(e,f<1?f:1,i)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),i=n?n.length:0;if(0===i||1===i&&(By(e.point,t.point)||By(e.otherEvent.point,t.otherEvent.point))||2===i&&e.isSubject===t.isSubject)return 0;if(1===i)return !By(e.point,n[0])&&!By(e.otherEvent.point,n[0])&&zy(e,n[0],r),!By(t.point,n[0])&&!By(t.otherEvent.point,n[0])&&zy(t,n[0],r),1;const s=[];let a=!1,o=!1;return By(e.point,t.point)?a=!0:1===Py(e,t)?s.push(t,e):s.push(e,t),By(e.otherEvent.point,t.otherEvent.point)?o=!0:1===Py(e.otherEvent,t.otherEvent)?s.push(t.otherEvent,e.otherEvent):s.push(e.otherEvent,t.otherEvent),a&&o||a?(t.type=1,e.type=t.inOut===e.inOut?2:3,a&&!o&&zy(s[1].otherEvent,s[0].point,r),2):o?(zy(s[0],s[1].point,r),3):s[0]!==s[3].otherEvent?(zy(s[0],s[1].point,r),zy(s[1],s[2].point,r),3):(zy(s[0],s[1].point,r),zy(s[3].otherEvent,s[2].point,r),3)}function ky(e,t){if(e===t)return 0;if(0!==Ey(e.point,e.otherEvent.point,t.point)||0!==Ey(e.point,e.otherEvent.point,t.otherEvent.point))return By(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1](t.contourId??0)?1:-1}return 1===Py(e,t)?1:-1}class Cy{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null;}isExterior(){return null==this.holeOf}}function Dy(e,t,r,n){let i,s=e+1,a=t[e].point;const o=t.length;for(sn;)s--;return s}function Ry(e,t,r){const n=new Cy;if(null!=e.prevInResult){const i=e.prevInResult,s=i.outputContourId;if(i.resultTransition>0){const e=t[s];if(null!=e.holeOf){const i=e.holeOf;t[i].holeIds.push(r),n.holeOf=i,n.depth=t[s].depth;}else t[s].holeIds.push(r),n.holeOf=s,n.depth=t[s].depth+1;}else n.holeOf=null,n.depth=t[s].depth;}else n.holeOf=null,n.depth=0;return n}const Ly=Math.max,Oy=Math.min;let Uy=0;function Ny(e,t,r,n,i,s){let a,o,l,u,c,h;for(a=0,o=e.length-1;a0?h.left=!0:c.left=!0;const o=l[0],d=l[1];i[0]=Oy(i[0],o),i[1]=Oy(i[1],d),i[2]=Ly(i[2],o),i[3]=Ly(i[3],d),n.push(c),n.push(h);}}const jy=[];function Gy(e,t,r){let n=e,i=t;"number"==typeof e[0][0][0]&&(n=[e]),"number"==typeof t[0][0][0]&&(i=[t]);let s=function(e,t,r){let n=null;return e.length*t.length===0&&(0===r?n=jy:2===r?n=e:(1===r||3===r)&&(n=0===e.length?t:e)),n}(n,i,r);if(s)return s===jy?null:s;const a=[1/0,1/0,-1/0,-1/0],o=[1/0,1/0,-1/0,-1/0],l=function(e,t,r,n,i){const s=new zn(void 0,Py);let a,o,l,u,c,h;for(l=0,u=e.length;ln[2]||n[0]>r[2]||r[1]>n[3]||n[1]>r[3])&&(0===i?s=jy:2===i?s=e:(1===i||3===i)&&(s=e.concat(t))),s}(n,i,a,o,r),s)return s===jy?null:s;const u=function(e,t,r,n,i,s){const a=new hy(ky),o=[],l=Math.min(n[2],i[2]);let u,c,h;for(;0!==e.length;){let t=e.pop();if(o.push(t),0===s&&t.point[0]>l||2===s&&t.point[0]>n[2])break;if(t.left){c=u=a.insert(t),h=a.minNode(),u=u!==h?a.prev(u):null,c=a.next(c);const r=u?u.key:null;let n;if(My(t,r,s),c&&2===Fy(t,c.key,e)&&(My(t,r,s),My(c.key,t,s)),u&&2===Fy(u.key,t,e)){let e=u;e=e!==h?a.prev(e):null,n=e?e.key:null,My(r,n,s),My(t,r,s);}}else t=t.otherEvent,c=u=a.find(t),u&&c&&(u=u!==h?a.prev(u):null,c=a.next(c),a.remove(t),c&&u&&Fy(u.key,c.key,e));}return o}(l,0,0,a,o,r),c=function(e){let t,r;const n=function(e){let t,r,n,i,s;const a=[];for(r=0,n=e.length;r{i[t]=!0,t=n.length)&&n[o];);s.push(r);}return s}(u),h=[];for(let e=0;e0&&(i=Gy(i,s,2)),Wy(i,1/n,.001)}function qy(e,t=1){return [e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Xy(e,t){const r=Math.floor(e)+.5;return Math.abs(e-r)<=t?Math.round(r):Math.round(e)}class Zy{constructor(e){this.xs=[],this.ys=[],this.ixs=[],this.iys=[],this.buckets=new Map,this.tolerance=e;}canonicalize(e,t){const r=this.tolerance,n=Math.floor(e/r),i=Math.floor(t/r);for(let s=-1;s<=1;s++){const a=this.buckets.get(n+s);if(a)for(let s=-1;s<=1;s++){const o=a.get(i+s);if(o)for(const s of o)if(Math.abs(this.xs[s]-e)<=r&&Math.abs(this.ys[s]-t)<=r){const r=this.ixs[s],a=this.iys[s];return this.xs[s]===e&&this.ys[s]===t||this.store(e,t,r,a,n,i),[r,a]}}}const s=Xy(e,r),a=Xy(t,r);return this.store(e,t,s,a,n,i),[s,a]}store(e,t,r,n,i,s){const a=this.xs.length;this.xs.push(e),this.ys.push(t),this.ixs.push(r),this.iys.push(n);let o=this.buckets.get(i);o||(o=new Map,this.buckets.set(i,o));let l=o.get(s);l||(l=[],o.set(s,l)),l.push(a);}}function Wy(e,t=1,r){const n=null!=r?new Zy(r):null;return e.map(e=>e.map((e,r)=>{const i=e.map(e=>{const r=e[0]*t,i=e[1]*t;if(n){const[e,t]=n.canonicalize(r,i);return new be(e,t)}return new be(Math.round(r),Math.round(i))});return r>0&&i.reverse(),i}))}class Yy{constructor(){this.frcCoverage=new Set,this.featureTriSegments=[],this.frcPerLevel=new Map,this.frcNonRoadSegments=new qu;}empty(){return 0===this.frcCoverage.size}}function Ky(e,t,r){if(0===e.frcCoverage.size||0===e.featureTriSegments.length)return;const n=r.get(),i=t.uint16,s=[];e.featureTriSegments.sort((e,t)=>e.segIdx!==t.segIdx?e.segIdx-t.segIdx:null===e.frc&&null===t.frc?0:null===e.frc?-1:null===t.frc?1:t.frc-e.frc);const a=new Map;let o=0,l=e.featureTriSegments[0].frc,u={vertexOffset:n[o].vertexOffset,primitiveOffset:0,vertexLength:n[o].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0};const c=()=>{u.primitiveLength>0&&(a.has(l)||a.set(l,[]),a.get(l).push({...u}));};for(const t of e.featureTriSegments){t.segIdx!==o&&(c(),o=t.segIdx,l=t.frc,u={vertexOffset:n[o].vertexOffset,primitiveOffset:s.length/3,vertexLength:n[o].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0}),t.frc!==l&&(c(),l=t.frc,u={...u,primitiveOffset:s.length/3,primitiveLength:0});for(let e=t.start;e0?i.length-1:0,frc:n});}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&Ky(this.frcData,e.bufferData.indexArray,e.bufferData.triangleSegments);}handleFeature(e,t,r,n,i,s){const a=new Array;if(!this.elevationMode)return !1;const o=uy(e,i,void 0,n);if(!o)return !1;{const e=this.clipPolygonsToTile(t,1);e.length>0&&a.push({polygons:e,elevationFeature:o.feature,elevationTileID:o.tileId});}const l={guardRailEnabled:s.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},n),featureIndex:r};for(const t of a)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new Xm(t.elevationTileID,s.layers,s.zoom,s.lut));const r=t.elevationFeature.isTunnel();let n=0;Object.hasOwn(e.properties,xh)&&(n=+e.properties[xh]),this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,t.polygons,r,t.elevationFeature,n);}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const i=new ay(n,t.elevationTileID);this.addElevatedGeometry(s,t.polygons,i,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,r,l);}return !0}populatePaintArrays(e,t,r,n,i,s,a){this.elevationBufferData&&this.elevationBufferData.populatePaintArrays(e,t,r,n,i,s,a);}update(e,t,r,n,i,s,a,o){this.elevationBufferData&&this.elevationBufferData.update(e,t,r,n,i,s,a,o),this.elevatedStructures&&this.elevatedStructures.update(e,t,r,n,i,s,a,o);}updateExpressions(e){this.elevationBufferData&&this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e));}upload(e){this.elevationBufferData&&this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e);}destroy(){this.elevationBufferData&&this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy();}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,r,n,i,s){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,r,n,i,s));}addElevatedGeometry(e,t,r,n,i,s,a){const o={elevation:n,elevationSampler:r,bias:i,index:s,featureInfo:a},[l,u]=e.addGeometry(t,this.elevationBufferData,o,this.elevatedStructures);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:l,max:u}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,l),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,u));}prepareElevatedPolygons(e,t,r){const n=1/Pl(r),i=[];for(const r of e){const e=Hy(r,new iy(t,n),.1);i.push(...e);}return i}clipPolygonsToTile(e,t){const r=-t,n=-t,i=Tn+t,s=Tn+t;let a=0;const o=[],l=[];for(;a=r&&u.max.x<=i&&u.min.y>=n&&u.max.y<=s?o:l).push(t);}if(o.length===e.length)return e;const u=[new be(r,n),new be(i,n),new be(i,s),new be(r,s),new be(r,n)],c=o;for(const e of l)c.push(...$y(e,u));return c}}function rg(e,t){return e.nextPoint.sub(t.at(-2)).unit()}function ng(e,t){return t[1].sub(e.prevPoint).unit()}Zs(tg,"FillHDExtension"),Zs(Xm,"ElevatedStructures");class ig{constructor(e,t){this.elevationEnabled=e,this.hasDeferredElevationFeatures=!1,t&&(this.frcData=new Yy);}isEmpty(){const e=!this.elevationEnabled||void 0===this.heightRange,t=!this.frcData||this.frcData.empty();return e&&t}trackFeatureFrc(e){if(!this.frcData)return null;const t=Qy(e||{});return null!==t&&this.frcData.frcCoverage.add(t),t}recordFeatureRange(e,t,r,n){if(!this.frcData||r<=t)return;const i=e.segments.get();this.frcData.featureTriSegments.push({start:3*t,end:3*r,segIdx:i.length>0?i.length-1:0,frc:n});}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&Ky(this.frcData,e.indexArray,e.segments);}handleFeature(e,t,r,n,i,s,a,o,l,u,c){if(!this.elevationEnabled)return !1;if(!c.terrainEnabled){const h=uy(e,n,i?i.registry:void 0,r),d=null!=e.properties&&Object.hasOwn(e.properties,gh)&&!Number.isNaN(+e.properties[gh]);if(!h&&d&&s&&(!i||!i.allProvidersReady))return this.hasDeferredElevationFeatures=!0,!0;if(h){let n=h.feature,s=h.tileId;if(!h.tileId.equals(r)){const t=this.mergedFeatureCache?this.mergedFeatureCache.get(n.id):void 0;if(t)n=t,s=r;else {const t=function(e,t,r){if(!e.properties||!t||0===t.length)return [];const n=+e.properties[gh];if(Number.isNaN(n))return [];const i=ly(t,n);if(i<0)return [];const s=[];for(let e=i;e1&&(n=function(e,t){const r=t.slice().sort((e,t)=>t.tileId.z-e.tileId.z),n=new be(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new be(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),s=[];for(const t of r){const r=new ay(t.tileId,e);for(const e of t.feature.vertices)s.push({position:r.pointTransform(e.position),height:e.height,extent:e.extent,index:e.index});const a=t.feature.safeArea;ey[0]=a.min.x,ey[1]=a.min.y,ty[0]=a.max.x,ty[1]=a.max.y,r.pointTransformInPlace(ey),r.pointTransformInPlace(ty),n.x=Math.min(n.x,ey[0],ty[0]),n.y=Math.min(n.y,ey[1],ty[1]),i.x=Math.max(i.x,ey[0],ty[0]),i.y=Math.max(i.y,ey[1],ty[1]);}const a={min:n,max:i};if(null!=r[0].feature.constantHeight)return new sy(r[0].feature.id,a,r[0].feature.constantHeight);s.sort((e,t)=>e.index-t.index);const o=[];for(const e of s)0!==o.length&&o.at(-1).index===e.index||o.push(e);const l=[];for(let e=1;e>1,c.layoutVertexArray.int16[6*e+1]>>1),r=h.pointElevation(t,n,.05);this.updateHeightRange(r),e0?i.parentIndex:null);}return c.fillNonElevatedRoadSegment(d),!0}prepareElevatedLines(e,t,r,n){if(null!=t.constantHeight)return e;const i=[],s=1/Pl(n),a=r.equals(n)?null:new ay(r,n);for(const r of e)lh(r,new iy(t,s,a),0,i);return i}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e};}endPopulate(){this.mergedFeatureCache=void 0;}}Zs(ig,"LineHDExtension");class sg{constructor(){this.elevatedLayoutVertexArray=new Wl,this.hasElevation=!1;}beginFeature(e,t,r){const n=uy(e,t,void 0,r);this.currentFeatureElevation=n?n.feature:void 0;}writeVertexQuad(e,t){const r=this.currentFeatureElevation?this.currentFeatureElevation.pointElevation(new be(e,t)):0;this.hasElevation=this.hasElevation||0!==r;for(let e=0;e<4;e++)this.elevatedLayoutVertexArray.emplaceBack(r);}finalize(){this.hasElevation||(this.elevatedLayoutVertexArray=void 0);}upload(e){this.elevatedLayoutVertexArray&&!this.elevatedLayoutVertexBuffer&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Ih.members));}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy();}}Zs(sg,"CircleHDExtension");const ag=(e,t,r,n)=>{for(let i=0;i=this.elevationFeatures.length)return !1;const r=this.elevationFeatureTileIds[e];return null!=r&&!r.equals(t)}getRoadFeatureHeightAtAnchor(e,t,r){if(65535===e||e>=this.elevationFeatures.length)return null;const n=this.elevationFeatures[e],i=this.elevationFeatureTileIds[e];return i.equals(r)?n.pointElevation(t):this.getElevationFeatureSampler(r,i).pointElevation(new be(t.x,t.y),n,0)}sampleRoadFeatureHeight(e,t,r){const n=this.getRoadFeatureHeightAtAnchor(e,t,r);return null===n?void 0:n}clearWorkerState(){this.consumerCanonical=void 0,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1,this.elevationFeatureIdToIndex.clear();}updateRoadElevation(e,t){if(this.elevationStateComplete)return;this.elevationStateComplete=!0,e.hasAnyZOffset=!1;let r=!1;const n=Pl(t),i=1/n;let s=!1,a=!1;for(let o=0;o0||d>0,y=p>0,g=l.elevationFeatureIndex,x=g=0&&ag(e.icon.orientationVertexArray,p,u,c),r>=0&&ag(e.icon.orientationVertexArray,f,u,c);}}s||(e.text.orientationVertexArray=void 0),a||(e.icon.orientationVertexArray=void 0),r&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}getRoadFeatureHeightForPlacedSymbol(e,t,r,n,i){const s=e.symbolInstances.get(t.symbolInstanceIndices[r]);return this.getRoadFeatureHeightAtAnchor(s.elevationFeatureIndex,n,i)}getElevationFeatureForPlacedSymbol(e,t,r){const n=e.symbolInstances.get(t.symbolInstanceIndices[r]).elevationFeatureIndex;if(n{const s=this.getRoadFeatureHeightForPlacedSymbol(e,t,r,i,n.canonical);return function(e,t,r,n,i,s){const a=n.upVector(t,r.x,r.y);return F(a,a,e*n.upVectorScale(t,i,s).metersToTile),[a[0],a[1],a[2]]}(null!==s?s:0,n.canonical,i,a,o,l)},elevation:s,elevationFeature:null}:{getElevation:i,elevation:s,elevationFeature:c}}}Zs(og,"SymbolHDExtension",{omit:["consumerCanonical","elevationParams","crossSourceElevationEnabled","terrainEnabled","hasDeferredElevationFeatures","elevationFeatureIdToIndex"]});let lg=null,ug=null,cg=null,hg=null;const dg=5120,pg=5121,fg=5122,mg=5123,yg=5125,gg=5126,xg={[dg]:Int8Array,[pg]:Uint8Array,[fg]:Int16Array,[mg]:Uint16Array,[yg]:Uint32Array,[gg]:Float32Array},vg={[dg]:"DT_INT8",[pg]:"DT_UINT8",[fg]:"DT_INT16",[mg]:"DT_UINT16",[yg]:"DT_UINT32",[gg]:"DT_FLOAT32"},bg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function wg(e,t,r){const n=r.json.bufferViews.length,i=r.buffers.length;t.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:e.byteLength},r.buffers[i]=e;}const _g="KHR_draco_mesh_compression";function Ag(e,t){const r=e.extensions&&e.extensions[_g];if(!r)return;const n=new lg.Decoder,i=zg(t,r.bufferView),s=new lg.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,s))throw new Error("Failed to decode Draco mesh");const a=t.json.accessors[e.indices],o=xg[a.componentType],l=a.count*o.BYTES_PER_ELEMENT,u=lg._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(s,l,u):n.GetTrianglesUInt32Array(s,l,u),wg(lg.memory.buffer.slice(u,u+l),a,t),lg._free(u);for(const i of Object.keys(r.attributes)){const a=n.GetAttributeByUniqueId(s,r.attributes[i]),o=t.json.accessors[e.attributes[i]],l=vg[o.componentType],u=o.count*bg[o.type]*xg[o.componentType].BYTES_PER_ELEMENT,c=lg._malloc(u);n.GetAttributeDataArrayForAllPoints(s,a,lg[l],u,c),wg(lg.memory.buffer.slice(c,c+u),o,t),lg._free(c);}n.destroy(),s.destroy(),delete e.extensions[_g];}const Mg="EXT_meshopt_compression";function Ig(e,t){if(!e.extensions||!e.extensions[Mg])return;const r=e.extensions[Mg],n=new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);cg.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=i.buffer,delete e.extensions[Mg];}const Sg=1179937895,Bg=new TextDecoder("utf8");function Eg(e,t){return new URL(e,t).href}async function Pg(e,t,r,n,i){const s=await fetch(Eg(e.uri,n),{signal:i}),a=await s.arrayBuffer();t.buffers[r]=a;}function zg(e,t){const r=e.json.bufferViews[t];return new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength)}async function Tg(e,t,r,n,i){if(e.uri){const s=Eg(e.uri,n),a=await fetch(s,{signal:i}),o=await a.blob(),l=await createImageBitmap(o);t.images[r]=l;}else if(void 0!==e.bufferView){const n=zg(t,e.bufferView),i=new Blob([n],{type:e.mimeType}),s=await createImageBitmap(i);t.images[r]=s;}}async function Vg(e,t=0,r,n){const i={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Sg){const r=new Uint32Array(e,t);let n=2;const s=(r[n++]>>2)-3,a=r[n++]>>2;if(n++,i.json=JSON.parse(Bg.decode(r.subarray(n,n+a))),n+=a,n>>0,Math.ceil(1.2*i)),a=Math.ceil((s-i)/65536);try{return r.grow(a),n(),!0}catch(e){return !1}},b:i}}).then(e=>{const{Rb:i,Qb:s,P:a,T:o,X:l,Ja:u,La:c,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:y,e:g,yb:x,zb:v,Ab:b,Bb:w,Db:_,Gb:A}=e.instance.exports;r=g;const M=(()=>{let e=0,r=0,n=0,a=0;return o=>{n&&(i(a),i(e),r+=n,n=e=0),e||(r+=128,e=s(r));const l=o.length+7&-8;let u=e;l>=r&&(n=l,u=a=s(l));for(let e=0;e{lg=e,ug=null;})),ug}()),d&&c.push(function(){var e;if(!cg)return null!=hg||(hg=(e=fetch(At()),WebAssembly.instantiateStreaming(e,{}).then(e=>{const{sbrk:t,memory:r,meshopt_decodeVertexBuffer:n,meshopt_decodeIndexBuffer:i,meshopt_decodeIndexSequence:s,meshopt_decodeFilterOct:a,meshopt_decodeFilterQuat:o,meshopt_decodeFilterExp:l}=e.instance.exports,u={ATTRIBUTES:n,TRIANGLES:i,INDICES:s},c={OCTAHEDRAL:a,QUATERNION:o,EXPONENTIAL:l};return e.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(e,n,i,s,a,o){const l=n+3&-4,h=t(l*i),d=t(s.length),p=new Uint8Array(r.buffer);p.set(s,d);const f=u[a](h,n,i,d,s.length);if(0===f&&c[o]&&c[o](h,l,i),e.set(p.subarray(h,h+n*i)),t(h-t(0)),0!==f)throw new Error(`Malformed buffer data: ${f}`)}}})).then(e=>{cg=e,hg=null;})),hg}()),a)for(let e=0;ee.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let u=0;for(;uthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const r=Cg(e.x-this.min.x,this.xScale,this.cellsX),n=Cg(e.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Cg(e.x-this.min.x,this.xScale,this.cellsX),i=Cg(t.x-this.min.x,this.xScale,this.cellsX),s=Cg(e.y-this.min.y,this.yScale,this.cellsY),a=Cg(t.y-this.min.y,this.yScale,this.cellsY);for(let e=s;e<=a;e++)for(let t=n;t<=i;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;e0){const r=function(e,t){const r=t.worldSize,n=Al(1,0)*r*Bl(t.center.lat,t.zoom)/Df(r),i=Al(1,t.center.lat)*r,s=u([]);m(s,s,Oe(t.center.lng)),f(s,s,Oe(t.center.lat)),d(s,s,[0,0,hl]),p(s,s,[n,n,n*i]);const a=t.point;return d(s,s,[-a.x,-a.y,0]),h(s,s,e),h(s,t.globeMatrix,s)}(e,t);return function(e,t,r){const n=(e,t,r)=>{const n=I(e),i=I(t),s=Sf(e,t,r);return F(s,s,1/I(s)*pr(n,i,r))},i=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],r),s=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],r),a=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],r),o=Sf([e[12],e[13],e[14]],[t[12],t[13],t[14]],r);return [i[0],i[1],i[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],1]}(i,r,n)}return i}function Qg(e,t,r,n){const i=vf.projectAabbCorners(n,r);let s=Number.MAX_VALUE;for(let e=0;e0||0===a&&r[0]*s[0]+r[1]*s[1]>=0&&r[0]*r[0]+r[1]*r[1]>s[0]*s[0]+s[1]*s[1])&&(n=t);}i=n;}while(i!==r);return t.length>0&&t.push(t[0]),t}(i);if(Nc(e,a))return s}const ex=64,tx={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function rx(e,t,r,n,i,s,a,o,l,c=!1){const f=r.zoom,m=r.project(n),y=Bl(n.lat,f),g=1/y;u(e),d(e,e,[m.x+a[0]*g,m.y+a[1]*g,a[2]]);let x=1,v=1;const b=r.worldSize;if(c){if("mercator"===r.projection.name){let e=0;r.elevation&&(e=r.elevation.getAtPointOrZero(new zl(m.x/b,m.y/b),0));const t=Q([],[m.x,m.y,e,1],r.projMatrix)[3]/r.cameraToCenterDistance;x=t,v=t*Bl(r.center.lat,f);}else if("globe"===r.projection.name){const t=Jg(e,r),i=[0,0,0,1];Q(i,i,h([],r.projMatrix,t));const s=i[3]/r.cameraToCenterDistance,a=Of(f),o=r.projection.pixelsPerMeter(n.lat,b)*Bl(n.lat,f),l=r.projection.pixelsPerMeter(r.center.lat,b)*Bl(r.center.lat,f);x=s/pr(o,Sl(r.center.lat),a),v=s*y/o,x*=l,v*=l;}}else x=g;p(e,e,[x,x,v]);const _=[...e],A=t.orientation,M=[];if(Yg(M,[A[0]+(i?i[0]:0),A[1]+(i?i[1]:0),A[2]+(i?i[2]:0)],s),h(e,_,M),o&&r.elevation){let i=0;const s=[];if(l&&r.elevation){i=function(e,t,r,n,i){const s=t.elevation;if(!s)return 0;const a=vf.projectAabbCorners(r,n),o=Al(1,i.lat)*t.worldSize,l=function(e,t){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of n){const n=e[i.corners[0]],s=e[i.corners[1]],a=e[i.corners[2]],o=[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])],l=N(o,o,[a[0]-n[0],a[1]-n[1],t*(a[2]-n[2])]);O(l,l),i.dotProductWithUp=U(l,r);}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(a,o),u=a[l[0]],c=a[l[1]],h=a[l[2]],d=a[l[3]],p=s.getAtPointOrZero(new zl(u[0]/t.worldSize,u[1]/t.worldSize),0),f=s.getAtPointOrZero(new zl(c[0]/t.worldSize,c[1]/t.worldSize),0),m=s.getAtPointOrZero(new zl(h[0]/t.worldSize,h[1]/t.worldSize),0),y=s.getAtPointOrZero(new zl(d[0]/t.worldSize,d[1]/t.worldSize),0),g=(p+y)/2,x=(f+m)/2;return g>x?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function sx(e,t,r){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Dg.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Ug.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Og.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Rg:Lg).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,jg.members,!0)),e.segments=qu.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&ix(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&ix(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&ix(n.normalTexture,t),n.occlusionTexture&&ix(n.occlusionTexture,t,r),n.emissionTexture&&ix(n.emissionTexture,t);}function ax(e,t,r){if(e.meshes)for(const n of e.meshes)sx(n,t,r);if(e.lodMeshes)for(const n of e.lodMeshes)sx(n,t,r);if(e.children)for(const n of e.children)ax(n,t,r);}function ox(e){e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();}function lx(e){if(e.meshes)for(const t of e.meshes)ox(t);if(e.lodMeshes)for(const t of e.lodMeshes)ox(t);if(e.children)for(const t of e.children)lx(t);}function ux(e){var t;e.vertexBuffer&&(e.vertexBuffer.destroy(),e.indexBuffer.destroy(),e.normalBuffer&&e.normalBuffer.destroy(),e.texcoordBuffer&&e.texcoordBuffer.destroy(),e.colorBuffer&&e.colorBuffer.destroy(),e.pbrBuffer&&e.pbrBuffer.destroy(),e.segments.destroy(),e.material&&((t=e.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));}function cx(e){if(e.meshes)for(const t of e.meshes)ux(t);if(e.lodMeshes)for(const t of e.lodMeshes)ux(t);if(e.footprintDebugMesh&&(e.footprintDebugMesh.vertexBuffer.destroy(),e.footprintDebugMesh.indexBuffer.destroy(),e.footprintDebugMesh.segments.destroy()),e.children)for(const t of e.children)cx(t);}function hx(e,t,r,n){return e[0]<=n[0]&&t[0]>=r[0]&&e[1]<=n[1]&&t[1]>=r[1]&&e[2]<=n[2]&&t[2]>=r[2]}function dx(e,t,r,n,i,s,a,o,l,u,c){const h=.5*(u[0]+c[0]),d=.5*(u[1]+c[1]),p=.5*(u[2]+c[2]),f=.5*(c[0]-u[0]),m=.5*(c[1]-u[1]),y=.5*(c[2]-u[2]),g=e-h,x=t-d,v=r-p,b=n-h,w=i-d,_=s-p,A=a-h,M=o-d,I=l-p,S=b-g,B=w-x,E=_-v,P=A-b,z=M-w,T=I-_,V=g-A,F=x-M,k=v-I;let C,D,R,L,O,U;if(C=v*B-x*E,D=_*B-w*E,R=I*B-M*E,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(E)*m+Math.abs(B)*y,L>U||O<-U)return !1;if(C=v*z-x*T,D=_*z-w*T,R=I*z-M*T,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(T)*m+Math.abs(z)*y,L>U||O<-U)return !1;if(C=v*F-x*k,D=_*F-w*k,R=I*F-M*k,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(k)*m+Math.abs(F)*y,L>U||O<-U)return !1;if(C=g*E-v*S,D=b*E-_*S,R=A*E-I*S,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(E)*f+Math.abs(S)*y,L>U||O<-U)return !1;if(C=g*T-v*P,D=b*T-_*P,R=A*T-I*P,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(T)*f+Math.abs(P)*y,L>U||O<-U)return !1;if(C=g*k-v*V,D=b*k-_*V,R=A*k-I*V,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(k)*f+Math.abs(V)*y,L>U||O<-U)return !1;if(C=x*S-g*B,D=w*S-b*B,R=M*S-A*B,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(B)*f+Math.abs(S)*m,L>U||O<-U)return !1;if(C=x*P-g*z,D=w*P-b*z,R=M*P-A*z,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(z)*f+Math.abs(P)*m,L>U||O<-U)return !1;if(C=x*V-g*F,D=w*V-b*F,R=M*V-A*F,L=Math.min(C,D,R),O=Math.max(C,D,R),U=Math.abs(F)*f+Math.abs(V)*m,L>U||O<-U)return !1;if(L=Math.min(g,b,A),O=Math.max(g,b,A),L>f||O<-f)return !1;if(L=Math.min(x,w,M),O=Math.max(x,w,M),L>m||O<-m)return !1;if(L=Math.min(v,_,I),O=Math.max(v,_,I),L>y||O<-y)return !1;const N=B*T-E*z,j=E*P-S*T,G=S*z-B*P,$=-(N*g+j*x+G*v);return U=f*Math.abs(N)+m*Math.abs(j)+y*Math.abs(G),!(Math.abs($)>U)}const px=[];class fx{serializeFromGltf(e,t,r,n){if(e.length<7)return;let i=0;if(109!==e[i++]||98!==e[i++]||120!==e[i++]||98!==e[i++]||118!==e[i++]||104!==e[i++])return;if(43!==e[i++])return;const s=new DataView(e.buffer,e.byteOffset),a=s.getUint16(i,!0);if(i+=2,0===a)return;this._nodes=[];let o=0;for(let e=0;e0;){const i=r.pop(),s=this._nodes[i];if(s.aabbMax[2]<=n)continue;if(65535===s.backChild){for(let r=0;r=0?n:null}}function mx(e,t){const r=e.json.bufferViews[t.bufferView],n=xg[t.componentType];return new n(e.buffers[r.buffer],(t.byteOffset||0)+(r.byteOffset||0),t.count*(r.byteStride&&r.byteStride!==bg[t.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:bg[t.type]))}function yx(e,t,r,n){const i=xg[t.componentType],s=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),a=e.json.bufferViews[t.bufferView],o=a.byteStride?a.byteStride/i.BYTES_PER_ELEMENT:bg[t.type],l=r.float32,u=l.length/r.capacity,c=t.count*o;for(let e=0,t=0;e0){s.texcoordArray=new _u;const e=t.json.accessors[i.TEXCOORD_0];s.texcoordArray.resizeExact(e.count);const r=mx(t,e);yx(t,e,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const e=t.json.accessors[i._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(s.featureData=mx(t,e));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(mx(t,t.json.accessors[i._FEATURE_RGBA4444]).buffer));const y=e.material;return s.material=function(e,t){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:a,emissiveTexture:o,doubleSided:l,name:u}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=a?t[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&m){const e=a.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]];}return {name:u,pbrMetallicRoughness:{baseColorFactor:new mr(...c),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new mr(...r),alphaMode:n,alphaCutoff:i,normalTexture:s?t[s.index]:void 0,occlusionTexture:m,emissionTexture:o?t[o.index]:void 0,defined:void 0===e.defined}}(void 0!==y?t.json.materials[y]:{defined:!1},r),s}function xx(e,t,r){const{matrix:n,rotation:i,translation:s,scale:a,mesh:o,extras:u,children:c,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,r,n){var i=t[0],s=t[1],a=t[2],o=t[3],l=i+i,u=s+s,c=a+a,h=i*l,d=i*u,p=i*c,f=s*u,m=s*c,y=a*c,g=o*l,x=o*u,v=o*c,b=n[0],w=n[1],_=n[2];return e[0]=(1-(f+y))*b,e[1]=(d+v)*b,e[2]=(p-x)*b,e[3]=0,e[4]=(d-v)*w,e[5]=(1-(h+y))*w,e[6]=(m+g)*w,e[7]=0,e[8]=(p+x)*_,e[9]=(m-g)*_,e[10]=(1-(h+f))*_,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}([],i||[0,0,0,1],s||[0,0,0],a||[1,1,1]),d.globalMatrix=l(d.localMatrix),void 0!==o){d.meshes=r[o];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:r,max:n}=t.aabb;e[0]+=r[0]+n[0],e[1]+=r[1]+n[1];}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2);}if(u&&(u.id&&(d.id=u.id),u.lights&&(d.lights=function(e){if(!e.length)return [];const t=function(e){const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e=o.length||i>=o.length||s>=o.length||a>=o.length)return null;const l=o[n],u=o[i],c=o[s],h=o[a];if(void 0===l.bufferView||void 0===u.bufferView||void 0===c.bufferView||void 0===h.bufferView)return null;const d=e.json.bufferViews;if(l.bufferView>=d.length||u.bufferView>=d.length||c.bufferView>=d.length||h.bufferView>=d.length)return null;const p=d[l.bufferView],f=d[u.bufferView],m=d[c.bufferView],y=d[h.bufferView];if(p.buffer>=e.buffers.length||f.buffer>=e.buffers.length||m.buffer>=e.buffers.length||y.buffer>=e.buffers.length)return null;const g=(e,t,r)=>e>=0&&e<=r&&t<=r-e,x=l.byteOffset||0,v=u.byteOffset||0,b=c.byteOffset||0,w=h.byteOffset||0;if(!(g(x,0,p.byteLength)&&g(v,3*u.count*4,f.byteLength)&&g(b,3*c.count*4,m.byteLength)&&g(w,4*h.count,y.byteLength)))return null;const _=new Uint8Array(e.buffers[p.buffer],(p.byteOffset||0)+x,p.byteLength-x),A=new Float32Array(e.buffers[f.buffer],(f.byteOffset||0)+v,3*u.count),M=new Float32Array(e.buffers[m.buffer],(m.byteOffset||0)+b,3*c.count),I=new Uint32Array(e.buffers[y.buffer],(y.byteOffset||0)+w,h.count),S=new fx;if(S.serializeFromGltf(_,A,M,I),void 0!==r&&e.json.meshes&&e.json.meshes[r]){const t=e.json.meshes[r].primitives[0];if(t&&void 0!==t.attributes.POSITION&&t.attributes.POSITION1&&n.at(-1).equals(n[0])&&n.pop();let i=0;for(let e=0;e0&&n.reverse();const s=Do(n.flatMap(e=>[e.x,e.y]),[]);return 0===s.length?null:{vertices:n,indices:s}}function wx(e,t){const r=[],n=[];let i=0;const s=[];for(const a of e){i=r.length;const e=a.vertexArray.float32,o=a.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]]);}return {vertices:r,indices:n}}function _x(e,t){for(let r=0;r0){const t=Array.from(i.values()).sort((e,t)=>e-t);for(let r=t.length-1;r>=0;r--)e.splice(t[r],1);}}(l,o,e.json.nodes);const u=n?_x(n,"LOD"):-1;if(u>=0){const t=n[u].nodes,i=new Map;for(const n of t){const t=xx(s[n],e,r);t.id&&i.set(t.id,t);}for(const e of l)if(e.id){const t=i.get(e.id);t&&t.meshes&&(e.lodMeshes=t.meshes,t.meshBVH&&(e.meshBVH=t.meshBVH));}}return l}function Mx(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,r=e.aabb.min[0]-1,n=e.aabb.min[1]-1,i=ex/(e.aabb.max[0]-r+2),s=ex/(e.aabb.max[1]-n+2);for(let a=0;ae.heightmap[u*ex+l]&&(e.heightmap[u*ex+l]=o);}}function Ix(e,t,r,n,i){r.reserve(r.length+4*e.length),n.reserve(n.length+10*e.length),i.reserve(i.length+10*e.length);let s=n.length;for(const a of e){const e=Math.min(10,Math.max(4,1.3*a.height))*t,o=[-a.normal[1],a.normal[0],0],l=Math.min(.29,.1*a.width/a.depth),u=a.width-2*a.depth*t*(l+.01),c=k([],a.pos,o,u/2),h=k([],a.pos,o,-u/2),d=[c[0],c[1],c[2]+a.height],p=[h[0],h[1],h[2]+a.height],f=k([],a.normal,o,l);F(f,f,e);const m=k([],a.normal,o,-l);F(m,m,e),E(f,c,f),E(m,h,m),c[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const y=u/e/2;i.emplaceBack(-y-l,-1,y,.8),i.emplaceBack(y+l,-1,y,.8),i.emplaceBack(-y,0,y,1.3),i.emplaceBack(y,0,y,1.3),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(0,0,y,1.3),i.emplaceBack(0,0,y,1.3),i.emplaceBack(y+l,-1.2,y,.8),i.emplaceBack(y+l,-1.2,y,.8),r.emplaceBack(6+s,4+s,8+s),r.emplaceBack(7+s,9+s,5+s),r.emplaceBack(0+s,1+s,2+s),r.emplaceBack(1+s,3+s,2+s),s+=10;}}function Sx(e,t){const r={};r.indexArray=new fu,r.vertexArray=new tu,r.colorArray=new ou,r.indexArray.reserveExact(4*e.length),r.vertexArray.reserveExact(10*e.length),r.colorArray.reserveExact(10*e.length),Ix(e,t,r.indexArray,r.vertexArray,r.colorArray);const n={defined:!0};n.emissiveFactor=mr.black;const i={};return i.baseColorFactor=mr.white,n.pbrMetallicRoughness=i,r.material=n,r.aabb=new vf([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}Zs(fx,"ModelBVH");const Bx=$l([{name:"a_pos_3f",components:3,type:"Float32"}]),Ex=$l([{name:"a_normal_3",components:3,type:"Int16"}]),Px=$l([{name:"a_centroid_3",components:3,type:"Int16"}]),zx=$l([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Tx=$l([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Vx=$l([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Fx=$l([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),kx=$l([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Cx=$l([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Dx=$l([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Rx=$l([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Lx=$l([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),Ox=$l([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Ux=$l([{name:"a_join_normal_inside",components:3,type:"Int16"}]),Nx=$l([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),jx=$l([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Gx}=Dx;function $x(e,t,r,n){const i=[],s=0===n?(e,t,r,n,i,s)=>{e.push(new be(s,r+(s-t)/(n-t)*(i-r)));}:(e,t,r,n,i,s)=>{e.push(new be(t+(s-r)/(i-r)*(n-t),s));};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&s(a,o,l,u,c,t):h>r?d=t&&s(a,o,l,u,c,t),d>r&&h<=r&&s(a,o,l,u,c,r);}let o=i.at(-1);const l=0===n?o.x:o.y;l>=t&&l<=r&&a.push(o),a.length&&(o=a.at(-1),a[0].x===o.x&&a[0].y===o.y||a.push(a[0]),e.push(a));}e.length&&i.push(e);}return i}const Hx={None:0,Model:1,Symbol:2,FillExtrusion:4},qx=[new be(0,0),new be(Tn,0),new be(Tn,Tn),new be(0,Tn)];function Xx(e,t){const r=[];let n=[];if(!t||e.length<2)return [e];if(2===e.length)return eh(e[0],e[1],qx)?[e]:[];for(let t=0;t0&&(n.length>1&&r.push(n),n=[]);}return n.length>1&&r.push(n),r}const Zx=Dc.types,Wx=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],Yx=["fill-extrusion-flood-light-ground-radius"],Kx=Math.pow(2,13),Jx=Math.pow(2,15)-1,Qx=new be(0,1),ev=2147483648,tv=1073741824;function rv(e,t,r,n,i,s,a,o){e.emplaceBack((t<<1)+a,(r<<1)+s,(Math.floor(n*Kx)<<1)+i,Math.round(o));}function nv(e,t,r){e.emplaceBack(t.x*Tn,t.y*Tn,r?1:0);}function iv(e,t,r,n,i,s){e.emplaceBack(t.x,t.y,(r.x<<1)+n,(r.y<<1)+i,s);}function sv(e,t,r){const n=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*n,r[1]*n,r[2]*n);}class av{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class ov{constructor(){this.data=[];}get length(){return this.data.length}push(e){this.data.push(e);}get(e){return this.data[e]}static serialize(e,t){const r=e.data.length,n=new Uint32Array(4*r),i=[];i.length=r;for(let t=0;te.max.x&&(e.max.x=t.x,n=!0),t.ye.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Tn)&&t.x===r.x)!=((0===t.y||t.y===Tn)&&t.y===r.y)&&this.processBorderOverlap(t,r),n&&this.checkBorderIntersection(t,r);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,pr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Tn!=e.x>Tn&&this.addBorderIntersection(1,pr(t.y,e.y,(Tn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,pr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Tn!=e.y>Tn&&this.addBorderIntersection(3,pr(t.x,e.x,(Tn-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){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 r=this.borders[e];tr[1]&&(r[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y);}else {const r=0===e.y?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x);}}centroid(){return 0===this.accCount?new be(0,0):new be(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function hv(e,t){const r=e.add(t)._unit(),n=$e(e.x*r.x+e.y*r.y,-1,1);var i,s,a;return a=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(a)))/4*Jx*((i=e).x*(s=t).y-i.y*s.x<0?-1:1)}const dv=[e=>e.x<0,e=>e.x>Tn,e=>e.y<0,e=>e.y>Tn];function pv(e,t,r,n){const i=[4];if(0===n)return i;r._mult(n);const s=e.sub(r),a=t.sub(r),o=[e,t,s,a];for(let e=0;e<4;e++)for(const t of o)if(dv[e](t)){i.push(e);break}return i}class fv{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new Ql,this.indexArray=new fu,this.programConfigurations=new vc(e.layers,{zoom:e.zoom,lut:e.lut},e=>Yx.includes(e)),this._segments=new qu,this.hiddenByLandmarkVertexArray=new Eu,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new qu;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,r,n=!1){const i=e.length;if(i>2){let s=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let o;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const t=e[0],r=e[1];o=hv(t.sub(e[i-1])._perp()._unit(),r.sub(t)._perp()._unit());}for(let l=0;le.region-t.region);for(let r=0;re+t,0);let s=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let r=this.regionSegments[e];r||(r=this.regionSegments[e]=new qu);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:t};r.get().push(i);}s+=t;}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Nx.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class mv{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new uv,this.footprintIndices=new fu,this.footprintVertices=new ql,this.footprintSegments=new ov,this.layoutVertexArray=new Jl,this.centroidVertexArray=new Ou,this.wallVertexArray=new Nu,this.indexArray=new fu,this.programConfigurations=new vc(e.layers,{zoom:e.zoom,lut:e.lut},e=>Wx.includes(e)),this.segments=new qu,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new fv(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.features=[],this.hasPattern=ul("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Pl(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:i,id:s,index:a,sourceLayerIndex:o}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ol(i,e);if(!this.layers[0]._featureFilter.filter(new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,r))continue;const u={id:s,sourceLayerIndex:o,index:a,geometry:e?l.geometry:Ll(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===Zx[u.type];if(this.hasPattern)this.features.push({featureId:i.id,feature:cl("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of u.geometry)for(const s of Xx(e,h))this.addFeature(i.id,u,[s],a,r,{},t.availableImages,n,t.brightness);else this.addFeature(i.id,u,u.geometry,a,r,{},t.availableImages,n,t.brightness);t.featureIndex.insert(i,u.geometry,a,o,this.index,c);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(e,t,r,n,i,s){for(const{featureId:e,feature:a}of this.features){const o="Polygon"===Zx[a.type],{geometry:l}=a;if(this.wallMode)for(const u of l)for(const l of Xx(u,o))this.addFeature(e,a,[l],a.index,t,r,n,i,s);else this.addFeature(e,a,l,a.index,t,r,n,i,s);}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a,this.worldview),this.groundEffect.update(e,t,i,r,n,s,a,this.worldview);}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gx),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Ux.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,jx.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ox.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,r,n,i,s,a,o,l){const u=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new be(0,0),new be(Tn,Tn)],h=o.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===Zx[t.type],f=new cv;f.centroidDataIndex=this.centroidData.length;const m=new lv;m.buildingId=e,t.properties&&Object.hasOwn(t.properties,"building_id")&&(m.buildingId=Number(t.properties.building_id)),f.buildingId=m.buildingId;const y=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},i)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},i);let x;if(m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new iu),this.wallMode){if(d)return void nt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;x=function(e){const t=e[0].x===e.at(-1).x&&e[0].y===e.at(-1).y,r=function(e){let t=0;const r=e.length;for(let n=0;n=0}(e);r||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],s=[],a=[];let o=e.length;for(;o>=2&&e[o-1].equals(e[o-2]);)o--;if(o<(t?3:2))return n;let l,u,c,h,d,p=0;for(;p0;let g="miter";const x=2;"miter"===g&&m>x&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const o=new be(e.x,e.y),l=new be(e.x,e.y);o.x+=t.x*n,o.y+=t.y*n,l.x-=t.x*Math.max(r,1),l.y-=t.y*Math.max(r,1),a.push(t),i.push(o),s.push(l);};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=d.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else {const e=-Math.sqrt(m*m-1),t=y?e:0,r=y?0:e;u&&v(l,h,t,r),c&&v(l,d,t,r);}}n.geometry=[...i,...s.reverse(),i[0]],n.joinNormals=[...a,...a.reverse(),a.at(-1)];const f=n.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,b=this.wallMode?[r]:Be(r,500);for(let e=b.length-1;e>=0;e--){const t=b[e];(0===t.length||wv(t[0]))&&b.splice(e,1);}let w;if(d)w=Iv(b,c,i);else {w=[];for(const e of b)w.push({polygon:e,bounds:c});}const _=p?this.edgeRadius:0,A=_>0&&this.zoom<17,M=(e,t)=>{if(0===e.length)return !1;const r=e.at(-1);return t.x===r.x&&t.y===r.y};for(const{polygon:e,bounds:t}of w){let r=0,n=0;for(const t of e)p&&!t[0].equals(t.at(-1))&&t.push(t[0]),n+=p?t.length-1:t.length;const s=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new av;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const n=[],a=[];r=s.vertexLength;for(let r=0;r4&&_v(a[a.length-2],a[0],a[1]),l=_?gv(a[a.length-2],a[0],a[1],_):0;const c=[];let g,b,w;b=a[1].sub(a[0])._perp()._unit();let A=!0;for(let e=1,n=0;e0?1:0,P=u.dist(p);if(n+P>32768&&(n=0),_){w=I.sub(p)._perp()._unit();let e=xv(u,p,I,yv(b,w),_);isNaN(e)&&(e=0);const t=p.sub(u)._unit();u=u.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,b=w,y&&this.zoom>=17&&(M(c,u)||c.push(u),M(c,p)||c.push(p));}const z=s.vertexLength,T=a.length>4&&_v(u,p,I);let V=Av(n,o,A);if(rv(this.layoutVertexArray,u.x,u.y,B,E,0,0,V),rv(this.layoutVertexArray,u.x,u.y,B,E,0,1,V),this.wallMode){const t=v(e-1,a),r=x.joinNormals[e-1];nv(this.wallVertexArray,r,t),nv(this.wallVertexArray,r,t);}if(n+=P,V=Av(n,T,!A),o=T,rv(this.layoutVertexArray,p.x,p.y,B,E,0,0,V),rv(this.layoutVertexArray,p.x,p.y,B,E,0,1,V),this.wallMode){const t=v(e,a),r=x.joinNormals[e];nv(this.wallVertexArray,r,t),nv(this.wallVertexArray,r,t);}if(s.vertexLength+=4,this.indexArray.emplaceBack(z+0,z+1,z+2),this.indexArray.emplaceBack(z+1,z+3,z+2),s.primitiveLength+=2,_){const n=r+(1===e?a.length-2:e-2),i=1===e?r:n+1;if(this.indexArray.emplaceBack(z+1,n,z+3),this.indexArray.emplaceBack(n,i,z+3),s.primitiveLength+=2,void 0===g&&(g=z),!vv(I,a[e],t)){const t=e===a.length-1?g:s.vertexLength;this.indexArray.emplaceBack(z+2,z+3,t),this.indexArray.emplaceBack(z+3,t+1,t),this.indexArray.emplaceBack(z+3,i,t+1),s.primitiveLength+=3;}A=!A;}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(u.x,u.y,i),r=h.projectTilePoint(p.x,p.y,i),n=h.upVector(i,u.x,u.y),s=h.upVector(i,p.x,p.y);sv(e,t,n),sv(e,t,n),sv(e,r,s),sv(e,r,s);}}p&&(r+=a.length-1),y&&_&&this.zoom>=17&&(0!==c.length&&M(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u,_>0));}this.footprintSegments.push(o),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++m.footprintSegLen,++m.polygonSegLen;}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?Qx:this.encodeCentroid(f,m),t.properties&&Object.hasOwn(t.properties,"building_id")){const e=m.buildingId;let t=this.buildingGroups.get(e);t||(t={accX:0,accY:0,accCount:0,mergedMin:new be(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new be(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(e,t)),t.accX+=f.acc.x,t.accY+=f.acc.y,t.accCount+=f.accCount,t.mergedMin.x=Math.min(t.mergedMin.x,m.min.x),t.mergedMin.y=Math.min(t.mergedMin.y,m.min.y),t.mergedMax.x=Math.max(t.mergedMax.x,m.max.x),t.mergedMax.y=Math.max(t.mergedMax.y,m.max.y),t.partIndices.push(this.centroidData.length);}if(this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[r].borders[e][0]);}splitToSubtiles(){const e=[];for(let t=0;tTn),i=2*n+(+(r.min.x+r.max.x>Tn)^n);for(let n=0;ne.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let r=0,n=0,i=0;for(const t of e){if(t.triangleSegmentIdx!==r)break;i++;}const s=e.length;for(;n!==e.length;){r=e[n].triangleSegmentIdx;let a=0,o=n,l=n;for(let t=o;t0&&this.triangleSubSegments.push({segment:c,min:s,max:u}),o=l;for(let t=o;t[pr(e[0],t[0],r[0]),pr(e[1],t[1],r[1])],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Tn,d[1]=e.min.y/Tn,p[0]=e.max.x/Tn,p[1]=e.max.y/Tn;const t=h(u,c,d),a=h(u,c,p);if(0===new vf([t[0],t[1],i],[a[0],a[1],s]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const o=e.segment;l&&l.vertexOffset!==o.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=o.vertexLength,l.primitiveLength+=o.primitiveLength):l={vertexOffset:o.vertexOffset,primitiveLength:o.primitiveLength,vertexLength:o.vertexLength,primitiveOffset:o.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(e,t){const r=e.centroid(),n=t.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(6,Math.round(n.y*this.tileToMeter/10));return new be($e(r.x,1,8191)<<3|i,$e(r.y,1,8191)<<3|s)}encodeBorderCentroid(e){if(!e.borders)return new be(0,0);const t=e.borders,r=Number.MAX_VALUE;if(t[0][0]!==r||t[1][0]!==r){const e=t[0][0]!==r?0:1;return new be(6|(t[0][0]!==r?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==r?2:3;return new be((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==r?0:65528))}}showCentroid(e){const t=this.centroidData.get(e.centroidDataIndex);if(t.flags&=ev,0!==t.groupCentroidPos.x||0!==t.groupCentroidPos.y){const e=t.span(),r=Math.min(7,Math.round(e.x*this.tileToMeter/10)),n=Math.min(6,Math.round(e.y*this.tileToMeter/10));t.centroidXY=new be($e(t.groupCentroidPos.x,1,8191)<<3|r,$e(t.groupCentroidPos.y,1,8191)<<3|n);}else t.centroidXY=new be(0,0);this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,n=-1073741824&e.flags?Qx:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||i!==n.x){for(let e=t;ee.max.x||e.min.x>t.max.x||t.min.y>e.max.y||e.min.y>t.max.y||t.footprint.buildingIds.has(e.buildingId)&&(e.flags|=t.clipMask!==Hx.None?-1073741824:ev);else for(const r of this.centroidData)if(!(r.flags&ev||r.flags&tv||t.min.x>r.max.x||r.min.x>t.max.x||t.min.y>r.max.y||r.min.y>t.max.y))for(let s=0;st!=l>t&&e<(this.footprintVertices.int16[2*(o+s.vertexOffset)+0]-r)*(t-a)/(l-a)+r&&(n=!n);}a=r;}}return n}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(e+Tn)*Tn+(t+Tn);if(Object.hasOwn(this.partLookup,i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&ev)}:void 0}const s=this.centroidData.buffer,a=this.centroidData.length;for(let o=0;os[a+4]||s[a+2]>e||t>s[a+5]||s[a+3]>t)continue;const l=s[a+13];if(l<=r)continue;const u=this.centroidData.get(o);this.footprintContainsPoint(e,t,u)&&(r=l,this.partLookup[i]=u,n=!!(u.flags&ev));}if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function yv(e,t){const r=e.add(t)._unit();return e.x*r.x+e.y*r.y}function gv(e,t,r,n){const i=t.sub(e)._perp()._unit(),s=r.sub(t)._perp()._unit();return xv(e,t,r,yv(i,s),n)}function xv(e,t,r,n,i){const s=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(r)/3,i*s/n)}function vv(e,t,r){return e.xr[1].x&&t.x>r[1].x||e.yr[1].y&&t.y>r[1].y}function bv(e,t){return e.xt[1].x||e.yt[1].y}function wv(e){return e.every(e=>e.x<=0)||e.every(e=>e.x>=Tn)||e.every(e=>e.y<=0)||e.every(e=>e.y>=Tn)}function _v(e,t,r){if(e.x<0||e.x>=Tn||t.x<0||t.x>=Tn||r.x<0||r.x>=Tn)return !1;const n=r.sub(t),i=n.perp(),s=e.sub(t);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function Av(e,t,r){const n=t?2|e:-3&e;return r?1|n:-2&n}function Mv(){const e=Math.PI/32,t=Math.tan(e),r=xl;return r*Math.sqrt(1+2*t*t)-r}function Iv(e,t,r){const n=1<{for(const r of e)a.push({polygon:r,bounds:t});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):o(d,e);}if(f.length){const e=[new be(0===r?c:n.x,1===r?c:n.y),a];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):o(f,e);}}return a}(e,t,Math.ceil((s-i)/11.25),Math.ceil((a-o)/11.25),1,(e,t,i)=>{if(0===e)return .5*(t+i);{const e=gn((r.y+t/Tn)/n);return (mn(.5*(gn((r.y+i/Tn)/n)+e))*n-r.y)*Tn}})}function Sv(e,t,r,n,i,s){const a=Math.pow(2,n.z-i.z);for(let o=0;oBv?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Bv?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;0!==this.module.heapU8[e];)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters);}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t);}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t);}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0);}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0);}setFauxFacadeOptions(e,t,r){this.module.setFauxFacadeOptions(e?1:0,t?1:0,r);}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e);}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),r=this.createFloatArray(t.coordinates);if(-1===e||-1===r)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(t.id,t.sourceId,t.minHeight,t.height,t.roofType,r,e,t.ringIndices.length-1);}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const r=this.createFloatArray(t),n=this.createFloatArray(e.coordinates);if(-1===r||-1===n)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,r,t.length,n,e.coordinates.length);}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const r=this.module.getMeshCount(),n=new Array(r);for(let e=0;er||e.y<-t||e.y>r)return !1;return !0}function Vv(e){switch(e){case "flat":return 3;case "hipped":return 1;case "gabled":return 2;case "parapet":return 0;case "mansard":return 4;case "skillion":return 5;case "pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${e}`)}}let Fv,kv,Cv=null,Dv=null,Rv=null;class Lv{constructor(){this.layoutVertexArray=new tu,this.layoutAttenuationArray=new ou,this.layoutColorArray=new uu,this.indexArray=new fu,this.indexArrayForConflation=new fu,this.segmentsBucket=new qu;}}class Ov{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new qu,this.entranceBloom=new Lv;const t=66560;this.layoutVertexArray=new tu,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Xl,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Xl,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new uu,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new Bu,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new Eu,this.layoutAOArray.reserve(t),this.indexArray=new fu,this.indexArray.reserve(66560),this.indexArrayForConflation=new fu,this.segmentsBucket=new qu,this.entranceBloom=new Lv,e&&(this.layoutFacadePaintArray=new uu,this.layoutFacadeDataArray=new nu,this.layoutFacadeVerticalRangeArray=new uu);}reserve(e,t,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e));}}class Uv{constructor(e){this.requiresHDRuntime=!0,this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new _u,this.footprintsIndices=new Mu,this.footprintsMin=new be(1/0,1/0),this.footprintsMax=new be(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Ov(!1),this.buildingWithFacade=new Ov(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new vc(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new fv(e),this.groundEffect.groundRadiusArray=new Wl,this.hasAppearances=null;}updateFootprints(e,t){const r=new kg([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:n,id:e});}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){if(!Rv)return;const i=Pl(r);this.tileToMeter=i,this.brightness=t.brightness,Rv.setStyle({normalScale:[1,-1,i],tileToMeters:i}),Rv.setAOOptions(!1,.3),Rv.setMetricOptions(!1,16),Rv.setStructuralOptions(!0),Rv.setFacadeClassifierOptions(3);const s=new Map,a=new Map;let o=0;for(const{feature:t}of e){if("LineString"!==Pv[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Za(this.zoom),t,r))continue;const i=Ol(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new Za(this.zoom),i,r))continue;const l=e?i.geometry:Ll(t,r,n),u=[];for(const e of l)for(const t of e)u.push(t.x),u.push(t.y);const c={coordinates:u,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let d=a.get(h);d||(d=[],a.set(h,d)),d.push(c),++o;}this.maxHeight=0;const l=new Array,u=new Set,c=e=>{null!=e&&u.add(e);},h=(e,t)=>{null!=e&&l.push({buildingId:e,footprintIndex:t});},d=64*(e.length-o),p=d/2;this.buildingWithFacade.reserve(d,p,!0),this.buildingWithoutFacade.reserve(2*d,2*p,!1),this.footprintsIndices.reserve(16*(e.length-o)),this.footprintsVertices.reserve(8*(e.length-o));for(const{feature:o,id:l,index:d,sourceLayerIndex:p}of e){if("LineString"===Pv[o.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Za(this.zoom),o,r))continue;let f=null;if(o.properties&&Object.hasOwn(o.properties,"building_id")&&(f=Number(o.properties.building_id),u.has(f)))continue;const m=Ol(o,e);if(!e&&!this.layers[0]._featureFilter.filter(new Za(this.zoom),m,r))continue;const y=e?m.geometry:Ll(o,r,n),g=Be(y,500);let x=!1;for(const e of g)if(1!==e.length){x=!0;break}if(x){c(f);continue}if(!Tv(y,163)){c(f);continue}const v=this.layers[0],b=Vv(v.layout.get("building-roof-shape").evaluate(o,{},r)),w=v.layout.get("building-base").evaluate(o,{},r),_=v.layout.get("building-height").evaluate(o,{},r),A=v.layout.get("building-flood-light-ground-radius").evaluate(o,{},r),M=v.paint.get("building-ambient-occlusion-intensity"),I=A/this.tileToMeter;o.properties["building-part"]="roof";const S=v.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),B=v.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);o.properties["building-part"]="wall";const E=v.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),P=v.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);o.properties["building-part"]="window";const z=v.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),T=v.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);o.properties["building-part"]="door";const V=v.paint.get("building-color").evaluate(o,{},this.canonical).toPremultipliedRenderColor(this.lut),F=v.paint.get("building-emissive-strength").evaluate(o,{},this.canonical);let k=v.layout.get("building-flood-light-wall-radius").evaluate(o,{},r);k=$e(k,0,2048);const C=k/2048*zv,D=s.get(l),R=a.get(D)||[],L=0!==R.length&&v.layout.get("building-facade").evaluate(o,{},r);Rv.setFacadeOptions(4,!0),Rv.setFauxFacadeOptions(L,!1,1);let O=0,U=0,N=0,j=0,G=0,$=0,H=0,q=0,X=0,Z=0,W=0;if(L){let e=Math.round(v.layout.get("building-facade-floors").evaluate(o,{},r));if(0===w){e=Math.max(1,e-(R.length>0?1:0));let t=4;if(_>100){const e=[10,13,15];t=e[o.id?o.id%e.length:0];}else _<=10&&(t=3);Rv.setFacadeOptions(t,!0),G=(_<15?1.3:1.61803)*t/i;}else G=w/i;$=_/i,G=Math.min(G,$),N=v.layout.get("building-facade-unit-width").evaluate(o,{},r)/i,j=($-G)/e,Rv.setFauxFacadeOptions(!0,!0,N);const t=v.layout.get("building-facade-window").evaluate(o,{},r);O=t[0],U=t[1],H=Math.floor(65535*Math.min(1,G/Tn)),q=Math.floor(65535*Math.min(1,$/Tn)),X=Math.floor(255*O)<<8|Math.floor(255*U),Z=Math.floor(65535*Math.min(1,N/Tn)),W=Math.floor(65535*Math.min(1,j/Tn));}const Y=Array(g.length),K={x:1/0,y:1/0},J={x:-1/0,y:-1/0},Q={x:0,y:0};let ee=0;for(let e=0;e0){const r=[],n=Array(t.length+1);n[0]=0;for(let e=0;eTn||K.y<0||J.y>Tn)&&this.featuresOnBorder.push({featureId:o.id,footprintIndex:this.footprints.length});{const e=Do(ge,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,me),this.buildingIds.add(null!=f?f:o.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,xe.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,xe.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,ve.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,ve.y);const t={footprintVertexOffset:ye,footprintVertexLength:this.footprintsVertices.length-ye,footprintIndexOffset:me,footprintIndexLength:this.footprintsIndices.length-me,min:xe,max:ve,hiddenFlags:0,indicesOffset:he,indicesLength:fe,bloomIndicesOffset:oe,bloomIndicesLength:le,groundEffectVertexOffset:we,groundEffectVertexLength:_e,hasFauxFacade:L,height:de,promoteId:l,feature:m,parts:se,buildingBloom:ae},r=this.footprints.length;void 0!==o.id&&this.featureFootprintLookup.set(o.id,r),h(f,r),this.footprints.push(t);}this.programConfigurations.populatePaintArrays(re.layoutVertexArray.length,o,d,{},t.availableImages,r,t.brightness),this.groundEffect.addPaintPropertiesData(o,d,{},t.availableImages,r,t.brightness),t.featureIndex.insert(o,y,d,p,this.index,ue);}l.forEach(({buildingId:e,footprintIndex:t})=>{u.has(e)&&(this.footprints[t].hiddenFlags|=4);});const f=new Set;this.buildingIds.forEach((e,t,r)=>{u.has(e)||f.add(e);}),this.buildingIds=f,this.groundEffect.prepareBorderSegments();}update(e,t,r,n,i,s,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,a),this.groundEffect.update(e,t,i,r,n,s,a),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1;}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e);}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,Bx.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,Ex.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,Px.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,Cx.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,Vx.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,Fx.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,Bx.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,kx.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e);};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()));};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy();}updateFootprintHiddenFlags(e,t,r=!0){let n=!1;const i=r?t:0,s=0|(r?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],r=e.hiddenFlags&s|i;e.hiddenFlags!==r&&(e.hiddenFlags=r,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags));}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16));};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0));};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0;}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,zx.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,Tx.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,zx.members,!0);};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0;}evaluate(e,t){const r=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const i=t[n.promoteId],s=n.feature;s.properties["building-part"]="roof";const a=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),o=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),u=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="window";const c=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,i=a;1===e.part?(i=a,t=o):0===e.part?(i=l,t=u):2===e.part?(i=c,t=h):3===e.part&&(i=d,t=p),t=$e(t,0,1);for(let s=0;st.max.x||r.max.xt.max.y||r.max.ya.max.x||a.min.x>e||t>a.max.y||a.min.y>t||a.height<=r||Nv(s,this.footprintsVertices.float32.subarray(2*a.footprintVertexOffset,2*(a.footprintVertexOffset+a.footprintVertexLength)),this.footprintsIndices.uint16.subarray(a.footprintIndexOffset,a.footprintIndexOffset+a.footprintIndexLength))&&(r=a.height,this.footprintLookup[i]=a,n=0!==a.hiddenFlags);if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.footprintLookup[i]=void 0;}}function Nv(e,t,r){for(let n=0;n0&&this.rings[0].length>0}}async function $v(){}function Hv(e,t,r){const n=t.paint.get(e).value;return "constant"===n.kind?n.value:r.programConfigurations.get(t.id).getMaxValue(e)}function qv(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Xv(e,t,r,n,i){if(!t[0]&&!t[1])return e;const s=be.convert(t)._mult(i);"viewport"===r&&s._rotate(-n);const a=[];for(let t=0;t{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Kv(e,t,r,n,i,s,a,o,l){if(s&&e.queryGeometry.isAboveHorizon)return !1;s&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(o),d=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,p=r.projection.projectTilePoint(h.x,h.y,u);if(d>0){const e=r.projection.upVector(u,h.x,h.y);p.x+=e[0]*c*d,p.y+=e[1]*c*d,p.z+=e[2]*c*d;}const f=s?h:Jv(p.x,p.y,p.z,n),m=s?e.tilespaceRays.map(e=>tb(e,d)):e.queryGeometry.screenGeometry,y=Q([],[p.x,p.y,p.z,1],n);if(!a&&s?l*=y[3]/r.cameraToCenterDistance:a&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const e=gn((t.y/Tn+u.y)/(1<{t[e.evaluationKey]=a;const o=e.expression.evaluate(t),l=o?o.toNonPremultipliedRenderColor(s):null;l&&(i.data[r+n+0]=Math.floor(255*l.r),i.data[r+n+1]=Math.floor(255*l.g),i.data[r+n+2]=Math.floor(255*l.b),i.data[r+n+3]=Math.floor(255*l.a));};if(e.clips)for(let t=0,i=0;te.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.footprints)t.push({footprint:r,id:e});}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){const i=[];for(const{feature:s,id:a,index:o,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ol(s,e);if(!this.layers[0]._featureFilter.filter(new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,r))continue;const c={id:a,properties:s.properties,type:s.type,sourceLayerIndex:l,index:o,geometry:e?u.geometry:Ll(s,r,n),patterns:{}};i.push(c);}for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n;this.addFeature(n,i,s,r,{},t.availableImages,t.brightness),t.featureIndex.insert(e[s].feature,i,s,a,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(e){}update(e,t,r,n,i,s,a){}destroy(){}addFeature(e,t,r,n,i,s=[],a){for(const e of Be(t,2)){const t=[],r=[],n=[],i=new be(1/0,1/0),s=new be(-1/0,-1/0);for(const a of e)if(0!==a.length){a!==e[0]&&n.push(r.length/2);for(let e=0;e{e[0]=t,e[1]=r,e[2]=n,e[3]=1;},g=Mv();r>0&&(r+=g),n+=g;for(const g of t){const t=[],x=[];for(const h of g){const d=h.x+i.x,g=h.y+i.y,v=e.projection.projectTilePoint(d,g,c),b=e.projection.upVector(c,h.x,h.y);let w=r,_=n;if(a){const e=Ab(d,g,r,n,a,o,l,u);w+=e.base,_+=e.top;}0!==r?y(f,v.x+b[0]*p*w,v.y+b[1]*p*w,v.z+b[2]*p*w):y(f,v.x,v.y,v.z),y(m,v.x+b[0]*p*_,v.y+b[1]*p*_,v.z+b[2]*p*_),G(f,f,s),G(m,m,s),t.push(new nh(f[0],f[1],f[2])),x.push(new nh(m[0],m[1],m[2]));}h.push(t),d.push(x);}return [h,d]}(e,t,r,n,i,s,a,o,l,u,c):a?function(e,t,r,n,i,s,a,o,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const u of d){const c=u.x+n.x,d=u.y+n.y,f=Ab(c,d,t,r,s,a,o,l);h[0]=c,h[1]=d,h[2]=f.base,h[3]=1,Q(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new nh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=f.top,h[3]=1,Q(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new nh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(y);}u.push(e),c.push(p);}return [u,c]}(t,r,n,i,s,a,o,l,u):function(e,t,r,n,i){const s=[],a=[],o=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*r,d=i[9]*r,p=i[10]*r,f=i[11]*r;for(const t of e){const e=[],r=[];for(const s of t){const t=s.x+n.x,a=s.y+n.y,m=i[0]*t+i[4]*a+i[12],y=i[1]*t+i[5]*a+i[13],g=i[2]*t+i[6]*a+i[14],x=i[3]*t+i[7]*a+i[15],v=m+o,b=y+l,w=g+u,_=Math.max(x+c,1e-5),A=m+h,M=y+d,I=g+p,S=Math.max(x+f,1e-5);e.push(new nh(v/_,b/_,w/_)),r.push(new nh(A/S,M/S,I/S));}s.push(e),a.push(r);}return [s,a]}(t,r,n,i,s)}function Ab(e,t,r,n,i,s,a,o){const l=a*i.getElevationAt(e,t,!0,!0),u=0!==s[0],c=u?0===s[1]?a*(s[0]/7-450):a*function(e,t,r){const n=Math.floor(t[0]/8),i=Math.floor(t[1]/8),s=10*(t[0]-8*n),a=10*(t[1]-8*i),o=e.getElevationAt(n,i,!0,!0),l=e.getMeterToDEM(r),u=Math.floor(.5*(s*l-1)),c=Math.floor(.5*(a*l-1)),h=e.tileCoordToPixel(n,i),d=2*u+1,p=2*c+1,f=function(e,t,r,n,i){return [e.getElevationAtPixel(t,r,!0),e.getElevationAtPixel(t+i,r,!0),e.getElevationAtPixel(t,r+i,!0),e.getElevationAtPixel(t+n,r+i,!0)]}(e,h.x-u,h.y-c,d,p),m=Math.abs(f[0]-f[1]),y=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),x=Math.min(.25,.5*l*(m+y)/d),v=Math.min(.25,.5*l*g/p);return o+Math.max(x*s,v*a)}(i,s,o):l;return {base:l+(0===r?-1:r),top:u?Math.max(c+n,l+r+2):l+n}}function Mb(e,t,r){return t*(Tn/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}function Ib(e,t){return 1/Mb(e,1,t.tileZoom)}function Sb(e,t,r,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}Zs(xb,"ClipBucket",{omit:["layers"]});const Bb=e=>{const t=[];Eb(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT"),"multiply"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_MULTIPLY"),"additive"===e.paint.get("line-blend-mode")&&t.push("LINE_BLEND_ADDITIVE");const r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const n="none"===e.layout.get("line-join").constantOr("miter"),i=!!e.paint.get("line-pattern").constantOr(1);return n&&i&&t.push("LINE_JOIN_NONE"),t};function Eb(e){const t=e.paint.get("line-dasharray").value;return "constant"!==t.kind||t.value}let Pb;const zb=()=>Pb||(Pb={layout:mb||(mb=new ao({"line-cap":new io(oo.layout_line["line-cap"]),"line-join":new io(oo.layout_line["line-join"]),"line-miter-limit":new no(oo.layout_line["line-miter-limit"]),"line-round-limit":new no(oo.layout_line["line-round-limit"]),"line-sort-key":new io(oo.layout_line["line-sort-key"]),"line-z-offset":new io(oo.layout_line["line-z-offset"]),"line-elevation-reference":new no(oo.layout_line["line-elevation-reference"]),"line-cross-slope":new no(oo.layout_line["line-cross-slope"]),visibility:new no(oo.layout_line.visibility),"line-width-unit":new no(oo.layout_line["line-width-unit"]),"line-elevation-ground-scale":new io(oo.layout_line["line-elevation-ground-scale"])})),paint:yb||(yb=new ao({"line-opacity":new io(oo.paint_line["line-opacity"]),"line-color":new io(oo.paint_line["line-color"]),"line-translate":new no(oo.paint_line["line-translate"]),"line-translate-anchor":new no(oo.paint_line["line-translate-anchor"]),"line-width":new io(oo.paint_line["line-width"]),"line-gap-width":new io(oo.paint_line["line-gap-width"]),"line-offset":new io(oo.paint_line["line-offset"]),"line-blur":new io(oo.paint_line["line-blur"]),"line-dasharray":new io(oo.paint_line["line-dasharray"]),"line-pattern":new io(oo.paint_line["line-pattern"]),"line-pattern-cross-fade":new no(oo.paint_line["line-pattern-cross-fade"]),"line-gradient":new so(oo.paint_line["line-gradient"]),"line-trim-offset":new no(oo.paint_line["line-trim-offset"]),"line-trim-fade-range":new no(oo.paint_line["line-trim-fade-range"]),"line-trim-color":new no(oo.paint_line["line-trim-color"]),"line-emissive-strength":new io(oo.paint_line["line-emissive-strength"]),"line-border-width":new io(oo.paint_line["line-border-width"]),"line-border-color":new io(oo.paint_line["line-border-color"]),"line-occlusion-opacity":new no(oo.paint_line["line-occlusion-opacity"]),"line-blend-mode":new no(oo.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new no(oo.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},Pb);class Tb extends io{possiblyEvaluate(e,t){return t=new Za(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,n){return t={...t,zoom:Math.floor(t.zoom)},super.evaluate(e,t,r,n)}}let Vb,Fb,kb,Cb;function Db(e,t){return t>0?t+2*e:e}function Rb(e,t){return t.replace(/{([^{}]+)}/g,(t,r)=>r in e?String(e[r]):"")}class Lb{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Ar,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Zs(Lb,"FormatSectionOverride",{omit:["defaultValue"]});const Ob=()=>Cb||(Cb={layout:Fb||(Fb=new ao({"symbol-placement":new no(oo.layout_symbol["symbol-placement"]),"symbol-spacing":new no(oo.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new no(oo.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new io(oo.layout_symbol["symbol-sort-key"]),"symbol-z-order":new no(oo.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new no(oo.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new no(oo.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new no(oo.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new no(oo.layout_symbol["icon-ignore-placement"]),"icon-optional":new no(oo.layout_symbol["icon-optional"]),"icon-rotation-alignment":new no(oo.layout_symbol["icon-rotation-alignment"]),"icon-size":new io(oo.layout_symbol["icon-size"]),"icon-size-scale-range":new no(oo.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new io(oo.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new io(oo.layout_symbol["icon-text-fit-padding"]),"icon-image":new io(oo.layout_symbol["icon-image"]),"icon-image-use-theme":new no({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new io(oo.layout_symbol["icon-rotate"]),"icon-padding":new no(oo.layout_symbol["icon-padding"]),"icon-keep-upright":new no(oo.layout_symbol["icon-keep-upright"]),"icon-offset":new io(oo.layout_symbol["icon-offset"]),"icon-anchor":new io(oo.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new no(oo.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new no(oo.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new no(oo.layout_symbol["text-rotation-alignment"]),"text-field":new io(oo.layout_symbol["text-field"]),"text-font":new io(oo.layout_symbol["text-font"]),"text-size":new io(oo.layout_symbol["text-size"]),"text-size-scale-range":new no(oo.layout_symbol["text-size-scale-range"]),"text-max-width":new io(oo.layout_symbol["text-max-width"]),"text-line-height":new io(oo.layout_symbol["text-line-height"]),"text-letter-spacing":new io(oo.layout_symbol["text-letter-spacing"]),"text-justify":new io(oo.layout_symbol["text-justify"]),"text-radial-offset":new io(oo.layout_symbol["text-radial-offset"]),"text-variable-anchor":new no(oo.layout_symbol["text-variable-anchor"]),"text-anchor":new io(oo.layout_symbol["text-anchor"]),"text-max-angle":new no(oo.layout_symbol["text-max-angle"]),"text-writing-mode":new no(oo.layout_symbol["text-writing-mode"]),"text-rotate":new io(oo.layout_symbol["text-rotate"]),"text-padding":new no(oo.layout_symbol["text-padding"]),"text-keep-upright":new no(oo.layout_symbol["text-keep-upright"]),"text-transform":new io(oo.layout_symbol["text-transform"]),"text-offset":new io(oo.layout_symbol["text-offset"]),"text-allow-overlap":new no(oo.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new no(oo.layout_symbol["text-ignore-placement"]),"text-optional":new no(oo.layout_symbol["text-optional"]),visibility:new no(oo.layout_symbol.visibility)})),paint:kb||(kb=new ao({"icon-opacity":new io(oo.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new io(oo.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new io(oo.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new io(oo.paint_symbol["text-emissive-strength"]),"icon-color":new io(oo.paint_symbol["icon-color"]),"icon-halo-color":new io(oo.paint_symbol["icon-halo-color"]),"icon-halo-width":new io(oo.paint_symbol["icon-halo-width"]),"icon-halo-blur":new io(oo.paint_symbol["icon-halo-blur"]),"icon-translate":new no(oo.paint_symbol["icon-translate"]),"icon-translate-anchor":new no(oo.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new no(oo.paint_symbol["icon-image-cross-fade"]),"text-opacity":new io(oo.paint_symbol["text-opacity"]),"text-occlusion-opacity":new io(oo.paint_symbol["text-occlusion-opacity"]),"text-color":new io(oo.paint_symbol["text-color"],{runtimeType:Br,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new io(oo.paint_symbol["text-halo-color"]),"text-halo-width":new io(oo.paint_symbol["text-halo-width"]),"text-halo-blur":new io(oo.paint_symbol["text-halo-blur"]),"text-translate":new no(oo.paint_symbol["text-translate"]),"text-translate-anchor":new no(oo.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new no(oo.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new no(oo.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new no(oo.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new no(oo.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new io(oo.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},Cb);class Ub extends ko{constructor(e,t,r,n){super(e,Ob(),t,r,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=u([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint);}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0);}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(r=>{r.recalculate(e,t,this.iconImageUseTheme);}),"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 r=this.layout.get("text-writing-mode");if(r){const e=[];for(const t of r)e.includes(t)||e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,t,r,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,r,n){e=ct(e),t=ut(t);const i=o(),s=e/3,a=1-2*s,l=[a,s,s,0,s,a,s,0,s,s,a,0,0,0,0,1],u=.5-.5*t,c=n-r;return h(i,[c,0,0,0,0,c,0,0,0,0,c,0,r,r,r,1],[t,0,0,0,0,t,0,0,0,0,t,0,u,u,u,1]),h(i,i,l),i}(e,t,r,n),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,r,n){const i=this.layout.get(e).evaluate(t,{},r,n),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||Os(s.value)||!i?i:Rb(t.properties,i)}getAppearanceValueAndResolveTokens(e,t,r,n,i){const s=e.getLayoutProperty(t);if(!s)return;const a=s.evaluate(r,{},n,i),o=e.getUnevaluatedLayoutProperties()._values[t];return o.isDataDriven()||Os(o.value)||!a||"string"!=typeof a?a:Rb(r.properties,a)}createBucket(e){return new Gm(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of Ob().paint.overridableProperties){if(!Ub.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new Lb(t),n=new Ls(r,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Ns("source",n):new js("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new to(t.property,i,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,r){return !(!this.layout||t.isDataDriven()||r.isDataDriven())&&Ub.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),n=Ob().paint.properties[t];let i=!1;const s=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof jr)s(r.value.value.sections);else if("source"===r.value.kind){const e=t=>{i||(t instanceof Wr&&Xr(t.value)===Tr?s(t.value.sections):t instanceof Qr?s(t.sections):t.eachChild(e));},t=r.value;t._styleExpression&&e(t._styleExpression.expression);}return i}getProgramIds(){return ["symbol"]}getDefaultProgramParams(e,t,r){return {config:new xc(this,{zoom:t,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}mayUse(e){return "HD"===e&&Co(this,"symbol-elevation-reference",e=>"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?$v():Promise.resolve()}}let Nb,jb,Gb,$b;const Hb=1024,qb=(Math.pow(Hb,2)-1)/268170240;class Xb extends ko{constructor(e,t,r,n){super(e,{layout:Gb||(Gb=new ao({visibility:new no(oo.layout_raster.visibility)})),paint:$b||($b=new ao({"raster-opacity":new no(oo.paint_raster["raster-opacity"]),"raster-color":new so(oo.paint_raster["raster-color"]),"raster-color-mix":new no(oo.paint_raster["raster-color-mix"]),"raster-color-range":new no(oo.paint_raster["raster-color-range"]),"raster-hue-rotate":new no(oo.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new no(oo.paint_raster["raster-brightness-min"]),"raster-brightness-max":new no(oo.paint_raster["raster-brightness-max"]),"raster-saturation":new no(oo.paint_raster["raster-saturation"]),"raster-contrast":new no(oo.paint_raster["raster-contrast"]),"raster-resampling":new no(oo.paint_raster["raster-resampling"]),"raster-fade-duration":new no(oo.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new no(oo.paint_raster["raster-emissive-strength"]),"raster-array-band":new no(oo.paint_raster["raster-array-band"]),"raster-elevation":new no(oo.paint_raster["raster-elevation"]),"raster-elevation-reference":new no(oo.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN];}getProgramIds(){return ["raster"]}hasColorMap(){return !!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){const t=e?e._source:null;return (!t||"image"!==t.type&&"video"!==t.type&&"canvas"!==t.type||!t.onNorthPole&&!t.onSouthPole)&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e||(this._curRampRange=[NaN,NaN],this.updateColorRamp());}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}updateColorRamp(e){if(!this.hasColorMap())return;if(!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[r,n]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(n)||r===this._curRampRange[0]&&n===this._curRampRange[1]||(this.colorRamp=gb({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:n}],resolution:Hb}),this.colorRampTexture=null,this._curRampRange=[r,n]);}is3D(e){return this.paint.get("raster-elevation")>0}}let Zb,Wb,Yb,Kb,Jb,Qb,ew;class tw extends ko{constructor(e,t,r,n){super(e,{layout:Zb||(Zb=new ao({visibility:new no(oo["layout_raster-particle"].visibility)})),paint:Wb||(Wb=new ao({"raster-particle-array-band":new no(oo["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new no(oo["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new so(oo["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new no(oo["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new no(oo["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new no(oo["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new no(oo["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new no(oo["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp(),this.lastInvalidatedAt=vt.now();}mayUse(e){return "HD"===e}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null);}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy();}hasColorMap(){return !!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return ["rasterParticle"]}hasOffscreenPass(){return "none"!==this.visibility}isDraped(e){return !1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=gb({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=vt.now();}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class rw extends ko{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(e){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}function nw(e,t,r){const n=[0,0,1],i=te([]);return ne(i,i,r?-Oe(e)+Math.PI:Oe(e)),re(i,i,-Oe(t)),$(n,n,i),O(n,n)}class iw{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class sw{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Iu,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}colorForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=Math.floor(r[t+2]);const i=1.05*(r[t+2]-n);return n/=100,[r[t]%1*1.05,r[t+1]%1*1.05,i,n]}tileCoordinatesForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=r[t+0];return n=n>Tn?n-Tn:n,new be(Math.trunc(n),Math.trunc(r[t+1]))}translationForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+4],r[t+5],r[t+6]]}rotationScaleForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+10],r[t+11],r[t+12],r[t+13],r[t+14],r[t+15]]}transformForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+4],r[t+10],r[t+11],r[t+12],r[t+5],r[t+13],r[t+14],r[t+15],r[t+6],0,0,0,1]}}class aw{constructor(e){this.requiresStandardRuntime=!0,this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,n){this.tileToMeter=Pl(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const s="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?t.elevationFeatures:void 0;for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of e){const e=null!=o?o:a.properties&&Object.hasOwn(a.properties,"id")?a.properties.id:void 0,c=Ol(a,i);if(!this.layers[0]._featureFilter.filter(new Za(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h={id:e,sourceLayerIndex:u,index:l,geometry:i?c.geometry:Ll(a,r,n),properties:a.properties,type:a.type,patterns:{}},d=this.addFeature(h,h.geometry,c,s,r);d&&t.featureIndex.insert(a,h.geometry,l,u,this.index,this.instancesPerModel[d].instancedDataArray.length,256);}this.lookup=null;}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let r=0;for(const n of this.modelUris){const i=e.getModel(n,t);if(!i)continue;const s=this.instancesPerModel[n];if(s){const e=.5*C(i.aabb.max,i.aabb.min)*s.maxScale+s.maxXYTranslationDistance,t=Math.min(Tn,Math.max(e/this.tileToMeter,256));r=Math.max(t,r);}}return r}update(e,t,r,n){for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t in e)Object.hasOwn(r.idToFeaturesIndex,t)&&(this.evaluate(r.features[r.idToFeaturesIndex[t]],e[t],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t of r.features){const n=this.layers[0],i=t.feature,s=this.canonical,a=n.paint.get("model-rotation").evaluate(i,{},s),o=n.paint.get("model-scale").evaluate(i,{},s),l=n.paint.get("model-translation").evaluate(i,{},s);q(t.rotation,a)&&q(t.scale,o)&&q(t.translation,l)||(this.evaluate(t,t.featureStates,r,!0),e=!0);}}return e}updateReplacement(e,t,r,n){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Im(this.activeReplacements,i))return !1;this.activeReplacements=i;let s=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t],a=i.instancedDataArray;for(const t of i.features){const i=t.instancedDataOffset,o=t.instancedDataCount;for(let t=0;tTn;l=u?l-Tn:l;const c=Math.floor(l),h=Math.floor(a.float32[o+1]);let d=!1;for(const t of this.activeReplacements)if(!wm(t,r,Hx.Model,n)&&!(t.min.x>c||c>t.max.x||t.min.y>h||h>t.max.y)&&(d=Tm(zm(c,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;a.float32[o]=d?l+Tn:l,s=s||d!==u;}}}return s}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,Ng.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(e){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const e of this.modelUris)t.removeModel(e,"",!0);}addFeature(e,t,r,n,i){const s=this.layers[0],a=s.layout.get("model-id"),o=s.layout.get("model-allow-density-reduction"),l=a.evaluate(r,{},this.canonical);if(!l)return nt(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),l;!l.includes("://")&&!this.styleDefinedModelURLs[l]||this.modelUris.includes(l)||this.modelUris.push(l),this.instancesPerModel[l]||(this.instancesPerModel[l]=new sw);const u=this.instancesPerModel[l],c=u.instancedDataArray,h=new iw(r,c.length);let d;if(n){const t=uy(e,n,void 0,i);d=t?t.feature:void 0;}for(const e of t)for(const t of e){if(t.x<0||t.x>=Tn||t.y<0||t.y>=Tn)continue;if(0!==this.lookupDim&&o){const e=(this.lookupDim-1)/Tn,r=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}}this.instanceCount++;const e=c.length;if(c.resize(e+1),n){u.instancesRoadElevation||(u.instancesRoadElevation=[]);const e=d?d.pointElevation(new be(t.x,t.y)):0;u.instancesRoadElevation.push(e);}u.instancesEvaluatedElevation.push(0),c.float32[16*e]=t.x,c.float32[16*e+1]=t.y;}return h.instancedDataCount=u.instancedDataArray.length-h.instancedDataOffset,h.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(h),this.evaluate(h,{},u,!1)),l}getModelUris(){return this.modelUris}evaluate(e,t,r,n){const i=this.layers[0],s=e.feature,a=this.canonical,o=e.rotation=i.paint.get("model-rotation").evaluate(s,t,a),l=e.scale=i.paint.get("model-scale").evaluate(s,t,a),u=e.translation=i.paint.get("model-translation").evaluate(s,t,a),{r:c,g:h,b:d}=i.paint.get("model-color").evaluate(s,t,a),p=i.paint.get("model-color-mix-intensity").evaluate(s,t,a),f=[];this.maxVerticalOffset0?Math.sqrt(m):0;r.maxScale=Math.max(Math.max(r.maxScale,l[0]),Math.max(l[1],l[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,y),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Yg(f,o,l);const g=Math.round(100*p)+d/1.05;for(let t=0;t10?this.tileToMeter:Pl(a,d)),o[s+4]=u[0],o[s+5]=u[1],o[s+6]=u[2]+(r.instancesRoadElevation?r.instancesRoadElevation[i]:0)+l,o[s+7]=f[0],o[s+8]=f[1],o[s+9]=f[2],o[s+10]=f[4],o[s+11]=f[5],o[s+12]=f[6],o[s+13]=f[8],o[s+14]=f[9],o[s+15]=f[10],r.instancesEvaluatedElevation[i]=u[2];}}}Zs(aw,"ModelBucket",{omit:["layers"]}),Zs(sw,"PerModelAttributes"),Zs(iw,"ModelFeature");class ow{constructor(e,t,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=r;}static create(e,t,r){const n=r||e.findDEMTileFor(t);if(!n||!n.dem)return;const i=n.dem,s=n.tileID,a=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=tx.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=tx.HasMapboxMeshFeatures),i&&(this.modelTraits|=tx.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=s,this.worldview=o,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new mw(e)),pw(e,a.featureIndexArray.length,a.grid),a.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,a.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&t.push({footprint:n.footprint,id:e});}}updateAppearances(e,t,r,n){return {hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const r=t?this.stateDependentLayers:this.layers;if(!we(e,this.states))for(const t of r)this.evaluate(t,e);this.states=structuredClone(e);}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const r of t){const t=r.node;this.uploaded?this.updatePbrBuffer(t):ax(t,e,!0);}for(const e of t)lx(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);if(e.lodMeshes)for(const r of e.lodMeshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);return t}needsReEvaluation(e,t,r){const n=e.transform.projectionOptions,i=e.style.getBrightness(),s=this.brightness!==i;if(!this.uploaded||this.dirty||n.name!==this.projection.name||gw(r.paint.get("model-color").value,s)||gw(r.paint.get("model-color-mix-intensity").value,s)||gw(r.paint.get("model-roughness").value,s)||gw(r.paint.get("model-emissive-strength").value,s)||gw(r.paint.get("model-height-based-emissive-strength-multiplier").value,s)){this.projection=n,this.brightness=i;const e=this.getNodesInfo();for(const t of e)t.state=null;return !0}return !1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const e of r){const r=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(r,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(r,{},n);}}evaluate(e,t){const r=this.getNodesInfo();for(const n of r){if(!n.node.meshes)continue;const r=n.feature,i=t&&t[r.id];if(we(i,n.state))continue;n.state=structuredClone(i);const s=n.node.meshes&&n.node.meshes[0].featureData,a=n.evaluatedColor[2],o=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,s){for(let t=0;t=e)continue;const h=lw[u],d=Math.abs(h);d>o&&(a=h,o=d,l=i,c=t);}if(o>.1){const s=1-(e+.5*Math.abs(l*c))/u;let o=t._dem.get(n,r)+a*s;const h=t._dem.get(n+l,r+c),d=t._dem.get(n-l,r-c,!0);(o-h)*(o-d)>0&&(o=(h+d)/2),lw[i]=t._dem.set(n,r,o),uw[i]=e;}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=vt.now());}setFilter(e){this.filter=e?ho(e):null;}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Za(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)lx(t.node),cx(t.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!r.some(e=>e.footprint===t);}}getHeightAtTileCoord(e,t){const r=[0,0,0],n=u([]);for(const i of this.getNodesInfo()){const s=i.node.meshes[0],a=s.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===i.node.hidden)return {height:1/0,maxHeight:i.feature.properties.height,hidden:!1,verticalScale:i.evaluatedScale[2]};if(c(n,i.node.globalMatrix),r[0]=e,r[1]=t,r[2]=0,G(r,r,n),i.node.meshBVH){const e=r[0],t=r[1];cw[0]=e-1,cw[1]=t-1,cw[2]=-1e3,hw[0]=e+1,hw[1]=t+1,hw[2]=1e3;const n=i.node.meshBVH.findHighestPoint(cw,hw);if(null!==n)return {height:n,maxHeight:i.feature.properties.height,hidden:i.hiddenByReplacement,verticalScale:i.evaluatedScale[2]};continue}const o=(r[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*ex|0,l=Math.min(63,(r[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*ex|0)*ex+Math.min(63,o),u=s.heightmap[l];if(u<0&&i.node.footprint){const r=[];if(i.node.footprint.grid.query(new be(e,t),new be(e,t),r),r.length>0)return {height:void 0,maxHeight:i.feature.properties.height,hidden:i.hiddenByReplacement,verticalScale:i.evaluatedScale[2]};continue}if(i.hiddenByReplacement)return;return {height:u,maxHeight:i.feature.properties.height,hidden:!1,verticalScale:i.evaluatedScale[2]}}}}function gw(e,t){return e instanceof Ns&&!e.isLightConstant&&t}function xw(e){const t=$e(e,0,2);return Math.min(Math.round(.5*t*255),255)}const vw=new Float64Array(10*fw.length);function bw(e,t,r,n,i){if(!e.featureData)return;const s=e.featureArray=new Su;s.reserveExact(e.featureData.length),function(e,t,r){const n=r-t;for(let r=0;r>r&65535,i=t>>n&15,u=i<8?i:0,c=10*u;let h=(61440&e|(61440&e)>>4)>>8,d=(3840&e|(3840&e)>>4)>>4,p=240&e|(240&e)>>4;const f=(15&e|(15&e)<<4)/255,m=a[c+3];m>0&&(h=pr(h,a[c],m),d=pr(d,a[c+1],m),p=pr(p,a[c+2],m)),h*=f,d*=f,p*=f;const y=h<<8|d,g=p<<8|a[c+4],x=a[c+5],v=a[c+6],b=a[c+7],w=a[c+8],_=a[c+9];if(s.emplaceBack(y,g,x,v,b,w,_),l&&2===u){l=!1;const e=10*o.lights.length,t=new Su;t.reserveExact(e);for(let r=0;r"string"==typeof e)){e.nodeOverrideNames=[];for(const r of t)e.nodeOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n={orientation:[0,0,0],minZoom:void 0,maxZoom:void 0};if(Object.hasOwn(r,"orientation")){const e=r.orientation;e&&(n.orientation=e);}Object.hasOwn(r,"minzoom")&&(n.minZoom=r.minzoom),Object.hasOwn(r,"maxzoom")&&(n.maxZoom=r.maxzoom),e.nodeOverrides.set(t,n);});}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const r of t)e.materialOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n=r["model-color"],i={color:void 0!==n?new mr(n[0],n[1],n[2]):new mr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},s=r["model-color-mix-intensity"];void 0!==s&&(i.colorMix=s);const a=r["model-emissive-strength"];void 0!==a&&(i.emissionStrength=a);const o=r["model-opacity"];void 0!==o&&(i.opacity=o),e.materialOverrides.set(t,i);});}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){if(0===this._modelsInfo.size)return !0;for(const e of this._modelsInfo.values())if(null==e.model)return !1;return !0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return !1}reload(){this.cancelModelRequests();const e=Io(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load();}onRemove(e){this.cancelModelRequests();}setModels(e){this.models=[];const t=new Map;for(const r in e){const n=e[r],i=this._modelsInfo.get(r);i&&i.modelSpec.uri===n.uri&&t.set(r,i);}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[e,r]of t)r.model||t.delete(e);}this._modelsInfo=t,this._options.models=e,this.load();}}function Iw(e,t,r,n){const i=1<"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?$v():Promise.resolve()}},heatmap:class extends ko{createBucket(e){return new rb(e)}constructor(e,t,r,n){super(e,{layout:nb||(nb=new ao({visibility:new no(oo.layout_heatmap.visibility)})),paint:ib||(ib=new ao({"heatmap-radius":new io(oo.paint_heatmap["heatmap-radius"]),"heatmap-weight":new io(oo.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new no(oo.paint_heatmap["heatmap-intensity"]),"heatmap-color":new so(oo.paint_heatmap["heatmap-color"]),"heatmap-opacity":new no(oo.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=gb({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);}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}queryRadius(e){return Hv("heatmap-radius",this,e)}queryIntersectsFeature(e,t,r,n,i,s,a,o){const l=this.paint.get("heatmap-radius").evaluate(t,r);return Kv(e,n,s,a,o,!0,!0,new be(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t,r){return "heatmap"===e?{config:new xc(this,{zoom:t,lut:r}),overrideFog:!1}:{}}},hillshade:class extends ko{constructor(e,t,r,n){super(e,{layout:sb||(sb=new ao({visibility:new no(oo.layout_hillshade.visibility)})),paint:ab||(ab=new ao({"hillshade-illumination-direction":new no(oo.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new no(oo.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new no(oo.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new no(oo.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new no(oo.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new no(oo.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new no(oo.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t,r){return {overrideFog:!1}}},fill:class extends ko{constructor(e,t,r,n){super(e,{layout:ob||(ob=new ao({"fill-sort-key":new io(oo.layout_fill["fill-sort-key"]),visibility:new no(oo.layout_fill.visibility),"fill-elevation-reference":new no(oo.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new io(oo.layout_fill["fill-construct-bridge-guard-rail"])})),paint:lb||(lb=new ao({"fill-antialias":new no(oo.paint_fill["fill-antialias"]),"fill-opacity":new io(oo.paint_fill["fill-opacity"]),"fill-color":new io(oo.paint_fill["fill-color"]),"fill-outline-color":new io(oo.paint_fill["fill-outline-color"]),"fill-translate":new no(oo.paint_fill["fill-translate"]),"fill-translate-anchor":new no(oo.paint_fill["fill-translate-anchor"]),"fill-pattern":new io(oo.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new no(oo.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new no(oo.paint_fill["fill-emissive-strength"]),"fill-z-offset":new io(oo.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new io(oo.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new io(oo.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),r=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(e,t,r){return {config:new xc(this,{zoom:t,lut:r}),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(e){return new Sc(e)}queryRadius(){return qv(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,r,n,i,s){return !e.queryGeometry.isAboveHorizon&&Gc(Xv(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),n)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(e){if(0!==this.paint.get("fill-z-offset").constantOr(1))return !0;const t=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=e?t&&!e:t}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}mayUse(e){return "HD"===e&&Co(this,"fill-elevation-reference",e=>"none"!==e)}prepare(){return this.mayUse("HD")?$v():Promise.resolve()}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends ko{constructor(e,t,r,n){super(e,{layout:hb||(hb=new ao({visibility:new no(oo["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new no(oo["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new no(oo["layout_fill-extrusion"]["source-max-zoom"])})),paint:db||(db=new ao({"fill-extrusion-opacity":new no(oo["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new io(oo["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new no(oo["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new no(oo["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new io(oo["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new no(oo["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new io(oo["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new io(oo["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new no(oo["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new no(oo["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new no(oo["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new no(oo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new no(oo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new no(oo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new no(oo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new no(oo["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new no(oo["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new no(oo["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new io(oo["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new io(oo["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new no(oo["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new no(oo["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new no(oo["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new no(oo["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new no(oo["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new io(oo["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new io(oo["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new no(oo["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new mv(e)}queryRadius(){return qv(this.paint.get("fill-extrusion-translate"))}is3D(e){return !0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,r,n,i,s,a,o,l){const u=Zv(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,r),h=this.paint.get("fill-extrusion-base").evaluate(t,r),d=[0,0],p=o&&s.elevation,f=s.elevation?s.elevation.exaggeration():1,m=e.tile.getBucket(this);if(m instanceof mv){const e=m.centroidData.find(e=>l>=e.vertexArrayOffset&&le.polygon).flat());const y=p?o:null,[g,x]=_b(s,n,h,c,u,a,y,d,f,s.center.lat,e.tileID.canonical),v=e.queryGeometry;return wb(g,x,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},building:class extends ko{constructor(e,t,r,n){super(e,{layout:pb||(pb=new ao({visibility:new no(oo.layout_building.visibility),"building-facade":new io(oo.layout_building["building-facade"]),"building-facade-floors":new io(oo.layout_building["building-facade-floors"]),"building-facade-unit-width":new io(oo.layout_building["building-facade-unit-width"]),"building-facade-window":new io(oo.layout_building["building-facade-window"]),"building-roof-shape":new io(oo.layout_building["building-roof-shape"]),"building-height":new io(oo.layout_building["building-height"]),"building-base":new io(oo.layout_building["building-base"]),"building-flood-light-wall-radius":new io(oo.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new io(oo.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new io(oo.layout_building["building-flip-roof-orientation"])})),paint:fb||(fb=new ao({"building-opacity":new no(oo.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new no(oo.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new no(oo.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new no(oo.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new no(oo.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new no(oo.paint_building["building-vertical-scale"]),"building-cast-shadows":new no(oo.paint_building["building-cast-shadows"]),"building-color":new io(oo.paint_building["building-color"]),"building-emissive-strength":new io(oo.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new no(oo.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new no(oo.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new no(oo.paint_building["building-front-cutoff"]),"building-flood-light-color":new no(oo.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new no(oo.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new no(oo.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}mayUse(e){return "HD"===e}prepare(){return async function(){return function(){if(!at(self))return null;if(null!=Rv||null!=Dv)return null;if(null!=Cv)return Cv;const e=fetch(Mt());return Cv=function(e){let t,r,n,i,s;function a(){t=new Uint8Array(s.buffer),r=new Int16Array(s.buffer),n=new Int32Array(s.buffer),i=new Float32Array(s.buffer);}function o(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a:o,f:function(e){const r=t.length,n=Math.max(e>>>0,Math.ceil(1.2*r)),i=Math.ceil((n-r)/65536);try{return s.grow(i),a(),!0}catch(e){return !1}},g:o,b:l,c:l,d:l,e:l}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,u):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,u))).then(e=>{const o=e.instance.exports;return (0,o.g)(),s=o.f,a(),new Ev({setStyle:o.h,setAOOptions:o.i,setMetricOptions:o.j,setStructuralOptions:o.k,setFacadeOptions:o.l,setFauxFacadeOptions:o.m,setFacadeClassifierOptions:o.n,addFeature:o.o,addFacade:o.p,generateMesh:o.q,getLastError:o.r,getOuterRingLength:o.s,getMeshCount:o.t,getPositionsPtr:o.u,getPositionsLength:o.v,getNormalsPtr:o.w,getNormalsLength:o.x,getAOPtr:o.y,getAOLength:o.z,getUVPtr:o.A,getUVLength:o.B,getFauxFacadePtr:o.C,getFauxFacadeLength:o.D,getIndicesPtr:o.E,getIndicesLength:o.F,getBuildingPart:o.G,getRingCount:o.H,getRingPtr:o.I,getRingLength:o.J,malloc:o.K,free:o.L,heapU8:t,heap16:r,heap32:n,heapF32:i})})}(e).then(e=>{Cv=null,Rv=e;}).catch(e=>{nt("Could not load building-gen"),Cv=null,Dv=e;}),Cv}()}()}createBucket(e){return new Uv(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return !0}canCastShadows(){return !0}is3D(e){return !0}queryRadius(e){return 0}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){let c=this.layout.get("building-height").evaluate(t,r);const h=this.layout.get("building-base").evaluate(t,r),d=e.tile.getBucket(this).getFootprint(t);if(d){if(0!==d.hiddenFlags)return !1;c=d.height;}const[p,f]=_b(s,n,h,c,new be(0,0),a,null,[0,0],1,s.center.lat,e.tileID.canonical),m=e.queryGeometry;return wb(p,f,m.isPointQuery()?m.screenBounds:m.screenGeometry)}},line:class extends ko{constructor(e,t,r,n){const i=zb();super(e,i,t,r,n),i.layout&&(this.layout=new ro(i.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null;}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Ii,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}else "line-gradient-use-theme"===e&&(this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER);}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(Vb)return Vb;const e=zb();return Vb=new Tb(e.paint.properties["line-width"].specification),Vb.useIntegerZoom=!0,Vb})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e);}createBucket(e){return new _h(e)}getProgramIds(){const e=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return "default"!==this.paint.get("line-blend-mode")&&e.push("lineBlendComposite"),e}getDefaultProgramParams(e,t,r){if("lineBlendComposite"===e)return {};const n=Bb(this);return {config:new xc(this,{zoom:t,lut:r}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,r=Db(Hv("line-width",this,t),Hv("line-gap-width",this,t)),n=Hv("line-offset",this,t);return r/2+Math.abs(n)+qv(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,r,n,i,s){if(e.queryGeometry.isAboveHorizon)return !1;const a=Xv(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),o=e.pixelToTileUnitsFactor/2*Db(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),l=this.paint.get("line-offset").evaluate(t,r);return l&&(n=function(e,t){const r=[],n=new be(0,0);for(let i=0;i=3)for(let t=0;t"hd-road-markup"===e)}prepare(){return this.mayUse("HD")?$v():Promise.resolve()}hasOffscreenPass(){return "default"!==this.paint.get("line-blend-mode")&&0!==this.paint.get("line-opacity").constantOr(1)&&0!==this.paint.get("line-width").constantOr(1)&&"none"!==this.visibility}resize(){this._destroyLineBlendFbo();}onRemove(e){this._destroyLineBlendFbo(e.painter&&e.painter.context&&e.painter.context.gl||void 0);}_clear(){this._destroyLineBlendFbo();}_destroyLineBlendFbo(e){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),e&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(e),this.lineBlendDensityReadback=null;}},symbol:Ub,background:class extends ko{constructor(e,t,r,n){super(e,{layout:Nb||(Nb=new ao({visibility:new no(oo.layout_background.visibility)})),paint:jb||(jb=new ao({"background-pitch-alignment":new no(oo.paint_background["background-pitch-alignment"]),"background-color":new no(oo.paint_background["background-color"]),"background-pattern":new no(oo.paint_background["background-pattern"]),"background-opacity":new no(oo.paint_background["background-opacity"]),"background-emissive-strength":new no(oo.paint_background["background-emissive-strength"]),"background-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n);}getProgramIds(){return [this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t,r){return {overrideFog:!1}}is3D(e){return "viewport"===this.paint.get("background-pitch-alignment")}},raster:Xb,"raster-particle":tw,sky:class extends ko{constructor(e,t,r,n){super(e,{layout:Yb||(Yb=new ao({visibility:new no(oo.layout_sky.visibility)})),paint:Kb||(Kb=new ao({"sky-type":new no(oo.paint_sky["sky-type"]),"sky-atmosphere-sun":new no(oo.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new no(oo.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new no(oo.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new no(oo.paint_sky["sky-gradient-radius"]),"sky-gradient":new so(oo.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new no(oo.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new no(oo.paint_sky["sky-atmosphere-color"]),"sky-opacity":new no(oo.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp();}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0;}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0);}_updateColorRamp(){this.colorRamp=gb({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return !0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return !1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const r=this.paint.get("sky-atmosphere-sun"),n=!r,i=e.style.light,s=i.properties.get("position");return n&&"viewport"===i.properties.get("anchor")&&nt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?nw(s.azimuthal,90-s.polar,t):nw(r[0],90-r[1],t)}const r=this.paint.get("sky-gradient-center");return nw(r[0],90-r[1],t)}isSky(){return !0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position");}hasOffscreenPass(){return !0}getProgramIds(){const e=this.paint.get("sky-type");return "atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends ko{constructor(e,t,r,n){super(e,{paint:Jb||(Jb=new ao({}))},t,null);}},model:class extends ko{constructor(e,t,r,n){super(e,{layout:Qb||(Qb=new ao({visibility:new no(oo.layout_model.visibility),"model-id":new io(oo.layout_model["model-id"]),"model-allow-density-reduction":new no(oo.layout_model["model-allow-density-reduction"])})),paint:ew||(ew=new ao({"model-opacity":new io(oo.paint_model["model-opacity"]),"model-rotation":new io(oo.paint_model["model-rotation"]),"model-scale":new io(oo.paint_model["model-scale"]),"model-translation":new io(oo.paint_model["model-translation"]),"model-color":new io(oo.paint_model["model-color"]),"model-color-mix-intensity":new io(oo.paint_model["model-color-mix-intensity"]),"model-type":new no(oo.paint_model["model-type"]),"model-cast-shadows":new no(oo.paint_model["model-cast-shadows"]),"model-receive-shadows":new no(oo.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new no(oo.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new io(oo.paint_model["model-emissive-strength"]),"model-roughness":new io(oo.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new io(oo.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new no(oo.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new no(oo.paint_model["model-front-cutoff"]),"model-elevation-reference":new no(oo.paint_model["model-elevation-reference"]),"model-line-cutout-mode":new no(oo.paint_model["model-line-cutout-mode"]),"model-color-use-theme":new io({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this.layer=e,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}mayUse(e){return "Standard"===e}prepare(){return async function(){return Promise.resolve()}()}createBucket(e){return new aw(e)}getProgramIds(){return ["model"]}is3D(e){return !0}hasShadowPass(){return !0}canCastShadows(){return !0}hasLightBeamPass(){return !0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(e){return e instanceof yw?8191:0}queryRenderedFeatures(e,t,r){const n=t.getSource();if(!(n&&n instanceof Mw))return {};const i=n,s={};s[this.id]=[];const a=s[this.id];let o=0;for(const n of i.models){const i=t.getFeatureState(this.sourceLayer,n.id),s={type:"Unknown",id:n.id,properties:n.featureProperties},l=this.paint.get("model-rotation").evaluate(s,i),u=this.paint.get("model-scale").evaluate(s,i),c=this.paint.get("model-translation").evaluate(s,i),d=this.paint.get("model-elevation-reference");let p=[];rx(p,n,r,n.position,l,u,c,"ground"===d,"ground"===d,!1),"globe"===r.projection.name&&(p=Jg(p,r));const f=h([],r.projMatrix,p),m=Qg(e.isPointQuery()?e.screenBounds:e.screenGeometry,r,f,n.aabb);if(null!=m){const e=new Aw(void 0,0,0,0,n.id);e.layer=this.layer,e.properties=structuredClone(n.featureProperties),e.properties.layer=this.id,e.properties.uri=n.uri,e.properties.orientation=n.orientation,e.sourceLayer=this.sourceLayer,e.geometry={type:"Point",coordinates:[n.position.lng,n.position.lat]},e.state=i,e.source=this.source,a.push({featureIndex:o,feature:e,intersectionZ:m});}++o;}return s}queryIntersectsFeature(e,t,r,n,i,s,a,o,l,u){if(!this.modelManager)return !1;const c=this.modelManager,d=e.tile.getBucket(this);if(!(d&&d instanceof aw))return !1;for(const r in d.instancesPerModel){const n=d.instancesPerModel[r],i=void 0!==t.id?t.id:t.properties&&Object.hasOwn(t.properties,"id")?t.properties.id:void 0;if(Object.hasOwn(n.idToFeaturesIndex,i)){const t=n.features[n.idToFeaturesIndex[i]],a=c.getModel(r,u||this.scope);if(!a)return !1;let o=[];const l=new bl(0,0),p=d.canonical;let f=Number.MAX_VALUE;for(let r=0;r{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&&(this._channel.port1.close(),this._channel.port2.close()),this._callback=()=>{};}}const zw={Other:0,Symbol:1,FillExtrusion:2,HdRoadCoverage:3,HdRoadElevation:4};class Tw{constructor(){this.tasks=new Map,Ke(["process"],this),this.invoker=new Pw(this.process),this.nextId=0;}add(e,t){const r=this.nextId++,n=function({type:e,renderSourceType:t,zoom:r}){r=r||0;const n=t===zw.Symbol;return "message"===e?0:"maybePrepare"!==e||n?"parseTile"!==e||n?"parseTile"===e&&n?300-r:"maybePrepare"===e&&n?400-r:500:200-r:100-r}(t);if(0===n){try{e();}finally{}return null}return this.tasks.set(r,{fn:e,metadata:t,priority:n,id:r}),this.invoker.trigger(),{cancel:()=>{this.tasks.delete(r);}}}process(){try{const e=this.pick();if(!e)return;this.tasks.delete(e.id),this.tasks.size>0&&this.invoker.trigger(),e.fn();}finally{}}pick(){let e=null,t=1/0;for(const r of this.tasks.values())r.priority=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Uc(new rd(this.rawTileData)).layers,this.sourceLayerCoder=new Fw(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t){const{tilespaceGeometry:r,transform:n,tileTransform:i,pixelPosMatrix:s,availableImages:a,worldview:o}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,u=r.bufferedTilespaceBounds,c=this.grid.queryKeys(u.min.x,u.min.y,u.max.x,u.max.y,(e,t,n,i)=>Qc(r.bufferedTilespaceGeometry,e-l,t-l,n+l,i+l));c.sort(Dw);let h=null;n.elevation&&c.length>0&&(h=ow.create(n.elevation,this.tileID));const d={};let p;for(let l=0;l(m||(m=Ll(e,this.tileID.canonical,i)),a.queryIntersectsFeature(r,e,o,m,this.z,n,s,h,l,t.scope)));}return d}loadMatchingFeature(e,t,r,n,i,s){const{featureIndex:a,bucketIndex:o,sourceLayerIndex:l,layoutVertexArrayOffset:u}=t,c=this.bucketLayerIDs[o],h=r.layers,d=Object.keys(h);if(d.length&&!tt(d,c))return;const p=r.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(a),y=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ");return void nt(`Failed to create expression for promoteId: ${t}`)}this.promoteIdExpression=e.value;}r=this.promoteIdExpression.evaluate({zoom:0},e);}else r=e.properties[n];"boolean"==typeof r&&(r=Number(r));}return r}}function Cw(e,t,r,n,i){return Je(e,(e,s)=>{const a=t instanceof ro?t.get(s):null;return a&&a.evaluate?a.evaluate(r,n,void 0,i):a})}function Dw(e,t){return t-e}function Rw(e,t){const r={};let n;for(;n=e.nextField(t);)1===n?(r.delta_filter=Lw(e,e.readVarint()+e.pos),r.filter="delta_filter"):2===n?(e.readVarint(),r.filter="zigzag_filter"):3===n?(e.readVarint(),r.filter="bitshuffle_filter"):4===n&&(e.readVarint(),r.filter="byteshuffle_filter");return r}function Lw(e,t){const r={blockSize:0};let n;for(;n=e.nextField(t);)1===n&&(r.blockSize=e.readVarint());return r}function Ow(e,t){const r={};let n;for(;n=e.nextField(t);)1===n?(e.readVarint(),r.codec="gzip_data"):2===n?(e.readVarint(),r.codec="jpeg_image"):3===n?(e.readVarint(),r.codec="webp_image"):4===n&&(e.readVarint(),r.codec="png_image");return r}function Uw(e,t){const r={firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]};let n,i=0,s=0;for(;n=e.nextField(t);)1===n?r.firstByte=e.readFixed64():2===n?r.lastByte=e.readFixed64():3===n?r.filters.push(Rw(e,e.readVarint()+e.pos)):4===n?r.codec=Ow(e,e.readVarint()+e.pos):5===n?s=e.readFloat():6===n?i=e.readFloat():7===n?r.bands.push(e.readString()):8===n?r.offset=e.readDouble():9===n&&(r.scale=e.readDouble());return 0===r.offset&&(r.offset=s),0===r.scale&&(r.scale=i),r}function Nw(e,t){const r={version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]};let n;for(;n=e.nextField(t);)1===n?r.version=e.readVarint():2===n?r.name=e.readString():3===n?r.units=e.readString():4===n?r.tileSize=e.readVarint():5===n?r.buffer=e.readVarint():6===n?r.pixelFormat=e.readVarint():7===n&&r.dataIndex.push(Uw(e,e.readVarint()+e.pos));return r}function jw(e,t,r){let n;for(;n=e.nextField(t);)if(1===n){let t=0;const n=e.readVarint()+e.pos;for(;e.pos=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n>>1^-(1&e[t]);return e}function Hw(e,t){switch(t){case "uint32":return e;case "uint16":for(let t=0;t>4|(61440&r)>>8|(240&n)<<4|61440&n,e[t+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return e;case "uint8":for(let t=0;t>6|(192&n)>>4|(192&i)>>2|192&s,e[t+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,e[t+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,e[t+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}Zs(kw,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var qw=Uint8Array,Xw=Uint16Array,Zw=Int32Array,Ww=new qw([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Yw=new qw([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Kw=new qw([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Jw=function(e,t){for(var r=new Xw(31),n=0;n<31;++n)r[n]=t+=1<>1|(21845&i_)<<1;n_[i_]=((65280&(s_=(61680&(s_=(52428&s_)>>2|(13107&s_)<<2))>>4|(3855&s_)<<4))>>8|(255&s_)<<8)>>1;}var a_=function(e,t,r){for(var n=e.length,i=0,s=new Xw(t);i>l]=u;return a},o_=new qw(288);for(i_=0;i_<144;++i_)o_[i_]=8;for(i_=144;i_<256;++i_)o_[i_]=9;for(i_=256;i_<280;++i_)o_[i_]=7;for(i_=280;i_<288;++i_)o_[i_]=8;var l_=new qw(32);for(i_=0;i_<32;++i_)l_[i_]=5;var u_=a_(o_,9),c_=a_(l_,5),h_=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},d_=function(e,t,r){var n=t/8|0;return (e[n]|e[n+1]<<8)>>(7&t)&r},p_=function(e,t){var r=t/8|0;return (e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},f_=function(e){return (e+7)/8|0},m_=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],y_=function(e,t,r){var n=new Error(t||m_[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,y_),!r)throw n;return n},g_=new qw(0);var x_="undefined"!=typeof TextDecoder&&new TextDecoder;try{x_.decode(g_,{stream:!0});}catch(e){}const v_={gzip_data:"gzip"};class b_ extends Error{constructor(e){super(e),this.name="MRTError";}}const w_={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},__={uint32:1,uint16:2,uint8:4},A_={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let M_;class I_{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e;}getLayer(e){const t=this.layers[e];if(!t)throw new b_(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new b_("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length= ${r} but got buffer of length ${t.length}`);const n=function(e){const t={headerLength:0,x:0,y:0,z:0,layers:[]};let r;for(;r=e.nextField(void 0);)1===r?t.headerLength=e.readFixed32():2===r?t.x=e.readVarint():3===r?t.y=e.readVarint():4===r?t.z=e.readVarint():5===r&&t.layers.push(Nw(e,e.readVarint()+e.pos));return t}(new M_(t.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new b_(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new S_(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let n of e.blockIndices){const i=r.dataIndex[n],s=i.firstByte-e.firstByte,a=i.lastByte-e.firstByte;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:s,lastByte:a,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map(e=>e.filter)};r._blocksInProgress.add(n),t.push(o);}return new B_(t,()=>{t.forEach(e=>r._blocksInProgress.delete(e.blockIndex));},(e,n)=>{if(t.forEach(e=>r._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e);});})}}class S_{constructor({version:e,name:t,units:r,tileSize:n,pixelFormat:i,buffer:s,dataIndex:a},o){if(this.version=e,1!==this.version)throw new b_(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=w_[i],this.dataIndex=a,this.bandShape=[n+2*s,n+2*s,__[this.pixelFormat]],this._decodedBlocks=new Ew(o?o.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return __[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data);}getBlockForBand(e){let t=0;switch(typeof e){case "string":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===e)return {bandIndex:t+i,blockIndex:r,blockBandIndex:i};t+=n.bands.length;}break;case "number":for(const[r,n]of this.dataIndex.entries()){if(e>=t&&ethis.cacheSize)throw new b_(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:t,lastByte:r,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:r}=this.getBlockForBand(e);if(t<0)throw new b_(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new b_(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[t],s=this.bandShape.reduce((e,t)=>e*t,1),a=r*s,o=n.subarray(a,a+s);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:i.offset,scale:i.scale}}}I_.setPbf=function(e){M_=e;};class B_{constructor(e,t,r){this.tasks=e,this._onCancel=t,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0);}}function E_(e,t,r){try{t=function(e){if(!e.variants)return e;if(!Array.isArray(e.variants))throw new Error("variants must be an array");for(const t of e.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(t.capabilities))throw new Error("capabilities must be an array");if(1===t.capabilities.length&&"meshopt"===t.capabilities[0])return Object.assign(e,t)}return e}(t);}catch(e){return new Error("Failed to process TileJSON variants",{cause:e})}const n=Ze({...t,...e},["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return e.url&&t.tiles&&e.tiles&&(n.tiles=t.tiles),n.tiles=r.canonicalizeTileset(n,e.url),n}I_.performDecoding=function(e,t){const r=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:i,pixelFormat:s,blockShape:a,blockIndex:o,filters:l,codec:u}=e,c=r.subarray(n,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let d;if("gzip_data"!==u)throw new b_(`Unhandled codec: ${u}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve((a=function(e){31==e[0]&&139==e[1]&&8==e[2]||y_(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)}(r=e),a+8>r.length&&y_(6,"invalid gzip data"),function(e,t,r,n){var i=e.length;if(!i||t.f&&!t.l)return r||new qw(0);var s=!r,a=s||2!=t.i,o=t.i;s&&(r=new qw(3*i));var l=function(e){var t=r.length;if(e>t){var n=new qw(Math.max(2*t,e));n.set(r),r=n;}},u=t.f||0,c=t.p||0,h=t.b||0,d=t.l,p=t.d,f=t.m,m=t.n,y=8*i;do{if(!d){u=d_(e,c,1);var g=d_(e,c+1,3);if(c+=3,!g){var x=e[(P=f_(c)+4)-4]|e[P-3]<<8,v=P+x;if(v>i){o&&y_(0);break}a&&l(h+x),r.set(e.subarray(P,v),h),t.b=h+=x,t.p=c=8*v,t.f=u;continue}if(1==g)d=u_,p=c_,f=9,m=5;else if(2==g){var b=d_(e,c,31)+257,w=d_(e,c+10,15)+4,_=b+d_(e,c+5,31)+1;c+=14;for(var A=new qw(_),M=new qw(19),I=0;I>4)<16)A[I++]=P;else {var T=0,V=0;for(16==P?(V=3+d_(e,c,3),c+=2,T=A[I-1]):17==P?(V=3+d_(e,c,7),c+=3):18==P&&(V=11+d_(e,c,127),c+=7);V--;)A[I++]=T;}}var F=A.subarray(0,b),k=A.subarray(b);f=h_(F),m=h_(k),d=a_(F,f),p=a_(k,m);}else y_(1);if(c>y){o&&y_(0);break}}a&&l(h+131072);for(var C=(1<>4;if((c+=15&T)>y){o&&y_(0);break}if(T||y_(2),L<256)r[h++]=L;else {if(256==L){R=c,d=null;break}var O=L-254;L>264&&(O=d_(e,c,(1<<(j=Ww[I=L-257]))-1)+e_[I],c+=j);var U=p[p_(e,c)&D],N=U>>4;if(U||y_(3),c+=15&U,k=r_[N],N>3){var j=Yw[N];k+=p_(e,c)&(1<y){o&&y_(0);break}a&&l(h+131072);var G=h+O;if(he.length)&&(r=e.length),new qw(e.subarray(0,r))}(r,0,h):r.subarray(0,h)}(r.subarray(a,-8),{i:2},new qw(((i=r)[(s=i.length)-4]|i[s-3]<<8|i[s-2]<<16|i[s-1]<<24)>>>0),n)));var r,n,i,s,a;const o=v_[t];if(!o)throw new Error(`Unhandled codec: ${t}`);const l=new globalThis.DecompressionStream(o);return new Response(new Blob([e]).stream().pipeThrough(l)).arrayBuffer().then(e=>new Uint8Array(e))}(c,u).then(e=>(function(e,t){let r;for(;r=e.nextField();)if(2===r)jw(e,e.readVarint()+e.pos,t);else if(3===r)throw new Error("Not implemented")}(new M_(e),h),new(0,A_[s])(h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case "delta_filter":Gw(e,a);break;case "zigzag_filter":$w(e);break;case "bitshuffle_filter":Hw(e,s);break;default:throw new b_(`Unhandled filter "${l[t]}"`)}return {layerName:t,blockIndex:o,data:e}}).catch(e=>{throw e})}))},Zs(B_,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Zs(I_,"MapboxRasterTile"),Zs(S_,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const P_=new Map,z_=new Map;class T_{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(e,t){const r=this.toIdx(e,t);return {min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function V_(e,t,r,n){let i=0,s=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(n[a])<1e-15){if(r[a]t[a])return null}else {const o=1/n[a];let l=(e[a]-r[a])*o,u=(t[a]-r[a])*o;if(l>u){const e=l;l=u,u=e;}if(l>i&&(i=l),us)return null}return i}function F_(e,t,r,n,i,s,a,o,l,u,c){const h=n-e,d=i-t,p=s-r,f=a-e,m=o-t,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*f-c[0]*y,v=c[0]*m-c[1]*f,b=h*g+d*x+p*v;if(Math.abs(b)<1e-15)return null;const w=1/b,_=u[0]-e,A=u[1]-t,M=u[2]-r,I=(_*g+A*x+M*v)*w;if(I<0||I>1)return null;const S=A*p-M*d,B=M*h-_*p,E=_*d-A*h,P=(c[0]*S+c[1]*B+c[2]*E)*w;return P<0||I+P>1?null:(f*S+m*B+y*E)*w}function k_(e,t,r,n,i,s,a,o,l){const u=1<{const s=n?1:0,a=(e+1)*r-s,o=t*r,l=(t+1)*r-s;i[0]=e*r,i[1]=o,i[2]=a,i[3]=l;};let a=new T_(i);const o=1/i,{floatView:l,stride:u}=e,c=[];for(let r=0;rw&&(w=r);}}a.minimums.push(y),a.maximums.push(w),a.leaves.push(1);}for(n.push(a),i/=2;i>=1;i/=2){const e=n.at(-1);a=new T_(i);for(let t=0;t0;){const{idx:o,t:p,nodex:f,nodey:m,depth:y}=d.pop();if(this.leaves[o]){k_(f,m,y,e,t,r,n,c,h);const o=1<1e-10,C=Math.abs(s[1])>1e-10,D=s[0]>=0?1:-1,R=s[1]>=0?1:-1;let L=Math.max(0,Math.min(M-1,Math.floor((T-S)/E))),O=Math.max(0,Math.min(I-1,Math.floor((V-B)/P)));const U=F?Math.abs(E/s[0]):Number.MAX_VALUE,N=C?Math.abs(P/s[1]):Number.MAX_VALUE;let j=F?z+(S+(s[0]>=0?L+1:L)*E-T)/s[0]:Number.MAX_VALUE,G=C?z+(B+(s[1]>=0?O+1:O)*P-V)/s[1]:Number.MAX_VALUE;const $=(e,t)=>v[(t+1)*b+e+1]*a;let H=$(w+L,A+O),q=$(w+L+1,A+O),X=$(w+L,A+O+1),Z=$(w+L+1,A+O+1),W=null;for(let e=0;e=0||i[2]+s[2]*e<=Math.max(H,q,X,Z)){const e=S+L*E,t=e+E,r=B+O*P,n=r+P,a=F_(t,r,q,e,r,H,e,n,X,i,s),o=F_(e,n,X,t,n,Z,t,r,q,i,s);null!=a&&a>=0&&(null===W||a=0&&(null===W||o=M||O<0||O>=I)break;if(null!==W&&e>W)break;t?D>0?(H=q,X=Z,q=$(w+L+1,A+O),Z=$(w+L+1,A+O+1)):(q=H,Z=X,H=$(w+L,A+O),X=$(w+L,A+O+1)):R>0?(H=X,q=Z,X=$(w+L,A+O+1),Z=$(w+L+1,A+O+1)):(X=H,Z=q,H=$(w+L,A+O),q=$(w+L+1,A+O));}if(null!==W)return W||0;const Y=k([],i,s,p),K=(Y[0]-c[0])/(h[0]-c[0]),J=(Y[1]-c[1])/(h[1]-c[1]),Q=R_(l,d,this.dem)*a,ee=R_(u,d,this.dem)*a,te=R_(u,g,this.dem)*a;if(D_(Q,ee,R_(l,g,this.dem)*a,te,K,J)>=Y[2])return p;continue}let g=0;for(let d=0;d=l[u[r]]&&(u.splice(r,0,d),t=!0);t||(u[g]=d),g++;}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (t+1)*this.stride+(e+1)}static pack(e,t){const r=[0,0,0,0],n=N_.getUnpackVector(t);let i=Math.floor((e+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new mh({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,i=t*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(t){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=a-1;break;case 1:a=s+1;}const o=-t*this.dim,l=-r*this.dim;for(let t=s;t>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=j_[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new $_(a,s,i,void 0,e)}constructor(e,t=64,r=Float64Array,n=ArrayBuffer,i){if(isNaN(e)||e<0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const s=j_.indexOf(this.ArrayType),a=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-o%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${r}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new r(i,8+o+l,2*e),this._pos=2*e,this._finished=!0;else {const i=this.data=new n(8+a+o+l);this.ids=new this.IndexArrayType(i,8,e),this.coords=new r(i,8+o+l,2*e),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+s]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e;}}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return H_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this;G_[0]=0,G_[1]=i.length-1,G_[2]=0;let o=3;const l=[];for(;o>0;){const u=G_[--o],c=G_[--o],h=G_[--o];if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=e&&o<=r&&u>=t&&u<=n&&l.push(i[a]);}continue}const d=h+c>>1,p=s[2*d],f=s[2*d+1];p>=e&&p<=r&&f>=t&&f<=n&&l.push(i[d]),(0===u?e<=p:t<=f)&&(G_[o++]=h,G_[o++]=d-1,G_[o++]=1-u),(0===u?r>=p:n>=f)&&(G_[o++]=d+1,G_[o++]=c,G_[o++]=1-u);}return l}within(e,t,r){const n=[];return this.withinInto(e,t,r,n),n}withinInto(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:a}=this;G_[0]=0,G_[1]=i.length-1,G_[2]=0;let o=3,l=0;const u=r*r;for(;o>0;){const c=G_[--o],h=G_[--o],d=G_[--o];if(h-d<=a){for(let r=d;r<=h;r++)W_(s[2*r],s[2*r+1],e,t)<=u&&(n[l++]=i[r]);continue}const p=d+h>>1,f=s[2*p],m=s[2*p+1];W_(f,m,e,t)<=u&&(n[l++]=i[p]),(0===c?e-r<=f:t-r<=m)&&(G_[o++]=d,G_[o++]=p-1,G_[o++]=1-c),(0===c?e+r>=f:t+r>=m)&&(G_[o++]=p+1,G_[o++]=h,G_[o++]=1-c);}return l}}function H_(e,t,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;q_(e,t,a,n,i,s),H_(e,t,r,n,a-1,1-s),H_(e,t,r,a+1,i,1-s);}function q_(e,t,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);q_(e,t,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=t[2*r+s];let o=n,l=i;for(X_(e,t,n,r),t[2*i+s]>a&&X_(e,t,n,i);oa;)l--;}t[2*n+s]===a?X_(e,t,n,l):(l++,X_(e,t,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function X_(e,t,r,n){Z_(e,r,n),Z_(t,2*r,2*n),Z_(t,2*r+1,2*n+1);}function Z_(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function W_(e,t,r,n){const i=e-r,s=t-n;return i*i+s*s}t.$=an,t.A=sr,t.B=ir,t.C=mr,t.D=Gr,t.E=lr,t.F=2,t.G=rp,t.H=Xd,t.I=ur,t.J=rn,t.K=lo,t.L=Ew,t.M=tn,t.N=sn,t.O=Ps,t.P=be,t.Q=Ss,t.R=$t,t.S=Es,t.T=tp,t.U=Os,t.V=uo,t.W=Gs,t.X=fi,t.Y=hi,t.Z=di,t._=hn,t.a=function(e){return wt.API_CDN_URL_REGEX.test(e)},t.a$=mn,t.a0=nn,t.a1=co,t.a2=/^(.*)-use-theme$/,t.a3=/^(.*)-transition$/,t.a4=zs,t.a5=Bs,t.a6=Ka,t.a7=ao,t.a8=no,t.a9=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return st(e.expression.evaluate(t))}interpolate(e,t,r){return {x:pr(e.x,t.x,r),y:pr(e.y,t.y,r),z:pr(e.z,t.z,r),azimuthal:pr(e.azimuthal,t.azimuthal,r),polar:pr(e.polar,t.polar,r)}}},t.aA=function(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*o,e[1]=i*l-n*o,e[2]=s*l+a*o,e[3]=a*l-s*o,e},t.aB=re,t.aC=u,t.aD=lt,t.aE=c,t.aF=x,t.aG=d,t.aH=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},t.aI=w,t.aJ=function(e,t,r,n,i){var s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var a=1/(n-i);e[10]=(i+n)*a,e[14]=2*i*n*a;}else e[10]=-1,e[14]=-2*n;return e},t.aK=function(e,t,r,n,i,s,a){var o=1/(t-r),l=1/(n-i),u=1/(s-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(i+n)*l,e[14]=(a+s)*u,e[15]=1,e},t.aL=Al,t.aM=gn,t.aN=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3];},t.aO=Q,t.aP=h,t.aQ=l,t.aR=y,t.aS=o,t.aT=function(e,t){const{x:r,y:n}=e.point,i=Lf(r,n,e.worldSize/e._pixelsPerMercatorPixel,0,0);return h(i,i,Cf(If(t)))},t.aU=i,t.aV=H,t.aW=X,t.aX=C,t.aY=k,t.aZ=Ld,t.a_=fn,t.aa=Za,t.ab=js,t.ac=zl,t.ad=G,t.ae=I,t.af=He,t.ag=ro,t.ah=Of,t.ai=pr,t.aj=Tn,t.ak=vr,t.al=Oe,t.am=function(){return We++},t.an=class{constructor(e,t,r){this.target=e,this.parent=t,this.mapId=r,this.pendingResponses=new Map,Ke(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new Tw;}send(e,t,r){const{signal:n,targetMapId:i,metadata:s}=r||{},a=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=new Set;return n&&n.aborted?Promise.reject(n.reason):(this.target.postMessage({id:a,type:e,targetMapId:i,sourceMapId:this.mapId,data:Js(t,o)},[...o]),new Promise((e,t)=>{const r={resolve:e,reject:t,metadata:s||Vw};if(n){const e=()=>{this.pendingResponses.delete(a),t(n.reason);};n.addEventListener("abort",e,{once:!0}),r.detach=()=>n.removeEventListener("abort",e);}this.pendingResponses.set(a,r);}))}notify(e,t,r){const{targetMapId:n}=r||{},i=new Set;this.target.postMessage({type:e,targetMapId:n,sourceMapId:this.mapId,data:Js(t,i)},[...i]);}sendCancelable(e,t,r,n){const i=new AbortController;return this.send(e,t,{...r,signal:i.signal}).then(e=>n(null,e)).catch(e=>{"AbortError"!==e.name&&n(e);}),i}getWorkerSourceActor(e){return {scheduler:this.scheduler,send:(t,r,n)=>this.send(t,r,{...n,targetMapId:e}),notify:(t,r)=>{this.notify(t,r,{targetMapId:e});},sendCancelable:(t,r,n,i)=>this.sendCancelable(t,r,{...n,targetMapId:e},i)}}receive(e){const t=e.data;if(!t)return;const r=t.id;if(!t.targetMapId||this.mapId===t.targetMapId)if(at(self)){const e=this.pendingResponses.get(r);this.scheduler.add(()=>{this.processTask(r,t);},e&&e.metadata||Vw);}else this.processTask(r,t);}async processTask(e,t){if(""===t.type){const r=this.pendingResponses.get(e);if(this.pendingResponses.delete(e),r){r.detach&&r.detach();try{t.error?r.reject(Qs(t.error)):r.resolve(Qs(t.data));}catch(e){r.reject(e);}}return}const r=new Set,n=Qs(t.data);try{let i;if(this.parent[t.type])i=await this.parent[t.type](t.sourceMapId,n);else {if(!this.parent.getWorkerSource)throw new Error(`Could not find function ${t.type}`);{const e=t.type.split("."),{source:r,scope:s}=n,a=this.parent.getWorkerSource(t.sourceMapId,{type:e[0],source:r,scope:s,uid:0});i=await a[e[1]](n);}}if(!e)return;this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:null,data:Js(i,r)},[...r]);}catch(t){this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:Js(t),data:null},[]);}}remove(){for(const e of this.pendingResponses.values())e.detach&&e.detach(),e.reject(new DOMException("Actor removed","AbortError"));this.pendingResponses.clear(),this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}},t.ao=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const r=st([1,e,t]);return {x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,r){return {x:pr(e.x,t.x,r),y:pr(e.y,t.y,r),z:pr(e.z,t.z,r)}}},t.ap=uc,t.aq=sc,t.ar=nc,t.as=$e,t.at=qe,t.au=O,t.av=F,t.aw=U,t.ax=N,t.ay=W,t.az=te,t.b=function(e){return wt.API_FONTS_REGEX.test(e)},t.b$=ic,t.b0=yd,t.b1=Rd,t.b2=function(e,t,r,n,i){const s=5*t+2;e.float32[s+0]=r,e.float32[s+1]=n,e.float32[s+2]=i;},t.b3=Lm,t.b4=bl,t.b5=Ze,t.b6=xm,t.b7=we,t.b8=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},t.b9=q,t.bA=Il,t.bB=K,t.bC=hf,t.bD=6,t.bE=function(e){const t=u(new Float64Array(16));h(t,e.pixelMatrix,e.globeMatrix);const r=[0,fl,0],n=[0,ml,0];return G(r,r,t),G(n,n,t),[r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Nf(e,new bl(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Nf(e,new bl(e.center.lat,-90))]},t.bF=wl,t.bG=function(e,t){const{scale:r}=e.tileTransform,n=r*Tn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z)),i=t.inverseAdjustmentMatrix;return new Float32Array([i[0]*n,i[1]*n,i[2]*n,i[3]*n])},t.bH=Hg,t.bI=_,t.bJ=Gg,t.bK=function(e){const t=Gg(e,!0);return i([],[t[0],t[1],t[4],t[5]])},t.bL=p,t.bM=df,t.bN=f,t.bO=function(e,t){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.bP=function(e){const{x:t,y:r}=e.point,{lng:n,lat:i}=e._center;return Lf(t,r,e.worldSize,n,i)},t.bQ=z,t.bR=g,t.bS=Ue,t.bT=eh,t.bU=5,t.bV=function(e,t,r){let n=0;for(let r=0;r<2;++r){const i=0;e[r]>i&&(n+=(e[r]-i)*(e[r]-i)),t[r]0?Math.acos(r/n)*Re:0;let s=0!==e||0!==t?Math.atan2(-t,-e)*Re+90:0;return s<0&&(s+=360),[n,s,i]},t.c6=S,t.c7=function(e){return [Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},t.c8=st,t.c9=lc,t.cA=P,t.cB=mv,t.cC=Mv,t.cD=$r,t.cE=ev,t.cF=450,t.cG=7,t.cH=4,t.cI=2,t.cJ=Nc,t.cK=Gc,t.cL=Ke,t.cM=class{static calculate(e,t,r){const n=new Set,i=new Map,s=new Set,a=new Set;for(const r of Object.values(e))for(const[e,o]of Object.entries(r.floors)){s.add(e),o.isDefault&&a.add(e),o.conflicts&&i.set(e,o.conflicts);const r=e===t,l=o.connections&&t&&o.connections.has(t);(r||l)&&n.add(e);}const o=e=>{const t=i.get(e)||new Set;for(const r of n)if((i.get(r)||new Set).has(e)||t.has(r))return !0;return !1};if(r)for(const e of r)s.has(e)&&(o(e)||n.add(e));for(const e of a)n.has(e)||o(e)||n.add(e);return n}},t.cN=class extends tc{constructor(e){super(e),this.current=new Float32Array(9);}set(e,t,r){if(!this.fetchUniformLocation(e,t))return;const n=this.current;for(let e=0;e<9;e++)if(r[e]!==n[e]){n.set(r),this.gl.uniformMatrix3fv(this.location,!1,n);break}}},t.cO=Kf,t.cP=yn,t.cQ=Zl,t.cR=$l,t.cS=zu,t.cT=Gm,t.cU=function(){Xa.isLoading()||Xa.isLoaded()||"deferred"!==Ha()||qa();},t.cV=ho,t.cW=Ol,t.cX=Aw,t.cY=ot,t.cZ=_h,t.c_=Sc,t.ca=vf,t.cb=L,t.cc=Bl,t.cd=ee,t.ce=b,t.cf=function(e,t){var r=new n(3);b(r,t);var i=1/r[0],s=1/r[1],a=1/r[2],o=t[0]*i,l=t[1]*s,u=t[2]*a,c=t[4]*i,h=t[5]*s,d=t[6]*a,p=t[8]*i,f=t[9]*s,m=t[10]*a,y=o+h+m,g=0;return y>0?(g=2*Math.sqrt(y+1),e[3]=.25*g,e[0]=(d-f)/g,e[1]=(p-u)/g,e[2]=(l-c)/g):o>h&&o>m?(g=2*Math.sqrt(1+o-h-m),e[3]=(d-f)/g,e[0]=.25*g,e[1]=(l+c)/g,e[2]=(p+u)/g):h>m?(g=2*Math.sqrt(1+h-o-m),e[3]=(p-u)/g,e[0]=(l+c)/g,e[1]=.25*g,e[2]=(d+f)/g):(g=2*Math.sqrt(1+m-o-h),e[3]=(l-c)/g,e[0]=(p+u)/g,e[1]=(d+f)/g,e[2]=.25*g),e},t.cg=function(e,t){var n=2*Math.acos(t[3]),i=Math.sin(n/2);return i>r?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=1,e[1]=0,e[2]=0),n},t.ch=Iw,t.ci=rx,t.cj=Jg,t.ck=tx,t.cl=function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],s=t[6],a=t[7],o=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=i,e[13]=a,e[14]=o;}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},t.cm=Tm,t.cn=Pl,t.co=ql,t.cp=fu,t.cq=uf,t.cr=qu,t.cs=ow,t.ct=class{constructor(e,t,r,n){this.context=e,this.format=n,this.size=r,this.texture=e.gl.createTexture();const[i,s,a]=this.size,{gl:o}=e;o.bindTexture(o.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&o.texImage3D(o.TEXTURE_3D,0,this.format,i,s,a,0,Qd(this.format),ep(this.format),t.data);}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}},t.cu=[1,1,1],t.cv=function(e,t,r,i){var s=new n(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s},t.cw=Y,t.cx=function(e,t,r,n){var i=t[0],s=t[1],a=t[2],o=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e[3]=o+n*(r[3]-o),e},t.cy=function(e){return e>>>=0,e=Math.imul(2747636419^e,2654435769)>>>0,e=Math.imul(e^e>>>16,2654435769)>>>0,(e=Math.imul(e^e>>>16,2654435769)>>>0)/4294967296},t.cz=E,t.d=function(e){return wt.API_TILEJSON_REGEX.test(e)},t.d$=Bd,t.d0=Mu,t.d1=Do,t.d2=function(e,t){const r=Of(t.zoom);if(0===r)return If(e);const n=Pf(e),i=zf(n),s=fn(n.getWest())*t.worldSize,a=fn(n.getEast())*t.worldSize,o=mn(n.getNorth())*t.worldSize,l=mn(n.getSouth())*t.worldSize,u=[s,o,0],h=[a,o,0],d=[s,l,0],p=[a,l,0],f=c([],t.globeMatrix);return G(u,u,f),G(h,h,f),G(d,d,f),G(p,p,f),i[0]=Sf(i[0],d,r),i[1]=Sf(i[1],p,r),i[2]=Sf(i[2],h,r),i[3]=Sf(i[3],u,r),vf.fromPoints(i)},t.d3=kf,t.d4=Tf,t.d5=Sf,t.d6=Xl,t.d7=lf,t.d8=I_,t.d9=rd,t.dA=zw,t.dB=Xe,t.dC="hd_road_coverage",t.dD=function(e){const t=e.indexOf(Mo);return t>=0?e.slice(0,t):e},t.dE=So,t.dF=function(e,t,r=0,n=!0){const i=new be(r,r),s=e.sub(i),a=t.add(i),o=[s,new be(a.x,s.y),a,new be(s.x,a.y)];return n&&o.push(s.clone()),o},t.dG=function(e,t){const r=[];for(let n=0;n{n(e,r);},t):n(e,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r((r,n)=>{i.result=[r,n];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(r,n);},t):e(r,n);setTimeout(()=>delete this.entries[e],3e3);})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==n),i.callbacks.length||(i.cancel(),delete this.entries[e]));}}},t.dO=function(e,t,r){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom},t=>{const n=new AbortController;return Qt(e.request,n.signal).then(({data:e,headers:n})=>{t(null,{rawData:e,vectorTile:r?void 0:new Uc(new rd(e)),headers:n});}).catch(e=>{n.signal.aborted||(qt(e)?t(null,null):t(e));}),()=>{n.abort(),t(null,null);}},t)},t.dP=class{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}},t.dQ=function(e,t,r,n){for(;t>1;e[i]<=n?t=i+1:r=i;}return t},t.dR=function(e,t,r,n){for(;t>1;e[i]{t.onloadstart=()=>r(),t.onerror=()=>n(new Error(`Could not load video: ${e.join(", ")}`));}),t},t.dW=Mw,t.dX=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.dY=wm,t.dZ=Hx,t.d_=zm,t.da=Qt,t.db=function(e){if("provider"in e&&!e.provider)return null;let t=e.provider;if(!t&&"url"in e&&e.url&&(t=function(e){try{const t=new URL(e).pathname.split("/").pop()||"",r=t.lastIndexOf(".");return r>=0?t.slice(r+1):""}catch{return ""}}(e.url)),!t)return null;const r=wt.TILE_PROVIDER_URLS[t];if(!r)return null;let n;try{n=new URL(r,wt.API_URL).href;}catch(e){return new Error(`TileProvider "${t}" has an invalid URL: "${r}"`)}return {name:t,url:n}},t.dc=function(e,t,r,n,i){const s=function(r,n){if(r)return i(r);if(n){e.url&&n.tiles&&e.tiles&&delete e.tiles;const r=E_(e,n,t);if(r instanceof Error)return i(r);i(null,r);}},a=function(e,t,r){if(!e)return null;if(!t&&!r)return e;r=r||e.worldview_default;const n=Object.values(e.language||{});if(0===n.length)return null;const i=Object.values(e.worldview||{});if(0===i.length)return null;const s=n.every(e=>e===t),a=i.every(e=>e===r);return s&&a?e:t in(e.language_options||{})||r in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(e.data,r,n);if(a)return vt.frame(()=>s(null,a));if(e.url){const i=new AbortController;return (async()=>{const a=await t.transformRequest(t.normalizeSourceURL(e.url,null,r,n),$t.Source,i.signal),{data:o}=await Jt(a,i.signal);s(null,o);})().catch(e=>{i.signal.aborted||s(e);}),{cancel:()=>i.abort()}}return vt.frame(()=>{const{data:t,...r}=e;s(null,r);})},t.dd=function(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}},t.de=function(e){Nt++,Nt>Dt&&(e.getActor().notify("enforceCacheSizeLimit",Ct),Nt=0);},t.df=async function(e,t,r){const n=e.url&&!e.tiles?await t.transformRequest(e.url,$t.Source,r):void 0;return {request:n,options:n?{...e,url:n.url}:e}},t.dg=async function(e,t){const r=z_.get(e);if(r)return r;const n=P_.get(e);if(void 0!==n)return n;const i=self.__mapboxImport( /* webpackIgnore: true */ /* @vite-ignore */ -t).catch(t=>{throw new Error(`TileProvider "${e}" failed to load: ${t instanceof Error?t.message:String(t)}`)}).then(t=>{const r=t.default;if("function"!=typeof r)throw new Error(`TileProvider "${e}" module must default-export a class`);if("function"!=typeof r.prototype.loadTile)throw new Error(`TileProvider "${e}" class must have a loadTile method`);return $_.set(e,r),r}).finally(()=>{G_.delete(e);});return G_.set(e,i),i},t.e9=function(e,t,r){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom},t=>{const n=ar(e.request,(e,n,i)=>{e?er(e)?t(null,null):t(e):n&&t(null,{rawData:n,vectorTile:r?void 0:new qc(new ad(n)),responseHeaders:new Map(i.entries())});});return ()=>{n.cancel(),t(null,null);}},t)},t.eA=Bt,t.eB=function(e,t,r,n,i,s,a){var o=1/(t-r),l=1/(n-i),u=1/(s-a);return e[0]=-2*o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*o,e[13]=(i+n)*l,e[14]=(a+s)*u,e[15]=1,e},t.eC=function(e,t){const r=e.url&&!e.tiles?t.transformRequest(e.url,Jt.Source):void 0;return {request:r,options:r?Object.assign({},e,{url:r.url}):e}},t.eD=function(e,t,r,n,i,s,a,o=1,l,u,c,h,d,p,f,m,y){e.createArrays(),e.tilePixelRatio=Xn/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const g=e.layers[0].layout,x=e.layers[0]._unevaluatedLayout._values,b={};b.scaleFactor=o,b.textSizeScaleRange=g.get("text-size-scale-range"),b.iconSizeScaleRange=g.get("icon-size-scale-range");const[v,w]=b.textSizeScaleRange,[_,A]=b.iconSizeScaleRange;b.textScaleFactor=Ze(b.scaleFactor,v,w),b.iconScaleFactor=Ze(b.scaleFactor,_,A);const I=x["text-size"],M=x["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.textSizeData;b.compositeTextSizes=[I.possiblyEvaluate(new Qa(t,{worldview:c}),s),I.possiblyEvaluate(new Qa(r,{worldview:c}),s)];}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.iconSizeData;b.compositeIconSizes=[M.possiblyEvaluate(new Qa(t,{worldview:c}),s,h),M.possiblyEvaluate(new Qa(r,{worldview:c}),s,h)];}b.layoutTextSize=I.possiblyEvaluate(new Qa(a+1,{worldview:c}),s),b.layoutIconSize=M.possiblyEvaluate(new Qa(a+1,{worldview:c}),s,h),b.textMaxSize=I.possiblyEvaluate(new Qa(18,{worldview:c}),s);const S=g.get("symbol-placement"),B="map"===g.get("text-rotation-alignment")&&"point"!==S,T=g.get("text-size");let P=!1;const z=[],E=null!=d&&0!==d;for(const a of e.features){if(E&&a.properties&&m&&m(a.properties,d))continue;const o=g.get("text-font").evaluate(a,{},s).join(","),p=T.evaluate(a,{},s)*b.textScaleFactor,f=b.layoutTextSize.evaluate(a,{},s)*b.textScaleFactor,y=b.layoutIconSize.evaluate(a,{},s,h)*b.iconScaleFactor,v={horizontal:{},vertical:void 0},w=a.text;let _,A=[0,0];if(w){const n=w.toString(),u=g.get("text-letter-spacing").evaluate(a,{},s)*Jh,c=g.get("text-line-height").evaluate(a,{},s)*Jh,h=ka(n)?u:0,d=g.get("text-anchor").evaluate(a,{},s),m=g.get("text-variable-anchor");if(!m){const e=g.get("text-radial-offset").evaluate(a,{},s);if(e)A=Op(d,[e*Jh,Cp]);else {const e=g.get("text-offset").evaluate(a,{},s);A=[e[0]*Jh,e[1]*Jh];}}let y=B?"center":g.get("text-justify").evaluate(a,{},s);const x="point"===S,_=x?g.get("text-max-width").evaluate(a,{},s)*Jh:1/0,I=s=>{e.allowVerticalPlacement&&Ea(n)&&(v.vertical=Ad(w,t,r,i,o,_,c,d,s,h,A,vd.vertical,!0,f,p,l,b.textScaleFactor));};if(!B&&m){const e="auto"===y?m.map(e=>Jp(e)):[y];let n=!1;for(let s=0;s0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Xf(e,new Ml(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Xf(e,new Ml(e.center.lat,-90))]},t.eL=nh,t.eM=ih,t.eN=Zc,t.eO=Hc,t.eP=function(e,t,r=0,n=!0){const i=new _e(r,r),s=e.sub(i),a=t.add(i),o=[s,new _e(a.x,s.y),a,new _e(s.x,a.y)];return n&&o.push(s.clone()),o},t.eQ=ff,t.eR=function(e,t){return ir(Object.assign(e,{method:"POST"}),t)},t.eS=function(e,t,r,n,i,s,a,o,l,u){e.iconAtlasPositions=u.iconPositions;const{featureData:c,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f,coveragePolygons:m,coverageTileZoom:y,symbolAnchorInFrcCoverage:g}=t;for(const t of c){const{shapedIcon:r,verticallyShapedIcon:s,feature:c,shapedTextOrientations:x,shapedText:b,layoutTextSize:v,textOffset:w,isSDFIcon:_,iconPrimary:A,iconSecondary:I,iconTextFit:M,iconOffset:S,iconCollisionBounds:B,iconVerticalCollisionBounds:T,textCollisionBounds:P}=t;Wp(r,u.iconPositions,A,I),Wp(s,u.iconPositions,A,I),Yp(x,u.iconPositions),Zp(A,I,u.iconPositions),(b||r)&&tf(e,c,x,r,s,l,d,v,0,w,_,n,i,a,o,h,M,S,p,f,B,T,P,0,0,m,y,g);}r&&e.generateCollisionDebugBuffers(s,e.collisionBoxArray,d.textScaleFactor),e.text.uboBinder&&e.text.uboBinder.finalize(),e.icon.uboBinder&&e.icon.uboBinder.finalize();},t.eT=Kd,t.eU=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},t.eV=function(e,t){const r=e.json.extensionsUsed&&e.json.extensionsUsed.includes("mbx_bvh"),n=Ix(e);for(const e of n){if(!r)for(const t of e.meshes)Mx(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(Bx(e.lights,t)));}return n},t.eW=function(e,t,r){return t?j_(e,t,r):e.tiles&&e.tiles.length>0?{tiles:e.tiles}:new Error('TileJSON is missing required "tiles" property')},t.eX=$e,t.eY=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.eZ=ea,t.e_=function(e){return e({pluginStatus:$a,pluginURL:qa}),Za.on("pluginStateChange",e),e},t.ea=zo,t.eb=nt,t.ec=function(e,t,r,n,i){return Ze((e-t)/(r-t)*(i-n)+n,n,i)},t.ed=tg,t.ee=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e},t.ef=function(e){const t=e.layers[0];"circle"===t.type&&"hd-road-markup"===t.layout.get("circle-elevation-reference")&&(e.hdExt=new ag);},t.eg=function(e,t){const r=e.layers[0].layout.get("fill-elevation-reference"),n="hd-road-base"===r||"hd-road-markup"===r?r:null,i=!!t&&t.length>0&&tg(t,e.layers[0].source,e.sourceLayerName);(n||i)&&(e.hdExt=new rg(e,n,i));},t.eh=function(e,t){const r="hd-road-markup"===e.layers[0].layout.get("line-elevation-reference"),n=!!t&&t.length>0&&tg(t,e.layers[0].source,e.sourceLayerName);(r||n)&&(e.hdExt=new sg(r,n));},t.ei=function(e){"hd-road-markup"===e.layers[0].layout.get("symbol-elevation-reference")&&(e.hdExt=new lg);},t.ej=Vl,t.ek=_n,t.el=An,t.em=Tl,t.en=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e},t.eo=A,t.ep=Y,t.eq=vs,t.er=d,t.es=E,t.et=hr,t.eu=O,t.ev=rm,t.ew=tt,t.ex=U,t.ey=ue,t.ez=ee,t.f=Jf,t.f$=Ye,t.f0=Rl,t.f1=function(e){if("provider"in e&&!e.provider)return null;let t=e.provider;if(!t&&"url"in e&&e.url&&(t=function(e){try{const t=new URL(e).pathname.split("/").pop()||"",r=t.lastIndexOf(".");return r>=0?t.slice(r+1):""}catch{return ""}}(e.url)),!t)return null;const r=Pt.TILE_PROVIDER_URLS[t];if(!r)return null;let n;try{n=new URL(r,Pt.API_URL).href;}catch(e){return new Error(`TileProvider "${t}" has an invalid URL: "${r}"`)}return {name:t,url:n}},t.f2=ie,t.f3=m,t.f4=se,t.f5=function(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],a=t[3],o=Math.sin(r),l=Math.cos(r);return e[0]=n*l+i*o,e[1]=i*l-n*o,e[2]=s*l+a*o,e[3]=a*l-s*o,e},t.f6=g,t.f7=ja,t.f8=function(e,t){return [Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},t.f9=Mt,t.fA=Ds,t.fB=Vs,t.fC=ks,t.fD=Fs,t.fE=function(e,t,r,n,i,s,a,o,l){if("globe"===l.name)return Ff(e,t,new Jf(r,n,i),!1);const u=nm({z:r,x:n,y:i},l);return new If([(s+u.x/u.scale)*t,t*(u.y/u.scale),a],[(s+u.x2/u.scale)*t,t*(u.y2/u.scale),o])},t.fF=Df,t.fG=Ew,t.fH=Fl,t.fI=nm,t.fJ=$l,t.fK=q,t.fL=$,t.fM=te,t.fN=Rm,t.fO=H,t.fP=kf,t.fQ=p,t.fR=function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],s=t[6],a=t[7],o=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=i,e[13]=a,e[14]=o;}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},t.fS=Ha,t.fT=fo,t.fU=et,t.fV=we,t.fW=function(e,t,r,n,i){const s=5*t+2;e.float32[s+0]=r,e.float32[s+1]=n,e.float32[s+2]=i;},t.fX=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},t.fY=function(e){const t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},t.fZ=function(e){return !!e&&Ue.test(e)},t.f_=lt,t.fa=F,t.fb=Q,t.fc=f,t.fd=ye,t.fe=D,t.ff=T,t.fg=function(e){Pt.ACCESS_TOKEN=e;},t.fh=function(e){Pt.API_URL=e;},t.fi=function(e){Pt.BUILDING_GEN_URL=Tt.resolveURL(e);},t.fj=function(e,t){Lt=e,Ot=t;},t.fk=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3];},t.fl=function(e){Pt.DRACO_URL=Tt.resolveURL(e);},t.fm=function(e){Pt.MAX_PARALLEL_IMAGE_REQUESTS=e;},t.fn=function(e){const t=Tt.resolveURL(e);Pt.MESHOPT_URL=t,Pt.MESHOPT_SIMD_URL=t;},t.fo=function(e,t,r=!1){if($a===ja.deferred||$a===ja.loading||$a===ja.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");qa=Tt.resolveURL(e),$a=ja.deferred,Ga=t,Xa(),r||Ya();},t.fp=Tm,t.fq=We,t.fr=up,t.fs=po,t.ft=ct,t.fu=L,t.fv=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return !1}},t.fw=Ct,t.fx=W,t.fy=ve,t.fz=z,t.g=kh,t.g0=X,t.h=Du,t.i=Ar,t.j=bn,t.k=pw,t.l=lo,t.m=class{constructor(e){this.entries={},this.scheduler=e;}request(e,t,r,n){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,r]=i.result;return this.scheduler?this.scheduler.add(()=>{n(e,r);},t):n(e,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r((r,n)=>{i.result=[r,n];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(r,n);},t):e(r,n);setTimeout(()=>delete this.entries[e],3e3);})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==n),i.callbacks.length||(i.cancel(),delete this.entries[e]));}}},t.n=[1,1,1],t.o=Cw,t.p=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const r=ct([1,e,t]);return {x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,r){return {x:wr(e.x,t.x,r),y:wr(e.y,t.y,r),z:wr(e.z,t.z,r)}}},t.q=7,t.r=Xn,t.s=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return !1;const r=t.getSource().maxzoom,n=1<1)return t;const i=n.getSource().maxzoom,s=1<{const o=this.getAtTileOffset(e,i,s,a),l=n.upVector(e.canonical,i.x,i.y);return F(l,l,o*n.upVectorScale(e.canonical,t,r).metersToTile),l}}getForTilePoints(e,t,r,n){if(this.isUsingMockSource())return !1;const i=pw.create(this,e,n);return !!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],r,!0);}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const r=t.dem.tree,n=t.tileID,i=1<e.id-t.id),n.sort((e,t)=>e.id-t.id||e.idx-t.idx),n=n.filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id&&t.idx===e.idx));const a=new Array;let o=0;const l=n.length;for(const e of i){if(e.constantHeight){a.push(new oy(e.id,e.bounds,e.constantHeight));continue}for(;o!==l&&n[o].id{throw new Error(`TileProvider "${e}" failed to load: ${t instanceof Error?t.message:String(t)}`)}).then(t=>{const r=t.default;if("function"!=typeof r)throw new Error(`TileProvider "${e}" module must default-export a class`);if("function"!=typeof r.prototype.loadTile)throw new Error(`TileProvider "${e}" class must have a loadTile method`);return z_.set(e,r),r}).finally(()=>{P_.delete(e);});return P_.set(e,i),i},t.dh=function(e,t,r){return t?E_(e,t,r):e.tiles&&e.tiles.length>0?{tiles:e.tiles}:new Error('TileJSON is missing required "tiles" property')},t.di=Xb,t.dj=tw,t.dk=Bu,t.dl=Pf,t.dm=function(e){const t=80.051129;e=$e(e,-80.051129,t)/t*90;const r=Math.pow(Math.abs(Math.sin(Oe(e))),3);return Math.round(r*(pl.length-1))},t.dn=If,t.dp=function(e){const t=e.pixelsPerMeter,r=t/Al(1,e.center.lat),n=u(new Float64Array(16));return d(n,n,[e.point.x,e.point.y,0]),p(n,n,[r,r,t]),Float32Array.from(n)},t.dq=function(e,t,r,n){const i=t.getNorth(),s=t.getSouth(),o=t.getWest(),l=t.getEast(),u=1<0){const e=180/n;a(f,f,[e/c+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1]);}return f[2]=u,f[5]=e.x,f[8]=e.y,f},t.dr=256,t.ds=_u,t.dt=fs,t.du=xl,t.dv=wu,t.dw=bu,t.dx=Ml,t.dy=qt,t.dz=function(e,t){const r=[];for(const n in e)n in t||r.push(n);return r},t.e=function(e){return 0===e.indexOf("mapbox:")},t.e$=function(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=c*a-o*u,d=-c*s+o*l,p=u*s-a*l,f=r*h+n*d+i*p;return f?(e[0]=h*(f=1/f),e[1]=(-c*n+i*u)*f,e[2]=(o*n-i*a)*f,e[3]=d*f,e[4]=(c*r-i*l)*f,e[5]=(-o*r+i*s)*f,e[6]=p*f,e[7]=(-u*r+n*l)*f,e[8]=(a*r-n*s)*f,e):null},t.e0=kp,t.e1=Xp,t.e2=qs,t.e3=ce,t.e4=fe,t.e5=de,t.e6=xe,t.e7=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return !1;const r=t.getSource().maxzoom,n=1<1)return t;const i=n.getSource().maxzoom,s=1<{const o=this.getAtTileOffset(e,i,s,a),l=n.upVector(e.canonical,i.x,i.y);return F(l,l,o*n.upVectorScale(e.canonical,t,r).metersToTile),l}}getForTilePoints(e,t,r,n){if(this.isUsingMockSource())return !1;const i=ow.create(this,e,n);return !!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],r,!0);}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const r=t.dem.tree,n=t.tileID,i=1<({u_matrix:new uc(e),u_texsize:new ic(e),u_pixels_to_tile_units:new cc(e),u_device_pixel_ratio:new nc(e),u_width_scale:new nc(e),u_floor_width_scale:new nc(e),u_image:new rc(e),u_units_to_pixels:new ic(e),u_tile_units_to_pixels:new nc(e),u_alpha_discard_threshold:new nc(e),u_trim_offset:new ic(e),u_trim_fade_range:new ic(e),u_trim_gradient_mix_range:new ic(e),u_trim_color:new oc(e),u_zbias_factor:new nc(e),u_tile_to_meter:new nc(e),u_ground_shadow_factor:new sc(e),u_pattern_transition:new nc(e),u_opacity_multiplier:new nc(e)}),t.eG=e=>({u_matrix:new uc(e),u_pixels_to_tile_units:new cc(e),u_device_pixel_ratio:new nc(e),u_width_scale:new nc(e),u_floor_width_scale:new nc(e),u_units_to_pixels:new ic(e),u_dash_image:new rc(e),u_gradient_image:new rc(e),u_image_height:new nc(e),u_texsize:new ic(e),u_tile_units_to_pixels:new nc(e),u_alpha_discard_threshold:new nc(e),u_trim_offset:new ic(e),u_trim_fade_range:new ic(e),u_trim_gradient_mix_range:new ic(e),u_trim_color:new oc(e),u_zbias_factor:new nc(e),u_tile_to_meter:new nc(e),u_ground_shadow_factor:new sc(e),u_opacity_multiplier:new nc(e)}),t.eH=e=>({u_camera_to_center_distance:new nc(e),u_extrude_scale:new cc(e),u_device_pixel_ratio:new nc(e),u_matrix:new uc(e),u_inv_rot_matrix:new uc(e),u_merc_center:new ic(e),u_tile_id:new sc(e),u_zoom_transition:new nc(e),u_up_dir:new sc(e),u_emissive_strength:new nc(e)}),t.eI=du,t.eJ=Lh,t.eK=Yv,t.eL=(e,t,r,n,i,s)=>{const a=e.transform,o="globe"===a.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(o){const e=Rf(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=a.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(a.projection),u_matrix:e.translatePosMatrix(t.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:vt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Wv,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get("circle-emissive-strength")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[t.canonical.x,t.canonical.y,1<{const c=e.transform,h=c.pitch<15?pr(.07,.7,$e((14-c.zoom)/5,0,1)):.07,d="none"===r.paint.get("line-trim-color-use-theme").constantOr("default");return {u_matrix:Sb(e,t,r,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_width_scale:s,u_floor_width_scale:a,u_image:0,u_tile_units_to_pixels:Ib(t,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:r.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:Pl(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:u,u_opacity_multiplier:1}},t.eO=(e,t,r,n,i,s,a,o,l,u)=>{const c=e.transform,h=c.calculatePixelsToTileUnitsMatrix(t),d="none"===r.paint.get("line-trim-color-use-theme").constantOr("default"),p=c.pitch<15?pr(.07,.7,$e((14-c.zoom)/5,0,1)):.07;return {u_matrix:Sb(e,t,r,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:s,u_width_scale:a,u_floor_width_scale:o,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Eb(r)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Ib(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:r.lut).toArray01(),u_zbias_factor:p,u_tile_to_meter:Pl(t.tileID.canonical,0),u_ground_shadow_factor:u,u_opacity_multiplier:1}},t.eP=Ye,t.eQ=gb,t.eR=qb,t.eS=Cf,t.eT=tu,t.eU=function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.eV=function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},t.eW=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},t.eX=xu,t.eY=vu,t.eZ=function(e,t,r,n,i){return $e((e-t)/(r-t)*(i-n)+n,n,i)},t.e_=ne,t.ea=$_,t.eb=Fg,t.ec=Ax,t.ed=nx,t.ee=function(){return {API_URL:wt.API_URL,DRACO_URL:wt.DRACO_URL,MESHOPT_URL:wt.MESHOPT_URL,MESHOPT_SIMD_URL:wt.MESHOPT_SIMD_URL,BUILDING_GEN_URL:wt.BUILDING_GEN_URL}},t.ef=Xt,t.eg=yp,t.eh=mp,t.ei=ja,t.ej=Ft,t.ek=nr,t.el=et,t.em=function(e){return e.includes(Mo)},t.en=function(e){const t=e.lastIndexOf(Mo);return t>=0?e.slice(t+1):""},t.eo=function(e){const t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},t.ep=function(e,t,r,n){return "custom"===e.type?new rw(e,t):new Bw[e.type](e,t,r,n)},t.eq=Qe,t.er=class extends Aw{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state={...e.state}),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer);}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},t.es=$a,t.et=function(e){return e({pluginStatus:Ua,pluginURL:Na}),$a.on("pluginStateChange",e),e},t.eu=je,t.ev=function(e,t,r){const n=Of(r.zoom),i=e.style.map._antialias,s=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!i&&!s},t.ew=function(e,t,r){const n=u(new Float64Array(16)),i=(t/(1<0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const r=Sm(new be(0,0),new be(Tn,Tn),e),n=[];if(t&&!Mm(r,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Mm(r,t))continue;const i=Bm(t.min,t.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope});}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(r).buckets[e.layer];n&&n.updateFootprints(r.toUnwrapped(),t);}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})));}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const r=e.getOrder(),n=e.getClipMask(),i=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Sm(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:r,clipMask:n,clipScope:i});}this._sourceIds.push(e.getSourceId());}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||_m(e.min,t.min)||_m(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const r=(e,t)=>e+t;return e.length-t.length||e.reduce(r,"").localeCompare(t.reduce(r,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[t];e=r.priority!==n.priority||!Am(r,n)||r.order!==n.order||r.clipMask!==n.clipMask||!we(r.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t;}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==vm&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const r=t[e].priority;for(;e1){let t=0,r=e(t);for(;t!==r;){let n=t;const i=t;for(;n!==r;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement();}},t.f2=vm,t.f3=class{constructor(e){this._createGrid(e),this._createPoles(e);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy();}_fillGridMeshWithLods(e,t){const r=new ql,n=new fu,i=[],s=e+1+2,a=t[0]+1,o=t[0]+1+(1+t.length),l=(e,t,r)=>{let n=e===s-1?e-2:0===e?e:e-1;return n+=r?24575:0,[n,t]};for(let e=0;e0&&eg(t,e.layers[0].source,e.sourceLayerName);(n||i)&&(e.hdExt=new tg(e,n,i));},t.fG=function(e,t){const r="hd-road-markup"===e.layers[0].layout.get("line-elevation-reference"),n=!!t&&t.length>0&&eg(t,e.layers[0].source,e.sourceLayerName);(r||n)&&(e.hdExt=new ig(r,n));},t.fH=Bh,t.fI=function(e){const t=e.layers[0];"circle"===t.type&&"hd-road-markup"===t.layout.get("circle-elevation-reference")&&(e.hdExt=new sg);},t.fJ=function(e){"hd-road-markup"===e.layers[0].layout.get("symbol-elevation-reference")&&(e.hdExt=new og);},t.fK=Zs,t.fL=ph,t.fM=2,t.fN=Fw,t.fO=kw,t.fP=yh,t.fQ=eg,t.fR=gh,t.fS=function(e,t){const r=Qy(e);return null!==r&&!!(t&1<{e.allowVerticalPlacement&&Ba(n)&&(w.vertical=vd(_,t,r,i,p,b,u,h,s,c,M,yd.vertical,!0,y,f,l,v.textScaleFactor));};if(!B&&d){const e="auto"===m?d.map(e=>Xp(e)):[m];let n=!1;for(let s=0;se()).catch(e);},t.fv=function(e){wt.MAX_PARALLEL_IMAGE_REQUESTS=e;},t.fw=function(e){wt.API_URL=e;},t.fx=function(e){wt.ACCESS_TOKEN=e;},t.fy="hd_road_elevation",t.fz=class{static parseFrom(e,t){const r=Jm.parse(e);if(!r)return [];let{vertices:n,features:i}=r;const s=1/Pl(t);i.sort((e,t)=>e.id-t.id),n.sort((e,t)=>e.id-t.id||e.idx-t.idx),n=n.filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id&&t.idx===e.idx));const a=new Array;let o=0;const l=n.length;for(const e of i){if(e.constantHeight){a.push(new sy(e.id,e.bounds,e.constantHeight));continue}for(;o!==l&&n[o].id=0&&e<128)return this.pos>=this.length&&this.realloc(1),void(this.buf[this.pos++]=e);e>268435455||e<0?function(e,t){let r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7);}(r,0,t),function(e,t){const r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))));}(n,t);}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))));}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e);}writeBoolean(e){this.writeVarint(+e);}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,r){for(let n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=n;continue}if(n<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);n<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:(n<65536?e[r++]=n>>12|224:(e[r++]=n>>18|240,e[r++]=n>>12&63|128),e[r++]=n>>6&63|128),e[r++]=63&n|128);}return r}(this.buf,e,this.pos);const r=this.pos-t;r>=128&&id(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r;}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4;}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8;}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t),this.buf.set(e,this.pos),this.pos+=t;}writeRawMessage(e,t){this.pos++;const r=this.pos;e(t,this);const n=this.pos-r;n>=128&&id(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;}writeMessage(e,t,r){this.writeTag(e,2),this.writeRawMessage(t,r);}writePackedVarint(e,t){t.length&&this.writeMessage(e,sd,t);}writePackedSVarint(e,t){t.length&&this.writeMessage(e,ad,t);}writePackedBoolean(e,t){t.length&&this.writeMessage(e,ud,t);}writePackedFloat(e,t){t.length&&this.writeMessage(e,od,t);}writePackedDouble(e,t){t.length&&this.writeMessage(e,ld,t);}writePackedFixed32(e,t){t.length&&this.writeMessage(e,cd,t);}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,hd,t);}writePackedFixed64(e,t){t.length&&this.writeMessage(e,dd,t);}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,pd,t);}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t);}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t);}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t);}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t);}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t);}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t);}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t);}writeStringField(e,t){this.writeTag(e,2),this.writeString(t);}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t);}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t);}writeBooleanField(e,t){this.writeVarintField(e,+t);}},t.g5=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Sg){const r=new Uint32Array(e,0,7),[,,n,i,s,a]=r;t=r.byteLength+i+s+a+s,(n!==e.byteLength||t>=e.byteLength)&&nt("Invalid b3dm header information.");}return Vg(e,t)},t.g6=function(e,t){const r=e.json.extensionsUsed&&e.json.extensionsUsed.includes("mbx_bvh"),n=Ax(e);for(const e of n){if(!r)for(const t of e.meshes)Mx(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(Sx(e.lights,t)));}return n},t.g7=yw,t.g8=at,t.g9=Xa,t.ga=La,t.gb=function(e){Ut(),null!=Lt&&Lt.then(t=>{t.keys().then(r=>{for(let n=0;nnt(e.message));}).catch(e=>nt(e.message));}).catch(e=>nt(e.message));},t.h=async function(e,t){return Kt(Object.assign(e,{method:"GET"}),t)},t.i=function(e){return wt.API_STYLE_REGEX.test(e)&&!Gt(e)},t.j=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},t.k=It,t.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},t.m=oo,t.n=Us,t.o=Jt,t.p=async function(e,t){return Kt(Object.assign(e,{method:"POST"}),t)},t.q=async function(e,t){It.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*");const r=await function(e){return new Promise((t,r)=>{if(e&&e.aborted)return void r(e.reason);const n=()=>{const e=tr.shift();e?e():rr--;};if(rr{e&&e.removeEventListener("abort",s),t(n);},s=()=>{const t=tr.indexOf(i);-1!==t&&tr.splice(t,1),r(e.reason);};e&&e.addEventListener("abort",s),tr.push(i);})}(t);try{const{data:r,headers:n}=await Qt(e,t);let i;try{i=await createImageBitmap(new Blob([new Uint8Array(r)],{type:"image/png"}));}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`,{cause:e})}return t&&t.throwIfAborted(),{data:i,headers:n}}finally{r();}},t.r=vt,t.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return !1}},t.t=fh,t.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},t.v=function(e){return !!e&&Le.test(e)},t.w=nt,t.x=xt,t.y=Io,t.z=class{constructor(e){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(e&&e.maxTextureMemoryMB?e.maxTextureMemoryMB:256)*1024,this.currentFrameAtlases=new Set,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures();});}beginFrame(){this.currentFrameAtlases.clear();}calculateTextureMemory(e){return e.image?Math.ceil(e.image.width*e.image.height*4*(e.patternPositions.size>0?1.33:1)):0}evictTexture(e){const t=this.textures.get(e);if(t){const r=this.calculateTextureMemory(e);t.destroy(),this.textures.delete(e),this.textureAccessTimes.delete(e),this.textureMemoryUsed-=r,e.uploaded=!1;}}evictTexturesIfNeeded(e){for(;this.textureMemoryUsed+e>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[r]of this.textures.entries()){if(this.currentFrameAtlases.has(r))continue;const n=this.textureAccessTimes.get(r)||0;n0){let e=!1;for(const s of a[0])if(s.x<0||s.x>t.r||s.y<0||s.y>t.r){e=!0;break}if(e)continue}const l=1===a.length&&5===a[0].length&&a[0].some(e=>e.x<=0&&e.y<=0)&&a[0].some(e=>e.x>=t.r&&e.y<=0)&&a[0].some(e=>e.x>=t.r&&e.y>=t.r)&&a[0].some(e=>e.x<=0&&e.y>=t.r);s.push(new t.M(r,l?[]:a));}return s}function r(e,s,i,o,n){const r=t.cp(s);if(null===r)return !1;let a=i.x,l=i.y;const c=null!=n?n:o.z;if(o.z!==c){const e=1<e.map(e=>[e.x,e.y]));if(t.eJ([a,l],e))return !0}return !1}function a(e,s,i,o){const n=s.indoorState.activeFloorsVisible;if(!s.sourceLayers)return n?s.indoorState.activeFloors:void 0;const r=function(e,s){if(!e)return t.f_("No source layers defined in indoor specification"),s;if(0===e.size)return s;const i=e.difference(s);for(const e of i)t.f_(`Missing source layer required in indoor specification: ${e}`);return s.intersection(s)}(s.sourceLayers,new Set(Object.keys(e.layers))),a=s.indoorState,d=function(e,s,i,o,n){const r={};for(const i of s){const s=e.layers[i];if(s)for(let e=0;ei.map(i=>t.cV(i,s,e.extent)));return 0===o.length?void 0:{type:"Polygon",coordinates:[o[0]]}}(e,s);return {id:i,isDefault:o,connections:n,conflicts:r,buildings:a,name:l,zIndex:c,geometry:u}}function d(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function f(e){return d(e,["type","id","name"])&&"structure"===e.properties.type}function p(e){return d(e,["type","id","name","z_index"])&&"floor"===e.properties.type}function g(e,s){e instanceof t.J?t.eg(e,s):e instanceof t.aa?t.eh(e,s):e instanceof t.g?t.ef(e):e instanceof t.aX&&t.ei(e);}function m(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const s of e)t+=`${m(s)},`;return `${t}]`}let t="{";for(const s of Object.keys(e).sort())t+=`${s}:${m(e[s])},`;return `${t}}`}function y(e){let s="";for(const i of t.eY)s+=`/${m(e[i])}`;return s}function w(e,t){return function e(s){return "string"==typeof s&&s===t||(Array.isArray(s)?s.some(e):!(!s||"object"!=typeof s)&&Object.values(s).some(e))}(e)}class b{constructor(e){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),e&&this.replace(e);}replace(e,t){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(e,[],t);}update(e,s,i){this._options=i;for(const s of e)this._layerConfigs[s.id]=s,(this._layers[s.id]=t.c0(s,this.scope,null,this._options)).compileFilter(i),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource=Object.create(null);const o=function(e,t){const s=Object.create(null);for(let i=0;ithis._layers[e.id]),s=t[0];if("none"===s.visibility)continue;const i=s.source||"";let o=this.familiesBySource[i];o||(o=this.familiesBySource[i]=Object.create(null));const n=s.sourceLayer||"_geojsonTileLayer";let r=o[n];r||(r=o[n]=[]),r.push(t);}}}const v=1*t.aI;class x{constructor(e){const s={},i=[];for(const t in e){const o=e[t],n=s[t]={};for(const e in o.glyphs){const t=o.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?v:1,r={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};i.push(r),n[e]=r;}}const{w:o,h:n}=t.eT(i),r=new t.b({width:o||1,height:n||1});for(const i in e){const o=e[i];for(const e in o.glyphs){const n=o.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=s[i][e],l=n.metrics.localGlyph?v:1;t.b.copy(n.bitmap,r,{x:0,y:0},{x:a.x+l,y:a.y+l},n.bitmap);}}this.image=r,this.positions=s;}}function S(e){for(const t of e){if(null!=t.hdExt)return !0;if(t.requiresHDRuntime)return !0}return !1}function I(e){for(const t of e)if(t.requiresStandardRuntime)return !0;return !1}t.eZ(x,"GlyphAtlas");class M{constructor(e){this.tileID=new t.ap(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.collectResourceTiming=!!e.request&&e.request.collectResourceTiming,this.promoteId=e.promoteId,this.renderSourceType=e.renderSourceType,this.frcCoverage=e.frcCoverage||null,this.deferRoadStructure=!1,this.tileTransform=t.fI(e.tileID.canonical,e.projection),this.projection=e.projection,this.worldview=e.worldview,this.localizableLayerIds=e.localizableLayerIds,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep,this.scaleFactor=e.scaleFactor,this.worldview=e.worldview,this.indoor=e.indoor;}isLayerActiveForTile(e){return !(this.renderSourceType===t.aC.Symbol&&"symbol"!==e.type||this.renderSourceType===t.aC.FillExtrusion&&"fill-extrusion"!==e.type||this.renderSourceType===t.aC.Other&&("symbol"===e.type||"fill-extrusion"===e.type)||e.minzoom&&this.zoom=e.maxzoom||"none"===e.visibility)}parse(e,t,s,i,o,n){this._parseAfterHD(e,t,s,i,o,n);}_parseAfterHD(e,s,l,c,u,h){let d;if(this.status="parsing",this.data=e,this.renderSourceType===t.aC.HdRoadCoverage){const s=e.layers[t.X];d=s&&n?n(s):[];}this.collisionBoxArray=new t.h;const f=new t.o(Object.keys(e.layers).sort()),p=new t.I(this.tileID,this.promoteId);p.bucketLayerIDs=[];const m={},y=new t.a9(256,256),w={featureIndex:p,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:y,availableImages:l,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&a&&(w.activeFloors=a(e,this.indoor,u,this.canonical));const b=[],v=s.familiesBySource[this.source];if(this.deferRoadStructure=!1,this.renderSourceType!==t.aC.HdRoadCoverage&&null!=this.frcCoverage&&!this.frcCoverage.resolved&&null===this.frcCoverage.frcMask)for(const e in v)if(t.ed&&t.ed(this.frcCoverage.sourceLayers,this.source,e)){this.deferRoadStructure=!0;break}for(const s in v){const o=e.layers[s];if(!o)continue;let n=!1,r=!1,a=!1,u=!1;for(const e of v[s])"symbol"===e[0].type?n=!0:"fill-extrusion"===e[0].type?r=!0:a=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(this.renderSourceType===t.aC.Symbol&&!n)continue;if(this.renderSourceType===t.aC.FillExtrusion&&!r)continue;if((this.renderSourceType===t.aC.Other||this.renderSourceType===t.aC.HdRoadCoverage)&&!a)continue;const h=null!=this.frcCoverage&&!!t.ed&&t.ed(this.frcCoverage.sourceLayers,this.source,s);if(this.deferRoadStructure&&h)continue;1===o.version&&t.f_(`Vector tile source "${this.source}" layer "${s}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=f.encode(s),y=[],x=this.localizableLayerIds&&this.localizableLayerIds.has(s);let S=!1;for(let e=0,i=0;et.ea(e.id,e.scope)));const n=()=>{const t=m[i.id]=i.createBucket({index:o,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceLayerName:s,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:c,worldview:this.worldview,localizable:x,availableImages:l,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});g&&g(t,this.frcCoverage?this.frcCoverage.sourceLayers:null),t.populate(y,w,this.tileID.canonical,this.tileTransform);};i.mayUse("HD")||i.mayUse("Standard")?b.push(i.prepare().then(()=>n())):n();}}const M=()=>{y.trim();const s=!(!w.elevationFeatures||!w.elevationFeatures.some(e=>e.heightRange.min<0));let i,n,a,c,g,b,v;const M={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},T=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster){this.status="done";const e=Object.values(m).filter(e=>!e.isEmpty());h(null,{buckets:e,containsHdExt:S(e),containsStandardExt:I(e),featureIndex:p,collisionBoxArray:null,hasTunnelGeometry:s,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:w.brightness,glyphMap:null,iconMap:null,glyphPositions:null});}else if(n&&a&&c&&v){const e=void 0,s=new x(n),i=new Map;for(const[e,s]of a.entries()){const{imagePosition:o}=t.cR(e,s,t.Z);i.set(e,o);}const o={};for(const e in m){const c=m[e];c instanceof t.aX&&(C(c.layers,this.zoom,w.brightness,l,this.worldview,w.activeFloors),o[e]=t.eD(c,n,s.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,g,this.worldview,l,this.frcCoverage?this.frcCoverage.frcMask:null,this.frcCoverage?this.frcCoverage.polygons:null,this.frcCoverage?this.frcCoverage.tileZoom:null,t.dz||null,r||null));}g.size||b.size?this.rasterizeTask=u.send("rasterizeImages",{scope:this.scope,iconTasks:g,patternTasks:b},(t,i)=>{if(!t)for(const[e,t]of i.entries())a.has(e)&&a.set(e,Object.assign(a.get(e),{data:t})),c.has(e)&&c.set(e,Object.assign(c.get(e),{data:t}));P(o,s,e,v);}):P(o,s,e,v);}},P=(e,i,o,n)=>{const r=a.size>0||c.size>0,f=Object.keys(e).length>0;if(!r&&!f){this.status="done";const e=Object.values(m).filter(e=>!e.isEmpty());return void h(null,{buckets:e,containsHdExt:S(e),containsStandardExt:I(e),featureIndex:p,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:s,glyphAtlasImage:i.image,lineAtlas:y,imageAtlas:null,brightness:w.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:d})}const g=(o,n)=>{for(const s in m){const i=m[s];if(s in e)t.eS(i,e[s],this.showCollisionBoxes,l,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,n);else if(i.hasPattern&&(i instanceof t.aa||i instanceof t.J||i instanceof t.K)){C(i.layers,this.zoom,w.brightness,l,this.worldview,w.activeFloors);const e=Object.fromEntries(n.patternPositions);i.addFeatures(w,this.tileID.canonical,e,l,this.tileTransform,this.brightness);}}this.status="done";const r=Object.values(m).filter(e=>!e.isEmpty());h(null,{buckets:r,containsHdExt:S(r),containsStandardExt:I(r),featureIndex:p,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:s,glyphAtlasImage:i.image,lineAtlas:y,imageAtlas:o,brightness:w.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:d});};if(r){const e=new Map,s=t.fr(a,e),i=t.fr(c,e),o=new t.c(s,i,n,this.lut,e);u.send("checkAtlasCache",{descriptor:o,scope:this.scope},(e,s)=>{let i,o;if(e&&t.f_(`[Worker] Error checking atlas cache: ${e.message}`),s)i=new t.a0(s.sourceHash),o=s;else {const e=new t._(a,c,this.lut,n);i=e,o=e;}g(i,o);});}else g(null,{iconPositions:new Map,patternPositions:new Map});};if(!this.extraShadowCaster){const e=t.eb(w.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?u.send("getGlyphs",{uid:this.uid,stacks:e},(e,t)=>{i||(i=e,n=t,T());},void 0,!1,M):n={},v=new Map;const s=Array.from(w.iconDependencies.keys()).map(e=>t.a1.parse(e)),o=Array.from(w.patternDependencies.keys()).map(e=>t.a1.parse(e));s.length||o.length?u.send("getImages",{icons:s,patterns:o,source:this.source,scope:this.scope,tileID:this.tileID},(e,t)=>{if(!i){i=e,a=new Map,c=new Map,g=this.updateImageMapAndGetImageTaskQueue(a,t.images,w.iconDependencies),b=this.updateImageMapAndGetImageTaskQueue(c,t.images,w.patternDependencies);for(const[e,s]of t.versions.entries())v.set(e,s);T();}},void 0,!1,M):(a=new Map,c=new Map,g=new Map,b=new Map);}o&&o({buckets:m,data:e,sourceLayerCoder:f,canonical:this.tileID.canonical,options:w}),T();};b.length>0?Promise.allSettled(b).then(M).catch(h):M();}updateParameters(e){this.scaleFactor=e.scaleFactor,this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.projection=e.projection,this.brightness=e.brightness,this.tileTransform=t.fI(e.tileID.canonical,e.projection),this.extraShadowCaster=e.extraShadowCaster,this.lut=e.lut,this.worldview=e.worldview,this.indoor=e.indoor,this.frcCoverage=e.frcCoverage||null;}updateImageMapAndGetImageTaskQueue(e,t,s){const i=new Map;for(const o of t.keys()){const n=s.get(o)||[];for(const s of n){const o=s.toString(),n=t.get(s.id.toString());n.usvg?i.has(o)||(i.set(o,s),e.set(o,Object.assign({},n))):e.set(o,n);}}return i}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel();}}function C(e,s,i,o,n,r){const a=new t.w(s,{brightness:i,worldview:n,activeFloors:r});for(const t of e)t.recalculate(a,o);}class T extends t.y{constructor({actor:e,layerIndex:s,availableImages:i,availableModels:o,isSpriteLoaded:n,tileProvider:r,brightness:a,maxUniformBufferBindings:l,maxUniformBlockSizeDwords:c,disableSymbolUBO:u}){super(),this.actor=e,this.layerIndex=s,this.availableImages=i,this.availableModels=o,this.loadVectorData=t.e9,this.tileProvider=r,this.loading={},this.loaded={},this.deduped=new t.m(e.scheduler),this.isSpriteLoaded=n,this.scheduler=e.scheduler,this.brightness=a,this.maxUniformBufferBindings=l,this.maxUniformBlockSizeDwords=c,this.disableSymbolUBO=u;}loadTileData(e,t){if(!this.tileProvider)return this.loadVectorData(e,t);const s=new AbortController;return this.loadTileWithProvider(this.tileProvider,e,s,t),()=>s.abort()}async loadTileWithProvider(e,t,s,i){const{z:o,x:n,y:r}=t.tileID.canonical;try{const a=await e.loadTile({z:o,x:n,y:r},{request:t.request,signal:s.signal});if(s.signal.aborted)return;if(null==a){const e=new Error("Tile not found");return e.status=404,i(e)}if(null==a.data)return i(null,null);if(a.data instanceof ImageBitmap)return i(new Error("Vector tiles require ArrayBuffer data"));const l=new Map;a.expires&&l.set("expires",a.expires),a.cacheControl&&l.set("cache-control",a.cacheControl),i(null,{rawData:a.data,responseHeaders:l});}catch(e){if(s.signal.aborted)return;i(e instanceof Error?e:new Error(String(e)));}}loadTile(e,i){const o=e.uid,n=e&&e.request,r=n&&n.collectResourceTiming,a=this.loading[o]=new M(e);a.maxUniformBufferBindings=this.maxUniformBufferBindings,a.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,a.disableSymbolUBO=this.disableSymbolUBO,a.abort=this.loadTileData(e,(l,c)=>{const u=!this.loading[o];if(delete this.loading[o],a.cancelRasterize(),u||l||!c)return a.status="done",u||(this.loaded[o]=a),i(l);const h=c.rawData,d={},f=t.cO(c.responseHeaders);f&&f.expires&&(d.expires=f.expires),f&&f.cacheControl&&(d.cacheControl=f.cacheControl),a.vectorTile=c.vectorTile||new t.be(new t.as(h));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,t)=>{if(e||!t)return i(e);const o={};if(r){const e=s(n);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)));}i(null,Object.assign({rawTileData:h.slice(0),responseHeaders:c.responseHeaders},t,d,o));});};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",renderSourceType:e.renderSourceType,zoom:e.tileZoom}):p();}),this.loaded=this.loaded||{},this.loaded[o]=a;});}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.updateParameters(e);const n=(e,s)=>{const i=o.reloadCallback;i&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,i)),t(e,s);};"parsing"===o.status?o.reloadCallback=n:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n):n());}else t(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class P{constructor(e){this.tileProvider=e.tileProvider,this.loading={};}loadTile(e,s){const i=e.uid;if(this.tileProvider){const t=new AbortController;return this.loading[i]={cancel:()=>t.abort()},void this.loadTileWithProvider(this.tileProvider,i,e,t,s)}const{cancel:o}=t.cG(e.request,(o,n,r)=>{const a=!this.loading[i];if(delete this.loading[i],a||o||!n)return s(o);this.decodeTile(i,n,e.encoding).then(e=>{const{expires:i,cacheControl:o}=t.cO(r);s(null,Object.assign(e,{expires:i,cacheControl:o}));}).catch(e=>s(e));});this.loading[i]={cancel:o};}async decodeTile(e,s,i){const o=s instanceof ImageBitmap?s:await createImageBitmap(new Blob([new Uint8Array(s)],{type:"image/png"})),n=1-(o.width-t.eU(o.width))/2,r=n<1,a=this.getImageData(o,n);return o.close(),{dem:new t.D(e,a,i,r),borderReady:r}}async loadTileWithProvider(e,t,s,i,o){const{z:n,x:r,y:a}=s.tileID.canonical;try{const l=await e.loadTile({z:n,x:r,y:a},{request:s.request,signal:i.signal});if(i.signal.aborted)return o(null,null);if(null==l){const e=new Error("Tile not found");return e.status=404,o(e)}if(null==l.data)return o(null,null);const c=await this.decodeTile(t,l.data,s.encoding);if(i.signal.aborted)return o(null,null);o(null,Object.assign(c,{expires:l.expires,cacheControl:l.cacheControl}));}catch(e){if(i.signal.aborted)return o(null,null);if(e instanceof DOMException&&"AbortError"===e.name)return o(null,null);o(e instanceof Error?e:new Error(String(e)));}finally{delete this.loading[t];}}reloadTile(e,t){t(null,null);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.cancel(),delete this.loading[s]),t();}removeTile(e,t){t();}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const s=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),s}}t.af.setPbf(t.as);class k{constructor(e){this._mrt=new t.af(e.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=e.uid,this.tileID=e.tileID,this.source=e.source;}parse(e,s){const i=this._mrt;this.status="parsing",this._entireBuffer=e;try{i.parseHeader(e),this._isHeaderLoaded=!0;const o=[];for(const s in i.layers){const n=i.getLayer(s),r=n.getDataRange(n.getBandList()),a=i.createDecodingTask(r),l=e.slice(r.firstByte,r.lastByte+1),c=t.af.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));o.push(c);}Promise.allSettled(o).then(()=>s(null,i)).catch(e=>s(e));}catch(e){s(e);}}}class _{constructor({actor:e}){this.actor=e,this.loading={},this.loaded={};}loadTile(e,s){const i=e.uid,o=e.request,n=this.loading[i]=new k(e),{cancel:r}=t.cG(o,(e,t,o)=>{const r=!this.loading[i];if(delete this.loading[i],r||e||!t)return n.status="done",r||(this.loaded[i]=n),s(e);n.parse(t,(e,t)=>{if(e||!t)return s(e);s(null,t,o);}),this.loaded[i]=n;});n.abort=r;}reloadTile(e,t){t(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=e.uid;this.loaded[s]&&delete this.loaded[s],t();}decodeRasterArray(e,s){t.af.performDecoding(e.buffer,e.task).then(e=>s(null,e)).catch(e=>s(e));}}const D=t.bf.prototype.toGeoJSON;class L{constructor(e){this._feature=e,this.extent=t.r,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 s of this._feature.geometry)e.push([new t.au(s[0],s[1])]);return e}{const e=[];for(const s of this._feature.geometry){const i=[];for(const e of s)i.push(new t.au(e[0],e[1]));e.push(i);}return e}}toGeoJSON(e,t,s){return D.call(this,e,t,s)}}class O{constructor(e,s){this.name=e,this.extent=t.r,this.length=s.length,this._jsonFeatures=s;}feature(e){return new L(this._jsonFeatures[e])}}class z{constructor(e){this.layers={},this.extent=t.r;for(const t of Object.keys(e))this.layers[t]=new O(t,e[t]);}}const j=64/4096;class B{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const s of e){const e=s.id;if(null==e)continue;let i=this.features.get(e);i&&this.updateCache(i,t),s.geometry?(i=F(s),this.updateCache(i,t),this.features.set(e,i)):this.features.delete(e),this.updateCache(i,t);}}updateCache(e,t){for(const{canonical:s,uid:i}of Object.values(t)){const{z:o,x:n,y:r}=s;E(e,Math.pow(2,o),n,r)&&delete t[i];}}getTile(e,t,s){const i=Math.pow(2,e),o=[];for(const e of this.features.values())E(e,i,t,s)&&o.push(Z(e,i,t,s));return {features:o}}getFeatures(){return [...this.features.values()]}}function E({minX:e,minY:t,maxX:s,maxY:i},o,n,r){return e<(n+1+j)/o&&t<(r+1+j)/o&&s>(n-j)/o&&i>(r-j)/o}function F(e){const{id:t,geometry:s,properties:i}=e;if(!s)return;if("GeometryCollection"===s.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:o,coordinates:n}=s,r={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===o)A(n,a,r);else if("MultiPoint"===o)for(const e of n)A(e,a,r);else if("LineString"===o)r.type=2,R(n,a,r);else if("MultiLineString"===o)r.type=2,U(n,a,r);else if("Polygon"===o)r.type=3,U(n,a,r,!0);else {if("MultiPolygon"!==o)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of n)U(e,a,r,!0);}return r}function A([e,s],i,o){const n=t.ek(e);let r=t.el(s);r=r<0?0:r>1?1:r,i.push(n,r),o.minX=Math.min(o.minX,n),o.minY=Math.min(o.minY,r),o.maxX=Math.max(o.maxX,n),o.maxY=Math.max(o.maxY,r);}function R(e,t,s,i=!1,o=!1){const n=[];for(const t of e)A(t,n,s);t.push(n),i&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t0===t)for(let t=0,s=e.length;t=a&&d>=a||(u>=a?(h+=Math.round(g*((a-u)/p)),u=a):d>=a&&(f=h+Math.round(g*((a-u)/p)),d=a),h>=a&&f>=a||(h>=a?(u+=Math.round(p*((a-h)/g)),h=a):f>=a&&(d=u+Math.round(p*((a-h)/g)),f=a),l&&u===l.at(-1)[0]&&h===l.at(-1)[1]||(l=[[u,h]],n.push(l)),l.push([d,f])))));}}function Y(e,s,i,o,n){const r=(i-j)/s,a=(o-j)/s,l=(i+1+j)/s,c=(o+1+j)/s;function u(e,t){let s=0;return el&&(s|=2),tc&&(s|=8),s}let h=[];for(let t=1;t<=8;t*=2){let s=e[e.length-2],i=e.at(-1),o=!(u(s,i)&t);for(let n=0;n>31}function q(e,t){const{geometry:s,type:i}=e;let o=0,n=0;if(1===i){t.writeVarint(J(1,s.length));for(const e of s){const s=e[0]-o,i=e[1]-n;t.writeVarint($(s)),t.writeVarint($(i)),o+=s,n+=i;}}else for(const e of s){if(0===e.length)continue;t.writeVarint(J(1,1));const s=e.length-(3===i?1:0);for(let i=0;ie},Q=Math.fround||(K=new Float32Array(1),e=>(K[0]=+e,K[0]));var K;class ee{constructor(e){this.options=Object.assign(Object.create(W),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:s,maxZoom:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const n=[];for(let t=0;t=s;e--){const s=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log("z%d: %d clusters in %dms",e,r.numItems,+Date.now()-s);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let o=180===e[2]?180:((e[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,o=180;else if(s>o){const e=this.getClusters([s,i,180,n],t),r=this.getClusters([-180,i,o,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(ie(s),oe(n),ie(o),oe(i)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?te(l,t,this.clusterProps):this.points[l[t+3]]);}return c}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),i="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(i);const n=o.data;if(t*this.stride>=n.length)throw new Error(i);const r=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=o.within(n[t*this.stride],n[t*this.stride+1],r),l=[];for(const t of a){const s=t*this.stride;n[s+4]===e&&l.push(n[s+5]>1?te(n,s,this.clusterProps):this.points[n[s+3]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,s){const i=[];return this._appendLeaves(i,e,t=t||10,s=s||0,0),i}getTile(e,t,s){const i=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(s-a)/o,c=(s+1+a)/o,u={features:[]};return this._addTileFeatures(i.range((t-a)/o,l,(t+1+a)/o,c),i.data,t,s,o,u),0===t&&this._addTileFeatures(i.range(1-a/o,l,1,c),i.data,o,s,o,u),t===o-1&&this._addTileFeatures(i.range(0,l,a/o,c),i.data,-1,s,o,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,1!==s.length)break;e=s[0].properties.cluster_id;}return t}_appendLeaves(e,t,s,i,o){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?o+n.point_count<=i?o+=n.point_count:o=this._appendLeaves(e,n.cluster_id,s,i,o):o1;let l,c,u;if(a)l=se(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const s=this.points[t[e+3]];l=s.properties;const[i,o]=s.geometry.coordinates;c=ie(i),u=oe(o);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*o-s)),Math.round(this.options.extent*(u*o-i))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),n.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:i,reduce:o,minPoints:n}=this.options,r=s/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let s=0;st&&(f+=a[s+5]);}if(f>d&&f>=n){let e,n=i*d,r=u*d,p=-1;const g=(s/c<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];n+=a[l]*u,r+=a[l+1]*u,a[l+4]=g,o&&(e||(e=this._map(a,s,!0),p=this.clusterProps.length,this.clusterProps.push(e)),o(e,this._map(a,l)));}a[s+4]=g,l.push(n/f,r/f,1/0,g,-1,f),o&&l.push(p);}else {for(let e=0;e1)for(const e of h){const s=e*c;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+5]>1){const i=this.clusterProps[e[t+6]];return s?Object.assign({},i):i}const i=this.points[e[t+3]].properties,o=this.options.map(i);return s&&o===i?Object.assign({},o):o}}function te(e,t,s){return {type:"Feature",id:e[t+3],properties:se(e,t,s),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),ne(e[t+1])]}};var i;}function se(e,t,s){const i=e[t+5],o=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,n=e[t+6],r=-1===n?{}:Object.assign({},s[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:o})}function ie(e){return e/360+.5}function oe(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function ne(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function re(e,t,s,i){let o=i;const n=t+(s-t>>1);let r,a=s-t;const l=e[t],c=e[t+1],u=e[s],h=e[s+1];for(let i=t+3;io)r=i,o=t;else if(t===o){const e=Math.abs(i-n);ei&&(r-t>3&&re(e,t,r,i),e[r+2]=o,s-r>3&&re(e,r,s,i));}function ae(e,t,s,i,o,n){let r=o-s,a=n-i;if(0!==r||0!==a){const l=((e-s)*r+(t-i)*a)/(r*r+a*a);l>1?(s=o,i=n):l>0&&(s+=r*l,i+=a*l);}return r=e-s,a=t-i,r*r+a*a}function le(e,t,s,i){const o={id:e??null,type:t,geometry:s,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)ce(o,s);else if("Polygon"===t)ce(o,s[0]);else if("MultiLineString"===t)for(const e of s)ce(o,e);else if("MultiPolygon"===t)for(const e of s)ce(o,e[0]);return o}function ce(e,t){for(let s=0;s0&&(r+=i?(o*l-a*n)/2:Math.sqrt(Math.pow(a-o,2)+Math.pow(l-n,2))),o=a,n=l;}const a=t.length-3;t[2]=1,re(t,0,a,s),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function fe(e,t,s,i){for(let o=0;o1?1:s}function me(e,t,s,i,o,n,r,a){if(i/=t,n>=(s/=t)&&r=i)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===o?t.minX:t.minY,c=0===o?t.maxX:t.maxY;if(r>=s&&c=i)continue;let u=[];if("Point"===n||"MultiPoint"===n)ye(e,u,s,i,o);else if("LineString"===n)we(e,u,s,i,o,!1,a.lineMetrics);else if("MultiLineString"===n)ve(e,u,s,i,o,!1);else if("Polygon"===n)ve(e,u,s,i,o,!0);else if("MultiPolygon"===n)for(const t of e){const e=[];ve(t,e,s,i,o,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===n){for(const e of u)l.push(le(t.id,n,e,t.tags));continue}"LineString"!==n&&"MultiLineString"!==n||(1===u.length?(n="LineString",u=u[0]):n="MultiLineString"),"Point"!==n&&"MultiPoint"!==n||(n=3===u.length?"Point":"MultiPoint"),l.push(le(t.id,n,u,t.tags));}}return l.length?l:null}function ye(e,t,s,i,o){for(let n=0;n=s&&r<=i&&xe(t,e[n],e[n+1],e[n+2]);}}function we(e,t,s,i,o,n,r){let a=be(e);const l=0===o?Se:Ie;let c,u,h=e.start;for(let d=0;d=s&&(u=l(a,f,p,m,y,s),r&&(a.start=h+c*u)):w>i?b<=i&&(u=l(a,f,p,m,y,i),r&&(a.start=h+c*u)):xe(a,f,p,g),b=s&&(u=l(a,f,p,m,y,s),v=!0),b>i&&w<=i&&(u=l(a,f,p,m,y,i),v=!0),!n&&v&&(r&&(a.end=h+c*u),t.push(a),a=be(e)),r&&(h+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===o?f:p;g>=s&&g<=i&&xe(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&xe(a,a[0],a[1],a[2]),a.length&&t.push(a);}function be(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ve(e,t,s,i,o,n){for(const r of e)we(r,t,s,i,o,n,!1);}function xe(e,t,s,i){e.push(t,s,i);}function Se(e,t,s,i,o,n){const r=(n-t)/(i-t);return xe(e,n,s+(o-s)*r,1),r}function Ie(e,t,s,i,o,n){const r=(n-s)/(o-s);return xe(e,t+(i-t)*r,n,1),r}function Me(e,t){const s=[];for(let i=0;i0&&t.size<(o?r:i))return void(s.numPoints+=t.length/3);const a=[];for(let e=0;er)&&(s.numSimplified++,a.push(t[e],t[e+1])),s.numPoints++;o&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t0===t)for(let t=0,s=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const s=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=ke(e,t,s,i,l),this.tileCoords.push({z:t,x:s,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,s,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==o){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===o)continue;if(null!=o){const e=o-t;if(s!==n>>e||i!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,p=.5-f,g=.5+f,m=1+f;let y=null,w=null,b=null,v=null;const x=me(e,u,s-f,s+g,0,d.minX,d.maxX,l),S=me(e,u,s+p,s+m,0,d.minX,d.maxX,l);x&&(y=me(x,u,i-f,i+g,1,d.minY,d.maxY,l),w=me(x,u,i+p,i+m,1,d.minY,d.maxY,l)),S&&(b=me(S,u,i-f,i+g,1,d.minY,d.maxY,l),v=me(S,u,i+p,i+m,1,d.minY,d.maxY,l)),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*s,2*i),a.push(w||[],t+1,2*s,2*i+1),a.push(b||[],t+1,2*s+1,2*i),a.push(v||[],t+1,2*s+1,2*i+1);}}getTile(e,t,s){e=+e,t=+t,s=+s;const i=this.options,{extent:o,debug:n}=i;if(e<0||e>24)return null;const r=1<1&&console.log("drilling down to z%d-%d-%d",e,t,s);let l,c=e,u=t,h=s;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ze(c,u,h)];return l&&l.source?(n>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,s),n>1&&console.timeEnd("drilling down"),this.tiles[a]?Te(this.tiles[a],o):null):null}}function ze(e,t,s){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,r=o.features.filter(e=>n(e));let a={_geojsonTileLayer:o.features};r.length>0&&(a={_geojsonTileLayer:o.features.filter(e=>!n(e)),hd_road_elevation:r});const l=new z(a),c=function(e){const s=new t.at;for(const t of Object.keys(e))s.writeMessage(3,N,{name:t,features:e[t]});return s.finish()}(a).buffer;s(null,{vectorTile:l,rawData:c});}class Be extends T{constructor(e){super(e),this.loadVectorData=je,this._dynamicIndex=new B;}loadData(e,i){const o=e&&e.request,n=o&&o.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(e,(r,a)=>{if(r||!a)return i(r);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{try{if(e.filter){const s=t.bY(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>s.value.evaluate({zoom:0},e));}e.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),e.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),e.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=e.cluster?new ee(function({superclusterOptions:e,clusterProperties:s}){if(!s||!e)return e;const i={},o={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(s);for(const e of a){const[n,r]=s[e],a=t.bY(r),l=t.bY("string"==typeof n?[n,["accumulated"],["get",e]]:n);i[e]=a.value,o[e]=l.value;}return e.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(n,r);return t},e.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=o[t].evaluate(n,r);},e}(e)).load(a.features):e.dynamic?this._dynamicIndex:function(e,t){return new Oe(e,t)}(a,e.geojsonVtOptions);}catch(e){return i(e)}const r={};if(n){const t=s(o);t&&(r.resourceTiming={},r.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)));}i(null,r);}});}reloadTile(e,t){const s=this.loaded;return s&&s[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(e,s){if(e.request)t.cT(e.request,s);else {if("string"!=typeof e.data)return s(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return s(null,JSON.parse(e.data))}catch(t){return s(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}},0);}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class Ee{constructor(e,s,i){this.tileID=new t.ap(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=e.projection,this.brightness=s,this.worldview=i;}parse(e,s,i,o){this.status="parsing";const n=new t.ap(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),r=[],a=s.familiesBySource[i.source],l=new t.I(n,i.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,t.e5(e).then(e=>{const s=e.json.extensionsUsed&&e.json.extensionsUsed.includes("MAPBOX_mesh_features")||e.json.asset.extras&&e.json.asset.extras.MAPBOX_mesh_features,c=e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new t.w(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const o in a)for(const h of a[o]){const o=h[0];l.bucketLayerIDs.push(h.map(e=>t.ea(e.id,e.scope))),o.recalculate(u,[]);const a=t.eV(e,1/t.fH(i.tileID.canonical)),d=new t.b1(h,a,n,s,c,this.brightness,l,this.worldview);s||(d.needsUpload=!0),r.push(d),d.evaluate(o);}this.status="done",o(null,{buckets:r,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null});}).catch(e=>o(new Error(e.message)));}}class Fe{constructor({actor:e,layerIndex:t,availableImages:s,availableModels:i,brightness:o,worldview:n}){this.actor=e,this.layerIndex=t,this.availableImages=s,this.availableModels=i,this.brightness=o,this.loading={},this.loaded={},this.worldview=n;}loadTile(e,s){const i=e.uid,o=this.loading[i]=new Ee(e,this.brightness,this.worldview);t.cG(e.request,(t,n)=>{const r=!this.loading[i];return delete this.loading[i],r||t?(o.status="done",r||(this.loaded[i]=o),s(t)):n&&0!==n.byteLength?void o.parse(n,this.layerIndex,e,(e,t)=>{o.status="done",this.loaded=this.loaded||{},this.loaded[i]=o,e||!t?s(e):s(null,t);}):(o.status="done",this.loaded[i]=o,s())});}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.projection=e.projection,o.brightness=e.brightness;const n=(s,i)=>{o.reloadCallback&&(delete o.reloadCallback,this.loadTile(e,t)),t(s,i);};"parsing"===o.status?o.reloadCallback=n:"done"===o.status&&this.loadTile(e,t);}}abortTile(e,t){const s=e.uid;this.loading[s]&&delete this.loading[s],t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class Ae{constructor(e){this.self=e,this.actor=new t.a(e,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=t.c$({name:"mercator"}),this.workerSourceTypes={vector:T,geojson:Be,"raster-dem":P,"raster-array":_,"batched-model":Fe},this.workerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=e=>{if(t.eH.isParsed())throw new Error("RTL text plugin already registered.");t.eH.setState({pluginStatus:t.f7.parsed,pluginURL:t.eH.getPluginURL()}),t.eH.applyArabicShaping=e.applyArabicShaping,t.eH.processBidirectionalText=e.processBidirectionalText,t.eH.processStyledBidirectionalText=e.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[];};}clearCaches(e,t,s){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],s();}checkIfReady(e,t,s){s();}setReferrer(e,t){this.referrer=t;}spriteLoaded(e,s){this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={});const{scope:i,isLoaded:o}=s;if(this.isSpriteLoaded[e][i]=o,this.workerSources[e]&&this.workerSources[e][i])for(const s in this.workerSources[e][i]){const n=this.workerSources[e][i][s];for(const e in n){const s=n[e];s instanceof T&&(s.isSpriteLoaded=o,s.fire(new t.x("isSpriteLoaded")));}}}setImages(e,t,s){this.availableImages[e]||(this.availableImages[e]={});const{scope:i,images:o}=t;if(this.availableImages[e][i]=o,this.workerSources[e]&&this.workerSources[e][i]){for(const t in this.workerSources[e][i]){const s=this.workerSources[e][i][t];for(const e in s)s[e].availableImages=o;}s();}else s();}setModels(e,{scope:t,models:s},i){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=s,this.workerSources[e]&&this.workerSources[e][t]){for(const i in this.workerSources[e][t]){const o=this.workerSources[e][t][i];for(const e in o)o[e].availableModels=s;}i();}else i();}setProjection(e,s){this.projections[e]=t.c$(s);}setBrightness(e,t,s){this.brightness=t,s();}setContextParams(e,t,s){this.maxUniformBufferBindings=t.maxBindingPoints,this.maxUniformBlockSizeDwords=t.maxUniformBlockSizeDwords,this.disableSymbolUBO=t.disableSymbolUBO,s();}setWorldview(e,t,s){this.worldview=t,s();}setLayers(e,t,s){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),s();}updateLayers(e,t,s){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),s();}loadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).loadTile(t,s);}decodeRasterArray(e,t,s){this.getWorkerSource(e,t).decodeRasterArray(t,s);}reloadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).reloadTile(t,s);}abortTile(e,t,s){this.getWorkerSource(e,t).abortTile(t,s);}removeTile(e,t,s){this.getWorkerSource(e,t).removeTile(t,s);}removeSource(e,t,s){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const i=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==i.removeSource?i.removeSource(t,s):s();}loadTileProvider(e,s,i){t.e8(s.name,s.url).then(t=>{const i=new t(s.options);return this.getWorkerSource(e,{type:s.type,source:s.source,scope:s.scope},i),i.load&&s.request?i.load({request:s.request}):null}).then(e=>i(null,e)).catch(e=>i(e instanceof Error?e:new Error(String(e))));}async syncRTLPluginState(e,s,i){if(t.eH.isParsed())return void i(null,!0);if(t.eH.isParsing())return void this.rtlPluginParsingListeners.push(i);t.eH.setState(s);const o=t.eH.getPluginURL();if(!t.eH.isLoaded()||t.eH.isParsed()||t.eH.isParsing())i(null,!1);else {t.eH.setState({pluginStatus:t.f7.parsing,pluginURL:o});try{await import( +define(["require","./shared"],function(e,t){function s(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e,s){if(Object.hasOwn(e.layers,t.fy))return t.fz.parseFrom(e.layers[t.fy],s)}function o({buckets:e,data:s,sourceLayerCoder:i,canonical:o,options:n}){if(!n.elevationFeatures||0===n.elevationFeatures.length)return;const r=[];for(const s of Object.values(e))if(s instanceof t.c_&&s.hdExt){const e=s.hdExt.getUnevaluatedPortalGraph();e&&r.push(e);}const a=t.fA.evaluate(r);for(const r of Object.values(e))if(r instanceof t.c_&&r.hdExt){const e=s.layers[i.decode(r.sourceLayerIndex)];r.hdExt.setEvaluatedPortalGraph(a,e,o,n.availableImages,n.brightness,r.worldview);}}function n(e){const s=[];for(let i=0;i0){let e=!1;for(const s of a[0])if(s.x<0||s.x>t.aj||s.y<0||s.y>t.aj){e=!0;break}if(e)continue}const l=1===a.length&&5===a[0].length&&a[0].some(e=>e.x<=0&&e.y<=0)&&a[0].some(e=>e.x>=t.aj&&e.y<=0)&&a[0].some(e=>e.x>=t.aj&&e.y>=t.aj)&&a[0].some(e=>e.x<=0&&e.y>=t.aj);s.push(new t.fB(r,l?[]:a));}return s}function r(e,s,i,o,n){const r=t.fC(s);if(null===r)return !1;let a=i.x,l=i.y;const c=null!=n?n:o.z;if(o.z!==c){const e=1<e.map(e=>[e.x,e.y]));if(t.fD([a,l],e))return !0}return !1}function a(e,s,i,o){const n=s.indoorState.activeFloorsVisible;if(!s.sourceLayers)return n?s.indoorState.activeFloors:void 0;const r=function(e,s){if(!e)return t.w("No source layers defined in indoor specification"),s;if(0===e.size)return s;const i=e.difference(s);for(const e of i)t.w(`Missing source layer required in indoor specification: ${e}`);return s.intersection(s)}(s.sourceLayers,new Set(Object.keys(e.layers))),a=s.indoorState,d=function(e,s,i,o,n){const r={};for(const i of s){const s=e.layers[i];if(s)for(let e=0;ei.map(i=>t.fE(i,s,e.extent)));return 0===o.length?void 0:{type:"Polygon",coordinates:[o[0]]}}(e,s);return {id:i,isDefault:o,connections:n,conflicts:r,buildings:a,name:l,zIndex:c,geometry:u}}function d(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function f(e){return d(e,["type","id","name"])&&"structure"===e.properties.type}function p(e){return d(e,["type","id","name","z_index"])&&"floor"===e.properties.type}function g(e,s){e instanceof t.c_?t.fF(e,s):e instanceof t.cZ?t.fG(e,s):e instanceof t.fH?t.fI(e):e instanceof t.cT&&t.fJ(e);}function m(e){for(const s in e){const i=e[s];if(i instanceof t.cZ&&i.hdExt&&i.hdExt.hasDeferredElevationFeatures)return !0;if(i instanceof t.cT&&i.hdExt&&i.hdExt.hasDeferredElevationFeatures)return !0}return !1}function y(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const s of e)t+=`${y(s)},`;return `${t}]`}let t="{";for(const s of Object.keys(e).sort())t+=`${s}:${y(e[s])},`;return `${t}}`}function w(e){let s="";for(const i of t.dX)s+=`/${y(e[i])}`;return s}function v(e,t){return function e(s){return "string"==typeof s&&s===t||(Array.isArray(s)?s.some(e):!(!s||"object"!=typeof s)&&Object.values(s).some(e))}(e)}class b{constructor(e){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),e&&this.replace(e);}replace(e,t){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(e,[],t);}update(e,s,i){this._options=i;for(const s of e)this._layerConfigs[s.id]=s,(this._layers[s.id]=t.ep(s,this.scope,null,this._options)).compileFilter(i),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource=Object.create(null);const o=function(e,t){const s=Object.create(null);for(let i=0;ithis._layers[e.id]),s=t[0];if("none"===s.visibility)continue;const i=s.source||"";let o=this.familiesBySource[i];o||(o=this.familiesBySource[i]=Object.create(null));const n=s.sourceLayer||"_geojsonTileLayer";let r=o[n];r||(r=o[n]=[]),r.push(t);}}}const x=1*t.fM;class S{constructor(e){const s={},i=[];for(const t in e){const o=e[t],n=s[t]={};for(const e in o.glyphs){const t=o.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?x:1,r={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};i.push(r),n[e]=r;}}const{w:o,h:n}=t.H(i),r=new t.fL({width:o||1,height:n||1});for(const i in e){const o=e[i];for(const e in o.glyphs){const n=o.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=s[i][e],l=n.metrics.localGlyph?x:1;t.fL.copy(n.bitmap,r,{x:0,y:0},{x:a.x+l,y:a.y+l},n.bitmap);}}this.image=r,this.positions=s;}}function I(e){for(const t of e){if(null!=t.hdExt)return !0;if(t.requiresHDRuntime)return !0}return !1}function M(e){for(const t of e)if(t.requiresStandardRuntime)return !0;return !1}function T(e,s,i){const o=null!=e&&!!t.fQ&&t.fQ(e.sourceLayers,s,i);return {applies:o,frcMask:o&&e?e.frcMask:null,polygons:o&&e?e.polygons:null,tileZoom:o&&e?e.tileZoom:null}}t.fK(S,"GlyphAtlas");class P{constructor(e){this.tileID=new t.br(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.lut=e.lut,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.collectResourceTiming=!!e.request&&e.request.collectResourceTiming,this.promoteId=e.promoteId,this.renderSourceType=e.renderSourceType,this.frcCoverage=e.frcCoverage||null,this.elevation=e.elevation||null,this.crossSourceElevationEnabled=!!e.crossSourceElevationEnabled,this.terrainEnabled=!!e.terrainEnabled,this.deferRoadStructure=!1,this.tileTransform=t.cO(e.tileID.canonical,e.projection),this.projection=e.projection,this.worldview=e.worldview,this.localizableLayerIds=e.localizableLayerIds,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster,this.tessellationStep=e.tessellationStep,this.scaleFactor=e.scaleFactor,this.worldview=e.worldview,this.indoor=e.indoor;}isLayerActiveForTile(e){return !(this.renderSourceType===t.dA.Symbol&&"symbol"!==e.type||this.renderSourceType===t.dA.FillExtrusion&&"fill-extrusion"!==e.type||this.renderSourceType===t.dA.Other&&("symbol"===e.type||"fill-extrusion"===e.type)||this.renderSourceType===t.dA.HdRoadElevation||e.minzoom&&this.zoom=e.maxzoom||"none"===e.visibility)}parse(e,t,s,i,o,n){this._parseAfterHD(e,t,s,i,o,n);}_parseAfterHD(e,s,l,c,u,h){let d;if(this.status="parsing",this.data=e,this.renderSourceType===t.dA.HdRoadCoverage){const s=e.layers[t.dC];d=s&&n?n(s):[];}this.collisionBoxArray=new t.cS;const f=new t.fN(Object.keys(e.layers).sort()),p=new t.fO(this.tileID,this.promoteId);p.bucketLayerIDs=[];const y={},w=new t.fP(256,256),v={featureIndex:p,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:w,availableImages:l,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,elevationParams:this.elevation,crossSourceElevationEnabled:this.crossSourceElevationEnabled,terrainEnabled:this.terrainEnabled,activeFloors:void 0};this.indoor&&a&&(v.activeFloors=a(e,this.indoor,u,this.canonical));const b=[],x=s.familiesBySource[this.source];if(this.renderSourceType===t.dA.HdRoadElevation){const t=i&&i(e,this.canonical)||[],s=new S({});return this.status="done",void h(null,{buckets:[],containsHdExt:!1,containsStandardExt:!1,featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:s.image,lineAtlas:w,imageAtlas:null,brightness:this.brightness,parsedElevationFeatures:t})}if(this.deferRoadStructure=!1,this.renderSourceType!==t.dA.HdRoadCoverage&&null!=this.frcCoverage&&!this.frcCoverage.resolved&&null===this.frcCoverage.frcMask)for(const e in x)if(t.fQ&&t.fQ(this.frcCoverage.sourceLayers,this.source,e)){this.deferRoadStructure=!0;break}for(const s in x){const o=e.layers[s];if(!o)continue;let n=!1,r=!1,a=!1,u=!1;for(const e of x[s])"symbol"===e[0].type?n=!0:"fill-extrusion"===e[0].type?r=!0:a=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(this.renderSourceType===t.dA.Symbol&&!n)continue;if(this.renderSourceType===t.dA.FillExtrusion&&!r)continue;if((this.renderSourceType===t.dA.Other||this.renderSourceType===t.dA.HdRoadCoverage)&&!a)continue;const h=null!=this.frcCoverage&&!!t.fQ&&t.fQ(this.frcCoverage.sourceLayers,this.source,s);if(this.deferRoadStructure&&h)continue;1===o.version&&t.w(`Vector tile source "${this.source}" layer "${s}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=f.encode(s),m=[],w=this.localizableLayerIds&&this.localizableLayerIds.has(s);let S=!1;for(let e=0,i=0;et.y(e.id,e.scope)));const n=()=>{const t=y[i.id]=i.createBucket({index:o,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceLayerName:s,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:c,worldview:this.worldview,localizable:w,availableImages:l,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords});g&&g(t,this.frcCoverage?this.frcCoverage.sourceLayers:null),t.populate(m,v,this.tileID.canonical,this.tileTransform);};i.mayUse("HD")||i.mayUse("Standard")?b.push(i.prepare().then(()=>n())):n();}}const P=()=>{w.trim();const s=!(!v.elevationFeatures||!v.elevationFeatures.some(e=>e.heightRange.min<0));let i,n,a,c,g,b,x;const P={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},_=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster){this.status="done";const e=Object.values(y).filter(e=>!e.isEmpty()),t=v.elevationFeatures;h(null,{buckets:e,containsHdExt:I(e),containsStandardExt:M(e),featureIndex:p,collisionBoxArray:null,hasTunnelGeometry:s,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:v.brightness,hasDeferredElevationFeatures:!!m&&m(y),parsedElevationFeatures:t,glyphMap:null,iconMap:null,glyphPositions:null});}else if(n&&a&&c&&x){const e=void 0,s=new S(n),i=new Map;for(const[e,s]of a.entries()){const{imagePosition:o}=t.fU(e,s,t.fV);i.set(e,o);}const o={};for(const e in y){const c=y[e];if(c instanceof t.cT){k(c.layers,this.zoom,v.brightness,l,this.worldview,v.activeFloors);const u=T(this.frcCoverage,this.source,c.layers[0].sourceLayer);o[e]=t.fW(c,n,s.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,g,this.worldview,l,u.frcMask,u.polygons,u.tileZoom,t.fS||null,r||null);}}g.size||b.size?this.rasterizeTask=u.sendCancelable("rasterizeImages",{scope:this.scope,iconTasks:g,patternTasks:b},{},(t,i)=>{if(!t)for(const[e,t]of i.entries())a.has(e)&&a.set(e,Object.assign(a.get(e),{data:t})),c.has(e)&&c.set(e,Object.assign(c.get(e),{data:t}));C(o,s,e,x);}):C(o,s,e,x);}},C=(e,i,o,n)=>{const r=a.size>0||c.size>0,f=Object.keys(e).length>0,g=v.elevationFeatures;if(!r&&!f){this.status="done";const e=Object.values(y).filter(e=>!e.isEmpty());return void h(null,{buckets:e,containsHdExt:I(e),containsStandardExt:M(e),featureIndex:p,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:s,glyphAtlasImage:i.image,lineAtlas:w,imageAtlas:null,brightness:v.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:d,hasDeferredElevationFeatures:!!m&&m(y),parsedElevationFeatures:g})}const b=(o,n)=>{for(const s in y){const i=y[s];if(s in e)t.f$(i,e[s],this.showCollisionBoxes,l,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,n);else if(i.hasPattern&&(i instanceof t.cZ||i instanceof t.c_||i instanceof t.cB)){k(i.layers,this.zoom,v.brightness,l,this.worldview,v.activeFloors);const e=Object.fromEntries(n.patternPositions);i.addFeatures(v,this.tileID.canonical,e,l,this.tileTransform,this.brightness);}}this.status="done";const r=Object.values(y).filter(e=>!e.isEmpty());h(null,{buckets:r,containsHdExt:I(r),containsStandardExt:M(r),featureIndex:p,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:s,glyphAtlasImage:i.image,lineAtlas:w,imageAtlas:o,brightness:v.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:d,hasDeferredElevationFeatures:!!m&&m(y),parsedElevationFeatures:g});};if(r){const e=new Map,s=t.fX(a,e),i=t.fX(c,e),o=new t.fY(s,i,n,this.lut,this.scope,e);u.send("checkAtlasCache",{descriptor:o,scope:this.scope}).then(e=>{let s,i;if(e)s=new t.fZ(e.sourceHash),i=e;else {const e=new t.f_(a,c,this.lut,n,this.scope);s=e,i=e;}b(s,i);}).catch(e=>{"AbortError"!==e.name&&t.w(`[Worker] Error checking atlas cache: ${e.message}`);const s=new t.f_(a,c,this.lut,n,this.scope);b(s,s);});}else b(null,{iconPositions:new Map,patternPositions:new Map});};if(!this.extraShadowCaster){const e=t.fT(v.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?u.send("getGlyphs",{uid:this.uid,stacks:e},{metadata:P}).then(e=>{i||(n=e,_());}).catch(e=>{i||(i=e,_());}):n={},x=new Map;const s=Array.from(v.iconDependencies.keys()).map(e=>t.I.parse(e)),o=Array.from(v.patternDependencies.keys()).map(e=>t.I.parse(e));s.length||o.length?u.send("getImages",{icons:s,patterns:o,source:this.source,scope:this.scope,tileID:this.tileID},{metadata:P}).then(e=>{if(!i){a=new Map,c=new Map,g=this.updateImageMapAndGetImageTaskQueue(a,e.images,v.iconDependencies),b=this.updateImageMapAndGetImageTaskQueue(c,e.images,v.patternDependencies);for(const[t,s]of e.versions.entries())x.set(t,s);_();}}).catch(e=>{i||(i=e,_());}):(a=new Map,c=new Map,g=new Map,b=new Map);}o&&o({buckets:y,data:e,sourceLayerCoder:f,canonical:this.tileID.canonical,options:v}),_();};b.length>0?Promise.allSettled(b).then(P).catch(h):P();}updateParameters(e){this.scaleFactor=e.scaleFactor,this.showCollisionBoxes=e.showCollisionBoxes,this.showElevationIdDebug=e.showElevationIdDebug,this.projection=e.projection,this.brightness=e.brightness,this.tileTransform=t.cO(e.tileID.canonical,e.projection),this.extraShadowCaster=e.extraShadowCaster,this.lut=e.lut,this.worldview=e.worldview,this.indoor=e.indoor,this.frcCoverage=e.frcCoverage||null,this.elevation=e.elevation||null,this.terrainEnabled=!!e.terrainEnabled;}updateImageMapAndGetImageTaskQueue(e,t,s){const i=new Map;for(const o of t.keys()){const n=s.get(o)||[];for(const s of n){const o=s.toString(),n=t.get(s.id.toString());n.usvg?i.has(o)||(i.set(o,s),e.set(o,{...n})):e.set(o,n);}}return i}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.abort();}}function k(e,s,i,o,n,r){const a=new t.aa(s,{brightness:i,worldview:n,activeFloors:r});for(const t of e)t.recalculate(a,o);}class _ extends t.E{constructor({actor:e,layerIndex:s,availableImages:i,availableModels:o,isSpriteLoaded:n,tileProvider:r,brightness:a,maxUniformBufferBindings:l,maxUniformBlockSizeDwords:c}){super(),this.actor=e,this.layerIndex=s,this.availableImages=i,this.availableModels=o,this.loadVectorData=t.dO,this.tileProvider=r,this.loading={},this.loaded={},this.deduped=new t.dN(e.scheduler),this.isSpriteLoaded=n,this.scheduler=e.scheduler,this.brightness=a,this.maxUniformBufferBindings=l,this.maxUniformBlockSizeDwords=c;}loadTileData(e,t){if(!this.tileProvider)return this.loadVectorData(e,t);const s=new AbortController;return this.loadTileWithProvider(this.tileProvider,e,s,t),()=>s.abort()}async loadTileWithProvider(e,t,s,i){const{z:o,x:n,y:r}=t.tileID.canonical;try{const a=await e.loadTile({z:o,x:n,y:r},{request:t.request,signal:s.signal});if(s.signal.aborted)return;if(null==a){const e=new Error("Tile not found");return e.status=404,i(e)}if(null==a.data)return i(null,null);if(a.data instanceof ImageBitmap)return i(new Error("Vector tiles require ArrayBuffer data"));const l=new Headers;a.expires&&l.set("expires",a.expires),a.cacheControl&&l.set("cache-control",a.cacheControl),i(null,{rawData:a.data,headers:l});}catch(e){if(s.signal.aborted)return;i(e instanceof Error?e:new Error(String(e)));}}_fetchTileData(e,t){return new Promise((s,i)=>{e.abort=this.loadTileData(t,(e,t)=>{e?i(e):s(t);});})}async _parse(e,t){const s=!this.isSpriteLoaded;return s&&await this.once("isSpriteLoaded"),new Promise((i,o)=>{const n=()=>e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,t)=>{e?o(e):i(t);});s&&this.scheduler?this.scheduler.add(n,{type:"parseTile",renderSourceType:t.renderSourceType,zoom:t.tileZoom}):n();})}async loadTile(e){const i=e.uid,o=e&&e.request,n=o&&o.collectResourceTiming,r=this.loading[i]=new P(e);r.maxUniformBufferBindings=this.maxUniformBufferBindings,r.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords;const a=(e,t)=>{const s=r.reloadCallback;s&&(delete r.reloadCallback,e||!t?s(e,null):r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,s));};let l,c;try{l=await this._fetchTileData(r,e);}catch(e){c=e;}const u=!this.loading[i];if(delete this.loading[i],r.cancelRasterize(),c||u||!l){if(r.status="done",u||(this.loaded[i]=r),c)throw c;return null}const h=l.rawData;let d;r.vectorTile=l.vectorTile||new t.g0(new t.d9(h)),this.loaded=this.loaded||{},this.loaded[i]=r;try{d=await this._parse(r,e);}catch(e){throw a(e),e}if(!d)return a(null,null),null;const f={};if(n){const e=s(o);e.length>0&&(f.resourceTiming=JSON.parse(JSON.stringify(e)));}const p={rawTileData:h.slice(0),headers:l.headers,...d,...f};return a(null,d),p}async reloadTile(e){const t=this.loaded,s=e.uid;if(t&&t[s])return new Promise((i,o)=>{const n=t[s];n.updateParameters(e);const r=(e,t)=>{const s=n.reloadCallback;s&&(delete n.reloadCallback,n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,s)),e?o(e):i(t);};"parsing"===n.status?n.reloadCallback=r:"done"===n.status?n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,r):r():i(void 0);})}abortTile(e){const t=e.uid,s=this.loading[t];s&&(s.abort&&s.abort(),delete this.loading[t]);}removeTile(e){const t=this.loaded,s=e.uid;t&&t[s]&&delete t[s];}}class C{constructor(e){this.tileProvider=e.tileProvider,this.loading={};}async loadTile(e){const s=e.uid,i=new AbortController;if(this.loading[s]={cancel:()=>i.abort()},this.tileProvider)return this.loadTileWithProvider(this.tileProvider,s,e,i);try{const{data:o,headers:n}=await t.da(e.request,i.signal);if(!o)return null;const r=await this.decodeTile(s,o,e.encoding);return r.headers=n,r}catch(e){if(i.signal.aborted)return null;throw e}finally{delete this.loading[s];}}async decodeTile(e,s,i){const o=s instanceof ImageBitmap?s:await createImageBitmap(new Blob([new Uint8Array(s)],{type:"image/png"})),n=1-(o.width-t.g1(o.width))/2,r=n<1,a=this.getImageData(o,n);return o.close(),{dem:new t.g2(e,a,i,r),borderReady:r}}async loadTileWithProvider(e,t,s,i){const{z:o,x:n,y:r}=s.tileID.canonical;try{const a=await e.loadTile({z:o,x:n,y:r},{request:s.request,signal:i.signal});if(i.signal.aborted)return null;if(null==a){const e=new Error("Tile not found");throw e.status=404,e}if(null==a.data)return null;const l=await this.decodeTile(t,a.data,s.encoding);if(i.signal.aborted)return null;const c=new Headers;return a.expires&&c.set("expires",a.expires),a.cacheControl&&c.set("cache-control",a.cacheControl),l.headers=c,l}catch(e){if(i.signal.aborted)return null;throw e}finally{delete this.loading[t];}}async reloadTile(e){}abortTile(e){const t=e.uid,s=this.loading[t];s&&(s.cancel(),delete this.loading[t]);}removeTile(e){}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const s=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),s}}t.d8.setPbf(t.d9);class D{constructor(e){this._mrt=new t.d8(e.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=e.uid,this.tileID=e.tileID,this.source=e.source;}async parse(e){const s=this._mrt;this.status="parsing",this._entireBuffer=e,s.parseHeader(e),this._isHeaderLoaded=!0;const i=[];for(const o in s.layers){const n=s.getLayer(o),r=n.getDataRange(n.getBandList()),a=s.createDecodingTask(r),l=e.slice(r.firstByte,r.lastByte+1);i.push(t.d8.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null)));}return await Promise.allSettled(i),s}}class j{constructor({actor:e}){this.actor=e,this.loading={},this.loaded={};}async loadTile(e){const s=e.uid,i=new AbortController,o=this.loading[s]=new D(e);o.abort=()=>i.abort();try{const{data:n,headers:r}=await t.da(e.request,i.signal);return n?(this.loaded[s]=o,{mrt:await o.parse(n),headers:r}):(o.status="done",this.loaded[s]=o,null)}catch(e){if(i.signal.aborted)return null;throw o.status="done",this.loaded[s]=o,e}finally{delete this.loading[s];}}async reloadTile(e){}abortTile(e){const t=e.uid,s=this.loading[t];s&&(s.abort&&s.abort(),delete this.loading[t]);}removeTile(e){const t=e.uid;this.loaded[t]&&delete this.loaded[t];}async decodeRasterArray(e){return t.d8.performDecoding(e.buffer,e.task)}}const L=t.g3.prototype.toGeoJSON;class E{constructor(e){this._feature=e,this.extent=t.aj,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 s of this._feature.geometry)e.push([new t.P(s[0],s[1])]);return e}{const e=[];for(const s of this._feature.geometry){const i=[];for(const e of s)i.push(new t.P(e[0],e[1]));e.push(i);}return e}}toGeoJSON(e,t,s){return L.call(this,e,t,s)}}class z{constructor(e,s){this.name=e,this.extent=t.aj,this.length=s.length,this._jsonFeatures=s;}feature(e){return new E(this._jsonFeatures[e])}}class O{constructor(e){this.layers={},this.extent=t.aj;for(const t of Object.keys(e))this.layers[t]=new z(t,e[t]);}}const A=64/4096;class F{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const s of e){const e=s.id;if(null==e)continue;let i=this.features.get(e);i&&this.updateCache(i,t),s.geometry?(i=R(s),this.updateCache(i,t),this.features.set(e,i)):this.features.delete(e),this.updateCache(i,t);}}updateCache(e,t){for(const{canonical:s,uid:i}of Object.values(t)){const{z:o,x:n,y:r}=s;B(e,Math.pow(2,o),n,r)&&delete t[i];}}getTile(e,t,s){const i=Math.pow(2,e),o=[];for(const e of this.features.values())B(e,i,t,s)&&o.push(X(e,i,t,s));return {features:o}}getFeatures(){return [...this.features.values()]}}function B({minX:e,minY:t,maxX:s,maxY:i},o,n,r){return e<(n+1+A)/o&&t<(r+1+A)/o&&s>(n-A)/o&&i>(r-A)/o}function R(e){const{id:t,geometry:s,properties:i}=e;if(!s)return;if("GeometryCollection"===s.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:o,coordinates:n}=s,r={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===o)Z(n,a,r);else if("MultiPoint"===o)for(const e of n)Z(e,a,r);else if("LineString"===o)r.type=2,U(n,a,r);else if("MultiLineString"===o)r.type=2,N(n,a,r);else if("Polygon"===o)r.type=3,N(n,a,r,!0);else {if("MultiPolygon"!==o)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of n)N(e,a,r,!0);}return r}function Z([e,s],i,o){const n=t.a_(e);let r=t.a$(s);r=r<0?0:r>1?1:r,i.push(n,r),o.minX=Math.min(o.minX,n),o.minY=Math.min(o.minY,r),o.maxX=Math.max(o.maxX,n),o.maxY=Math.max(o.maxY,r);}function U(e,t,s,i=!1,o=!1){const n=[];for(const t of e)Z(t,n,s);t.push(n),i&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t0===t)for(let t=0,s=e.length;t=a&&d>=a||(u>=a?(h+=Math.round(g*((a-u)/p)),u=a):d>=a&&(f=h+Math.round(g*((a-u)/p)),d=a),h>=a&&f>=a||(h>=a?(u+=Math.round(p*((a-h)/g)),h=a):f>=a&&(d=u+Math.round(p*((a-h)/g)),f=a),l&&u===l.at(-1)[0]&&h===l.at(-1)[1]||(l=[[u,h]],n.push(l)),l.push([d,f])))));}}function G(e,s,i,o,n){const r=(i-A)/s,a=(o-A)/s,l=(i+1+A)/s,c=(o+1+A)/s;function u(e,t){let s=0;return el&&(s|=2),tc&&(s|=8),s}let h=[];for(let t=1;t<=8;t*=2){let s=e[e.length-2],i=e.at(-1),o=!(u(s,i)&t);for(let n=0;n>31}function W(e,t){const{geometry:s,type:i}=e;let o=0,n=0;if(1===i){t.writeVarint(H(1,s.length));for(const e of s){const s=e[0]-o,i=e[1]-n;t.writeVarint(V(s)),t.writeVarint(V(i)),o+=s,n+=i;}}else for(const e of s){if(0===e.length)continue;t.writeVarint(H(1,1));const s=e.length-(3===i?1:0);for(let i=0;ie},ee=Math.fround||(te=new Float32Array(1),e=>(te[0]=+e,te[0]));var te;class se{constructor(e){this.options=Object.assign(Object.create(K),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:s,maxZoom:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const n=[];for(let t=0;t=s;e--){const s=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log("z%d: %d clusters in %dms",e,r.numItems,+Date.now()-s);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let o=180===e[2]?180:((e[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,o=180;else if(s>o){const e=this.getClusters([s,i,180,n],t),r=this.getClusters([-180,i,o,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(ne(s),re(n),ne(o),re(i)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?ie(l,t,this.clusterProps):this.points[l[t+3]]);}return c}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),i="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(i);const n=o.data;if(t*this.stride>=n.length)throw new Error(i);const r=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=o.within(n[t*this.stride],n[t*this.stride+1],r),l=[];for(const t of a){const s=t*this.stride;n[s+4]===e&&l.push(n[s+5]>1?ie(n,s,this.clusterProps):this.points[n[s+3]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,s){const i=[];return this._appendLeaves(i,e,t=t||10,s=s||0,0),i}getTile(e,t,s){const i=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(s-a)/o,c=(s+1+a)/o,u={features:[]};return this._addTileFeatures(i.range((t-a)/o,l,(t+1+a)/o,c),i.data,t,s,o,u),0===t&&this._addTileFeatures(i.range(1-a/o,l,1,c),i.data,o,s,o,u),t===o-1&&this._addTileFeatures(i.range(0,l,a/o,c),i.data,-1,s,o,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,1!==s.length)break;e=s[0].properties.cluster_id;}return t}_appendLeaves(e,t,s,i,o){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?o+n.point_count<=i?o+=n.point_count:o=this._appendLeaves(e,n.cluster_id,s,i,o):o1;let l,c,u;if(a)l=oe(t,e,this.clusterProps),c=t[e],u=t[e+1];else {const s=this.points[t[e+3]];l=s.properties;const[i,o]=s.geometry.coordinates;c=ne(i),u=re(o);}const h={type:1,geometry:[[Math.round(this.options.extent*(c*o-s)),Math.round(this.options.extent*(u*o-i))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),n.features.push(h);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:i,reduce:o,minPoints:n}=this.options,r=s/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let s=0;st&&(f+=a[s+5]);}if(f>d&&f>=n){let e,n=i*d,r=u*d,p=-1;const g=(s/c<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];n+=a[l]*u,r+=a[l+1]*u,a[l+4]=g,o&&(e||(e=this._map(a,s,!0),p=this.clusterProps.length,this.clusterProps.push(e)),o(e,this._map(a,l)));}a[s+4]=g,l.push(n/f,r/f,1/0,g,-1,f),o&&l.push(p);}else {for(let e=0;e1)for(const e of h){const s=e*c;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+5]>1){const i=this.clusterProps[e[t+6]];return s?Object.assign({},i):i}const i=this.points[e[t+3]].properties,o=this.options.map(i);return s&&o===i?Object.assign({},o):o}}function ie(e,t,s){return {type:"Feature",id:e[t+3],properties:oe(e,t,s),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),ae(e[t+1])]}};var i;}function oe(e,t,s){const i=e[t+5],o=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,n=e[t+6],r=-1===n?{}:Object.assign({},s[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:o})}function ne(e){return e/360+.5}function re(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function ae(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function le(e,t,s,i){let o=i;const n=t+(s-t>>1);let r,a=s-t;const l=e[t],c=e[t+1],u=e[s],h=e[s+1];for(let i=t+3;io)r=i,o=t;else if(t===o){const e=Math.abs(i-n);ei&&(r-t>3&&le(e,t,r,i),e[r+2]=o,s-r>3&&le(e,r,s,i));}function ce(e,t,s,i,o,n){let r=o-s,a=n-i;if(0!==r||0!==a){const l=((e-s)*r+(t-i)*a)/(r*r+a*a);l>1?(s=o,i=n):l>0&&(s+=r*l,i+=a*l);}return r=e-s,a=t-i,r*r+a*a}function ue(e,t,s,i){const o={id:e??null,type:t,geometry:s,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)he(o,s);else if("Polygon"===t)he(o,s[0]);else if("MultiLineString"===t)for(const e of s)he(o,e);else if("MultiPolygon"===t)for(const e of s)he(o,e[0]);return o}function he(e,t){for(let s=0;s0&&(r+=i?(o*l-a*n)/2:Math.sqrt(Math.pow(a-o,2)+Math.pow(l-n,2))),o=a,n=l;}const a=t.length-3;t[2]=1,le(t,0,a,s),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function ge(e,t,s,i){for(let o=0;o1?1:s}function we(e,t,s,i,o,n,r,a){if(i/=t,n>=(s/=t)&&r=i)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===o?t.minX:t.minY,c=0===o?t.maxX:t.maxY;if(r>=s&&c=i)continue;let u=[];if("Point"===n||"MultiPoint"===n)ve(e,u,s,i,o);else if("LineString"===n)be(e,u,s,i,o,!1,a.lineMetrics);else if("MultiLineString"===n)Se(e,u,s,i,o,!1);else if("Polygon"===n)Se(e,u,s,i,o,!0);else if("MultiPolygon"===n)for(const t of e){const e=[];Se(t,e,s,i,o,!0),e.length&&u.push(e);}if(u.length){if(a.lineMetrics&&"LineString"===n){for(const e of u)l.push(ue(t.id,n,e,t.tags));continue}"LineString"!==n&&"MultiLineString"!==n||(1===u.length?(n="LineString",u=u[0]):n="MultiLineString"),"Point"!==n&&"MultiPoint"!==n||(n=3===u.length?"Point":"MultiPoint"),l.push(ue(t.id,n,u,t.tags));}}return l.length?l:null}function ve(e,t,s,i,o){for(let n=0;n=s&&r<=i&&Ie(t,e[n],e[n+1],e[n+2]);}}function be(e,t,s,i,o,n,r){let a=xe(e);const l=0===o?Me:Te;let c,u,h=e.start;for(let d=0;d=s&&(u=l(a,f,p,m,y,s),r&&(a.start=h+c*u)):w>i?v<=i&&(u=l(a,f,p,m,y,i),r&&(a.start=h+c*u)):Ie(a,f,p,g),v=s&&(u=l(a,f,p,m,y,s),b=!0),v>i&&w<=i&&(u=l(a,f,p,m,y,i),b=!0),!n&&b&&(r&&(a.end=h+c*u),t.push(a),a=xe(e)),r&&(h+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===o?f:p;g>=s&&g<=i&&Ie(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&Ie(a,a[0],a[1],a[2]),a.length&&t.push(a);}function xe(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Se(e,t,s,i,o,n){for(const r of e)be(r,t,s,i,o,n,!1);}function Ie(e,t,s,i){e.push(t,s,i);}function Me(e,t,s,i,o,n){const r=(n-t)/(i-t);return Ie(e,n,s+(o-s)*r,1),r}function Te(e,t,s,i,o,n){const r=(n-s)/(o-s);return Ie(e,t+(i-t)*r,n,1),r}function Pe(e,t){const s=[];for(let i=0;i0&&t.size<(o?r:i))return void(s.numPoints+=t.length/3);const a=[];for(let e=0;er)&&(s.numSimplified++,a.push(t[e],t[e+1])),s.numPoints++;o&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t0===t)for(let t=0,s=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=function(e,t){const s=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[h]=De(e,t,s,i,l),this.tileCoords.push({z:t,x:s,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,s,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==o){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===o)continue;if(null!=o){const e=o-t;if(s!==n>>e||i!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,p=.5-f,g=.5+f,m=1+f;let y=null,w=null,v=null,b=null;const x=we(e,u,s-f,s+g,0,d.minX,d.maxX,l),S=we(e,u,s+p,s+m,0,d.minX,d.maxX,l);x&&(y=we(x,u,i-f,i+g,1,d.minY,d.maxY,l),w=we(x,u,i+p,i+m,1,d.minY,d.maxY,l)),S&&(v=we(S,u,i-f,i+g,1,d.minY,d.maxY,l),b=we(S,u,i+p,i+m,1,d.minY,d.maxY,l)),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*s,2*i),a.push(w||[],t+1,2*s,2*i+1),a.push(v||[],t+1,2*s+1,2*i),a.push(b||[],t+1,2*s+1,2*i+1);}}getTile(e,t,s){e=+e,t=+t,s=+s;const i=this.options,{extent:o,debug:n}=i;if(e<0||e>24)return null;const r=1<1&&console.log("drilling down to z%d-%d-%d",e,t,s);let l,c=e,u=t,h=s;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Oe(c,u,h)];return l&&l.source?(n>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,s),n>1&&console.timeEnd("drilling down"),this.tiles[a]?_e(this.tiles[a],o):null):null}}function Oe(e,t,s){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,r=o.features.filter(e=>n(e));let a={_geojsonTileLayer:o.features};r.length>0&&(a={_geojsonTileLayer:o.features.filter(e=>!n(e)),hd_road_elevation:r});const l=new O(a),c=function(e){const s=new t.g4;for(const t of Object.keys(e))s.writeMessage(3,$,{name:t,features:e[t]});return s.finish()}(a).buffer;s(null,{vectorTile:l,rawData:c,headers:new Headers});}class Fe extends _{constructor(e){super(e),this.loadVectorData=Ae,this._dynamicIndex=new F;}async loadData(e){const i=e&&e.request,o=i&&i.collectResourceTiming;this._geoJSONIndex=null;let n=await new Promise((t,s)=>{this.loadGeoJSON(e,(e,i)=>{e?s(e):t(i);});});if(!n)return {};if("object"!=typeof n)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(e.filter){const s=t.n(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));n.features=n.features.filter(e=>s.value.evaluate({zoom:0},e));}e.dynamic?("Feature"===n.type&&(n={type:"FeatureCollection",features:[n]}),e.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(n.features,this.loaded),e.cluster&&(n.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=e.cluster?new se(function({superclusterOptions:e,clusterProperties:s}){if(!s||!e)return e;const i={},o={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(s);for(const e of a){const[n,r]=s[e],a=t.n(r),l=t.n("string"==typeof n?[n,["accumulated"],["get",e]]:n);i[e]=a.value,o[e]=l.value;}return e.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(n,r);return t},e.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=o[t].evaluate(n,r);},e}(e)).load(n.features):e.dynamic?this._dynamicIndex:function(e,t){return new ze(e,t)}(n,e.geojsonVtOptions);const r={};if(o){const t=s(i);t&&(r.resourceTiming={},r.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)));}return r}async reloadTile(e){const t=this.loaded;if(t&&t[e.uid]){if(e.partial)return;return super.reloadTile(e)}return this.loadTile(e)}loadGeoJSON(e,s){if(e.request)t.o(e.request).then(({data:e})=>s(null,e)).catch(e=>s(e));else {if("string"!=typeof e.data)return s(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return s(null,JSON.parse(e.data))}catch(t){return s(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}},0);}}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class Be{constructor(e,s,i){this.tileID=new t.br(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=e.projection,this.brightness=s,this.worldview=i;}async parse(e,s,i){this.status="parsing";const o=new t.br(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),n=[],r=s.familiesBySource[i.source],a=new t.fO(o,i.promoteId);a.bucketLayerIDs=[],a.is3DTile=!0;const l=await t.g5(e),c=l.json.extensionsUsed&&l.json.extensionsUsed.includes("MAPBOX_mesh_features")||l.json.asset.extras&&l.json.asset.extras.MAPBOX_mesh_features,u=l.json.extensionsUsed&&l.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new t.aa(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const e in r)for(const s of r[e]){const e=s[0];a.bucketLayerIDs.push(s.map(e=>t.y(e.id,e.scope))),e.recalculate(h,[]);const r=t.g6(l,1/t.cn(i.tileID.canonical)),d=new t.g7(s,r,o,c,u,this.brightness,a,this.worldview);c||(d.needsUpload=!0),n.push(d),d.evaluate(e);}return this.status="done",{buckets:n,featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null}}}class Re{constructor({actor:e,layerIndex:t,availableImages:s,availableModels:i,brightness:o,worldview:n}){this.actor=e,this.layerIndex=t,this.availableImages=s,this.availableModels=i,this.brightness=o,this.loading={},this.loaded={},this.worldview=n;}async loadTile(e){const s=e.uid,i=new AbortController,o=this.loading[s]=new Be(e,this.brightness,this.worldview);o.abort=()=>i.abort();const n=(e,t)=>{const s=o.reloadCallback;s&&(delete o.reloadCallback,s(e,t));};let r;try{r=(await t.da(e.request,i.signal)).data;}catch(e){if(delete this.loading[s],o.status="done",this.loaded[s]=o,i.signal.aborted)return null;throw e}if(delete this.loading[s],!r||0===r.byteLength)return o.status="done",this.loaded[s]=o,null;try{const t=await o.parse(r,this.layerIndex,e);return this.loaded[s]=o,n(null,t),t}catch(e){throw this.loaded[s]=o,n(e),e}}async reloadTile(e){const t=this.loaded&&this.loaded[e.uid];if(t)return t.projection=e.projection,t.brightness=e.brightness,"parsing"===t.status&&await new Promise((e,s)=>{t.reloadCallback=t=>{t?s(t):e();};}),this.loadTile(e)}abortTile(e){const t=e.uid,s=this.loading[t];s&&(s.abort&&s.abort(),delete this.loading[t]);}removeTile(e){const t=this.loaded,s=e.uid;t&&t[s]&&delete t[s];}}class Ze{constructor(e){this.self=e,this.actor=new t.an(e,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=t.b6({name:"mercator"}),this.workerSourceTypes={vector:_,geojson:Fe,"raster-dem":C,"raster-array":j,"batched-model":Re},this.workerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=e=>{if(t.g9.isParsed())throw new Error("RTL text plugin already registered.");t.g9.setState({pluginStatus:t.ga.parsed,pluginURL:t.g9.getPluginURL()}),t.g9.applyArabicShaping=e.applyArabicShaping,t.g9.processBidirectionalText=e.processBidirectionalText,t.g9.processStyledBidirectionalText=e.processStyledBidirectionalText;for(const{resolve:e}of this.rtlPluginParsingListeners)e(!0);this.rtlPluginParsingListeners=[];};}clearCaches(e,t){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],delete this.isSpriteLoaded[e];}checkIfReady(e,t){}spriteLoaded(e,s){const{scope:i}=s;if(this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.isSpriteLoaded[e][i]=!0,this.workerSources[e]&&this.workerSources[e][i])for(const s in this.workerSources[e][i]){const o=this.workerSources[e][i][s];for(const e in o){const s=o[e];s instanceof _&&(s.isSpriteLoaded=!0,s.fire(new t.B("isSpriteLoaded")));}}}setImages(e,t){this.availableImages[e]||(this.availableImages[e]={});const{scope:s,images:i}=t;if(this.availableImages[e][s]=i,t.isSpriteLoaded&&this.spriteLoaded(e,{scope:s}),this.workerSources[e]&&this.workerSources[e][s])for(const t in this.workerSources[e][s]){const o=this.workerSources[e][s][t];for(const e in o)o[e].availableImages=i;}}setModels(e,{scope:t,models:s}){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=s,this.workerSources[e]&&this.workerSources[e][t])for(const i in this.workerSources[e][t]){const o=this.workerSources[e][t][i];for(const e in o)o[e].availableModels=s;}}setProjection(e,s){this.projections[e]=t.b6(s);}setGlobalParams(e,s){if(this.referrer=s.referrer,Object.assign(t.g,s.config),s.contextOptions){const{maxBindingPoints:e,maxUniformBlockSizeDwords:t}=s.contextOptions;this.maxUniformBufferBindings=e,this.maxUniformBlockSizeDwords=t;}}upsertRenderParams(e,t){void 0!==t.brightness&&(this.brightness=t.brightness),void 0!==t.worldview&&(this.worldview=t.worldview);}setLayers(e,t){this.getLayerIndex(e,t.scope).replace(t.layers,t.options);}updateLayers(e,t){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options);}loadTile(e,t){return t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).loadTile(t)}decodeRasterArray(e,t){return this.getWorkerSource(e,t).decodeRasterArray(t)}reloadTile(e,t){return t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t).reloadTile(t)}abortTile(e,t){return this.getWorkerSource(e,t).abortTile(t)}removeTile(e,t){return this.getWorkerSource(e,t).removeTile(t)}removeSource(e,t){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const s=this.workerSources[e][t.scope][t.type][t.source];return delete this.workerSources[e][t.scope][t.type][t.source],void 0!==s.removeSource?s.removeSource(t):void 0}async loadTileProvider(e,s){const i=new(await t.dg(s.name,s.url))(s.options);return this.getWorkerSource(e,{type:s.type,source:s.source,scope:s.scope},i),i.load&&s.request?i.load({request:s.request}):null}async syncRTLPluginState(e,s){if(t.g9.isParsed())return !0;if(t.g9.isParsing())return new Promise((e,t)=>{this.rtlPluginParsingListeners.push({resolve:e,reject:t});});t.g9.setState(s);const i=t.g9.getPluginURL();if(!t.g9.isLoaded()||t.g9.isParsed()||t.g9.isParsing())return !1;t.g9.setState({pluginStatus:t.ga.parsing,pluginURL:i});try{return await self.__mapboxImport( /* webpackIgnore: true */ /* @vite-ignore */ -o),t.eH.isParsed()?i(null,!0):this.rtlPluginParsingListeners.push(i);}catch(e){t.eH.setState({pluginStatus:t.f7.error,pluginURL:o}),i(e);for(const t of this.rtlPluginParsingListeners)t(e);this.rtlPluginParsingListeners=[];}}}setConfig(e,s){Object.assign(t.bN,s);}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let s=this.availableImages[e][t];return s||(s=[]),s}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let s=this.availableModels[e][t];return s||(s={}),s}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new b,s.scope=t),s}getWorkerSource(e,t,s){const{type:i,source:o,scope:n}=t,r=this.workerSources;if(r[e]||(r[e]={}),r[e][n]||(r[e][n]={}),r[e][n][i]||(r[e][n][i]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),r[e][n][i][o])s&&(r[e][n][i][o].tileProvider=s);else {const t={send:(t,s,i,o,n,r)=>this.actor.send(t,s,i,e,n,r),scheduler:this.actor.scheduler},a=this.workerSourceTypes[i];if(!a)throw new Error(`Unknown worker source type "${i}".`);r[e][n][i][o]=new a({actor:t,layerIndex:this.getLayerIndex(e,n),availableImages:this.getAvailableImages(e,n),availableModels:this.getAvailableModels(e,n),isSpriteLoaded:this.isSpriteLoaded[e][n],tileProvider:s,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});}return r[e][n][i][o]}enforceCacheSizeLimit(e,s){t.cf(s);}getWorkerPerformanceMetrics(e,t,s){s(void 0,void 0);}}return t.dR(self)&&(self.worker=new Ae(self)),Ae}); +i),!!t.g9.isParsed()||new Promise((e,t)=>{this.rtlPluginParsingListeners.push({resolve:e,reject:t});})}catch(e){t.g9.setState({pluginStatus:t.ga.error,pluginURL:i});for(const{reject:t}of this.rtlPluginParsingListeners)t(e);throw this.rtlPluginParsingListeners=[],e}}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let s=this.availableImages[e][t];return s||(s=[]),s}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let s=this.availableModels[e][t];return s||(s={}),s}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new b,s.scope=t),s}getWorkerSource(e,t,s){const{type:i,source:o,scope:n}=t,r=this.workerSources;if(r[e]||(r[e]={}),r[e][n]||(r[e][n]={}),r[e][n][i]||(r[e][n][i]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),r[e][n][i][o])s&&(r[e][n][i][o].tileProvider=s);else {const t=this.actor.getWorkerSourceActor(e),a=this.workerSourceTypes[i];if(!a)throw new Error(`Unknown worker source type "${i}".`);r[e][n][i][o]=new a({actor:t,layerIndex:this.getLayerIndex(e,n),availableImages:this.getAvailableImages(e,n),availableModels:this.getAvailableModels(e,n),isSpriteLoaded:this.isSpriteLoaded[e][n],tileProvider:s,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords});}return r[e][n][i][o]}enforceCacheSizeLimit(e,s){t.gb(s);}}return t.g8(self)&&(self.worker=new Ze(self)),Ze}); -define(["./shared"],function(e){var t="3.25.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},o={mark(e){performance.mark(e);},measure(e,t,i){performance.measure(e,t,i);}};function r(t){const i=t.name.split("?")[0];return e.dF(i)&&i.includes("mapbox-gl.js")?"javascript":e.dF(i)&&i.includes("mapbox-gl.css")?"css":e.dG(i)?"fontRange":e.dH(i)?"sprite":e.dI(i)?"style":e.dJ(i)?"tilejson":"other"}const n={antialias:!1,alpha:!0,stencil:!0,depth:!0};let s,a;function l(e){const t=document.createElement("canvas"),i=Object.create(n);i.failIfMajorPerformanceCaveat=e;const o=t.getContext("webgl2",i);if(!o)return !1;let r;try{r=o.createShader(o.VERTEX_SHADER);}catch(e){return !1}return !(!r||o.isContextLost())&&(o.shaderSource(r,"void main() {}"),o.compileShader(r),!0===o.getShaderParameter(r,o.COMPILE_STATUS))}const c=/firefox/i,h=/macintosh/i;function d(e,t,i){const o=document.createElement(e);return null!=t&&(o.className=t),i&&i.appendChild(o),o}function u(e,t,i){const o=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))o.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(o),o}const _="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,f=_&&void 0!==_.userSelect?"userSelect":"WebkitUserSelect";let p;function m(){_&&f&&(p=_[f],_[f]="none");}function g(){_&&f&&(_[f]=p);}function v(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",v,!0);}function y(){window.addEventListener("click",v,!0),window.setTimeout(()=>{window.removeEventListener("click",v,!0);},0);}function x(e,t){const i=e.getBoundingClientRect();return T(e,i,t)}function b(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;rthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,o){if(!e.dL(i))return i;const r=P(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||o)}normalizeGlyphsURL(t,i){if(!e.dL(t))return t;const o=P(t);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.dL(t))return t;const o=P(t);return o.path=`/models/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeSourceURL(t,i,o,r){if(!e.dL(t))return t;const n=P(t);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),o&&n.params.push(`language=${o}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||i)}normalizeIconsetURL(t,i){const o=P(t);return e.dL(t)?(o.path=`/styles/v1${o.path}/iconset.pbf`,this._makeAPIURL(o,this._customAccessToken||i)):M(o)}normalizeSpriteURL(t,i,o,r){const n=P(t);return e.dL(t)?(n.path=`/styles/v1${n.path}/sprite${i}${o}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${i}${o}`,M(n))}normalizeTileURL(t,i,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.dL(t))return t;const r=P(t);r.path=r.path.replace(S,`${i||o&&"raster"!==r.authority&&512===o?"@2x":""}${e.cn.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.bN.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.bN.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.bN.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(I,"/"),r.path=`/${e.bN.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(D);if(e)return e[1]}return null}(r.params)||e.bN.ACCESS_TOKEN;return e.bN.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,i){const o=P(t);if(!R.test(o.path)||!C.test(o.path))return t;let r="mapbox://";o.path.startsWith("/raster/v1/")?r+=`raster/${o.path.replace(`/${e.bN.RASTER_URL_PREFIX}/`,"")}`:o.path.startsWith("/rasterarrays/v1/")?r+=`rasterarrays/${o.path.replace(`/${e.bN.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${o.path.replace(`/${e.bN.TILE_URL_VERSION}/`,"")}`;let n=o.params;return i&&(n=n.filter(e=>!e.match(D))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,i){const o=!!i&&e.dL(i),r=[];for(const i of t.tiles||[])e.dK(i)?r.push(this.canonicalizeTileURL(i,o)):r.push(i);return r}_makeAPIURL(t,i){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=P(e.bN.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}`),!e.bN.REQUIRE_ACCESS_TOKEN)return M(t);if(i=i||e.bN.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return t.params=t.params.filter(e=>!e.includes("access_token")),t.params.push(`access_token=${i||""}`),M(t)}}const O=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function P(e){const t=e.match(O);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function M(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const F="mapbox.eventData";function z(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.bq(i[1]))}catch(e){return null}}function k(t){return !(!e.bN.EVENTS_URL||!t&&!e.bN.ACCESS_TOKEN)}let B;const N=/^[\w.+-]+(\/[\w.+-]+)?$/;let U="other";class j{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const i=z(e.bN.ACCESS_TOKEN);let o="";return o=i&&i.u?e.br(i.u):e.bN.ACCESS_TOKEN||"",t?`${F}.${t}:${o}`:`${F}:${o}`}fetchEventData(){const t=e.fv("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(o);t&&(this.anonId=t);const n=localStorage.getItem(r);n&&(this.anonIdTimestamp=Number(n));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(r,s.toString());}catch(t){e.f_("Unable to write to LocalStorage");}}processRequests(e){}postEvent(t,i,o,r){if(!e.bN.EVENTS_URL)return;const n=P(e.bN.EVENTS_URL);n.params.push(`access_token=${r||e.bN.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:M(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.eR(l,e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(r);});}queueRequest(e,t){this.queue.push(e),this.processRequests(t);}}class G extends j{constructor(e){super("metrics"),e&&(this.data=e);}postMetricsEvent(t){if(!k(t))return;this.anonId||this.fetchEventData(),e.fZ(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e);}}const V=new class extends j{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(t,i){k(i)&&Array.isArray(t)&&t.some(t=>e.dL(t)||e.dK(t))&&this.queueRequest(Date.now(),i);}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const o=z(e.bN.ACCESS_TOKEN),r=o?o.u:e.bN.ACCESS_TOKEN;let n=r!==this.eventData.tokenU;e.fZ(this.anonId)||(this.refreshUUID(),n=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;n=n||i>=1||i<-1||e.getDate()!==t.getDate();}else n=!0;if(!n)return void this.processRequests();const a={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:E,"enabled.telemetry":!1,userId:this.anonId,bundleFormat:"umd",bundleDistribution:U};B&&(a.sdkInfo=B),this.postEvent(s,a,e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r);},i);}},H=V.postTurnstileEvent.bind(V),W=new class extends j{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(t,i,o,r){this.skuToken=i,this.errorCb=r,e.bN.EVENTS_URL&&(o||e.bN.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(A)));}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:o,timestamp:r}=this.queue.shift();if(o&&this.success[o])return;this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.fZ(this.anonId)||this.refreshUUID();const n={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:E,skuToken:this.skuToken,userId:this.anonId,bundleFormat:"umd",bundleDistribution:U};B&&(n.sdkInfo=B),this.postEvent(r,n,e=>{e?this.errorCb(e):o&&(this.success[o]=!0);},i);}remove(){this.errorCb=null;}},Z=W.postMapLoadEvent.bind(W),q=new class extends j{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap;}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.fX(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:o,importedStyles:r}=t;if(!k(e))return;const n=this.getMapInstanceId(i),s={mapInstanceId:n,eventId:this.getEventId(n),style:o};r.length&&(s.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:s},e);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e);}},$=q.postStyleLoadEvent.bind(q),X=new G({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Y=X.postMetricsEvent.bind(X),K=new G({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Q=K.postMetricsEvent.bind(K),J=new class extends j{constructor(){super("gljs.performance");}postPerformanceEvent(e,t){k(e)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e);}processRequests(o){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:n,performanceData:s}=this.queue.shift(),a=function(o){const n=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const o of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,n=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[r]=Math.max(t[r]||-1/0,o.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==o.transferSize&&0===o.transferSize&&a(s),a(n);}return t}(function(e,t){const i={};if(e)for(const o of e){const e=t(o);void 0===i[e]&&(i[e]=[]),i[e].push(o);}return i}(n,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,h=c?c.effectiveType:void 0,d={counters:[],metadata:[],attributes:[]},u=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in a)u(d.counters,e,a[e]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(u(d.counters,"interactionRangeMin",o.interactionRange[0]),u(d.counters,"interactionRangeMax",o.interactionRange[1])),s)for(const e of Object.values(i)){const t=s.find(t=>t.name===e);t&&u(d.counters,e,t.startTime);}return u(d.counters,"visibilityHidden",o.visibilityHidden),u(d.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.dI(t)){const e=t.split("/").slice(-2);if(2===e.length)return `mapbox://styles/${e[0]}/${e[1]}`}}}(n)),u(d.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),u(d.attributes,"fogEnabled",o.fogEnabled?"true":"false"),u(d.attributes,"projection",o.projection),u(d.attributes,"zoom",o.zoom),u(d.metadata,"devicePixelRatio",l),u(d.metadata,"connectionEffectiveType",h),u(d.metadata,"navigatorUserAgent",navigator.userAgent),u(d.metadata,"screenWidth",window.screen.width),u(d.metadata,"screenHeight",window.screen.height),u(d.metadata,"windowWidth",window.innerWidth),u(d.metadata,"windowHeight",window.innerHeight),u(d.metadata,"mapWidth",o.width/l),u(d.metadata,"mapHeight",o.height/l),u(d.metadata,"webglRenderer",o.renderer),u(d.metadata,"webglVendor",o.vendor),u(d.metadata,"sdkVersion",t),u(d.metadata,"sdkIdentifier","mapbox-gl-js"),d}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(n,a,()=>{},o);}},ee=J.postPerformanceEvent.bind(J),te=new class extends j{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(t,i,o,r){if(!e.bN.API_URL||!e.bN.SESSION_PATH)return;const n=P(e.bN.API_URL+e.bN.SESSION_PATH);n.params.push(`sku=${i||""}`),n.params.push(`access_token=${r||e.bN.ACCESS_TOKEN||""}`);const s={url:M(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.cM(s,e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(r);});}getSessionAPI(t,i,o,r){this.skuToken=i,this.errorCb=r,e.bN.EVENTS_URL&&e.bN.SESSION_PATH&&e.bN.API_URL&&(o||e.bN.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(A)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0);},e);}remove(){this.errorCb=null;}},ie=te.getSessionAPI.bind(te),oe=new Set;function re(e,t){t?oe.add(e):oe.delete(e);}class ne{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={};}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.a1.toString(t)),this.setDirty();}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={};}}function se(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const ae=new e.i(0,0,0);function le(e,t){const i=[],o=e[`stretch_${t}`];let r=null;for(let e=0;e>16&255)/255,(t>>8&255)/255,(255&t)/255,1)}function be(e,t){const i={spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0};let o;for(;o=e.nextField(t);)1===o?i.transform=me(e,e.readVarint()+e.pos):2===o?i.spread_method=e.readVarint():3===o?i.stops.push(we(e,e.readVarint()+e.pos)):4===o?i.x1=e.readFloat():5===o?i.y1=e.readFloat():6===o?i.x2=e.readFloat():7===o&&(i.y2=e.readFloat());return i}function we(e,t){const i={offset:0,opacity:255,rgb_color:ae};let o;for(;o=e.nextField(t);)1===o?i.offset=e.readFloat():2===o?i.opacity=e.readVarint():3===o&&(i.rgb_color=xe(e.readVarint()));return i}function Te(e,t){const i={spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0};let o;for(;o=e.nextField(t);)1===o?i.transform=me(e,e.readVarint()+e.pos):2===o?i.spread_method=e.readVarint():3===o?i.stops.push(we(e,e.readVarint()+e.pos)):4===o?i.cx=e.readFloat():5===o?i.cy=e.readFloat():6===o?i.r=e.readFloat():7===o?i.fx=e.readFloat():8===o?i.fy=e.readFloat():9===o&&(i.fr=e.readFloat());return i}function Ee(e,t){const i={children:[]};let o;for(;o=e.nextField(t);)1===o?i.transform=me(e,e.readVarint()+e.pos):2===o?i.clip_path_idx=e.readVarint():3===o&&i.children.push(fe(e,e.readVarint()+e.pos));return i}function Se(e,t){const i={left:0,width:20,mask_type:1,children:[]};let o;for(;o=e.nextField(t);)1===o?i.left=i.top=e.readFloat():2===o?i.width=i.height=e.readFloat():3===o?i.top=e.readFloat():4===o?i.height=e.readFloat():5===o?i.mask_type=e.readVarint():6===o?i.mask_idx=e.readVarint():7===o&&i.children.push(fe(e,e.readVarint()+e.pos));return null==i.height&&(i.height=i.width),null==i.top&&(i.top=i.left),i}class Ie{static calculate(t={},i=[]){const o=new Map,r=new Map;if(0===Object.keys(t).length)return o;i.forEach(t=>{r.set(t.name,t.rgb_color||new e.i(0,0,0));});for(const[e,i]of Object.entries(t))r.has(e)?o.set(r.get(e).toString(),i):console.warn(`Ignoring unknown image variable "${e}"`);return o}}function Ce(t,i=255,o){const r=o.get(t.toString())||t;return 255===i?r.toString():new e.i(r.r,r.g,r.b,r.a*i/255).toString()}const Re=[];let De=0;function Ae(t,i){if(De>=Re.length){const o=e.eA()?new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0}):document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Re.push(o);}const o=Re[De++];return o.canvas.width=t,o.canvas.height=i,o}function Le(){De--;}function Oe(e,t,i,o,r){for(const n of o.children)Pe(e,t,i,n,r);}function Pe(e,t,i,o,r){o.group?(e.save(),function(e,t,i,o,r){const n=null!=o.mask_idx?i.masks[o.mask_idx]:null,s=null!=o.clip_path_idx?i.clip_paths[o.clip_path_idx]:null;if(o.transform&&(t=Ge(o.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(o,null!=s,null!=n))return void Oe(e,t,i,o,r);const a=Ae(e.canvas.width,e.canvas.height);Oe(a,t,i,o,r),s&&Ue(a,t,i,s),n&&je(a,t,i,n,r),e.globalAlpha=o.opacity/255,e.drawImage(a.canvas,0,0),Le();}(e,t,i,o.group,r),e.restore()):o.path&&(e.save(),function(e,t,i,o,r){e.setTransform(t),1===o.paint_order?(Me(e,i,o,r),ze(e,i,o,r)):(ze(e,i,o,r),Me(e,i,o,r));}(e,t,i,o.path,r),e.restore());}function Me(e,t,i,o){const r=i.fill;if(!r)return;const n=r.opacity/255;switch(e.save(),e.beginPath(),Ve(i,e),r.paint){case "rgb_color":e.fillStyle=Ce(r.rgb_color,r.opacity,o);break;case "linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(Ge(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=ke(e,i,n,o);break}case "radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(Ge(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Be(e,i,n,o);}}e.fill(Fe(i)),e.restore();}function Fe(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function ze(e,t,i,o){const r=i.stroke;if(!r)return;const n=He(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const s=r.opacity/255;switch(r.paint){case "rgb_color":e.strokeStyle=Ce(r.rgb_color,r.opacity,o);break;case "linear_gradient_idx":e.strokeStyle=ke(e,t.linear_gradients[r.linear_gradient_idx],s,o,!0);break;case "radial_gradient_idx":e.strokeStyle=Be(e,t.radial_gradients[r.radial_gradient_idx],s,o,!0);}switch(r.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel";}switch(r.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square";}e.stroke(n);}function ke(e,t,i,o,r=!1){if(1===t.stops.length){const e=t.stops[0];return Ce(e.rgb_color,e.opacity*i,o)}const{x1:n,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(n,s),h=new DOMPoint(a,l);if(r){const e=Ge(t.transform);c=e.transformPoint(c),h=e.transformPoint(h);}const d=e.createLinearGradient(c.x,c.y,h.x,h.y);for(const e of t.stops)d.addColorStop(e.offset,Ce(e.rgb_color,e.opacity*i,o));return d}function Be(e,t,i,o,r=!1){if(1===t.stops.length){const e=t.stops[0];return Ce(e.rgb_color,e.opacity*i,o)}const n=Ge(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:h,r:d}=t;let u=new DOMPoint(s,a),_=new DOMPoint(c,h),f=l,p=d;if(r){u=n.transformPoint(u),_=n.transformPoint(_);const e=(n.a+n.d)/2;f=l*e,p=t.r*e;}const m=e.createRadialGradient(u.x,u.y,f,_.x,_.y,p);for(const e of t.stops)m.addColorStop(e.offset,Ce(e.rgb_color,e.opacity*i,o));return m}function Ne(e,t,i,o){const r=o.transform?Ge(o.transform).preMultiplySelf(t):t,n=Ae(e.canvas.width,e.canvas.height);for(const e of o.children)if(e.group)Ne(n,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(He(t),r),n.fill(i,Fe(t));}const s=null!=o.clip_path_idx?i.clip_paths[o.clip_path_idx]:null;s&&Ue(n,r,i,s),e.globalCompositeOperation="source-over",e.drawImage(n.canvas,0,0),Le();}function Ue(e,t,i,o){const r=Ae(e.canvas.width,e.canvas.height);Ne(r,t,i,o),e.globalCompositeOperation="destination-in",e.drawImage(r.canvas,0,0),Le();}function je(e,t,i,o,r){if(0===o.children.length)return;const n=null!=o.mask_idx?i.masks[o.mask_idx]:null;n&&je(e,t,i,n,r);const s=e.canvas.width,a=e.canvas.height,l=Ae(s,a),c=o.width,h=o.height,d=o.left,u=o.top,_=new Path2D,f=new Path2D;f.rect(d,u,c,h),_.addPath(f,t),l.clip(_);for(const e of o.children)Pe(l,t,i,e,r);const p=l.getImageData(0,0,s,a),m=p.data;if(1===o.mask_type)for(let e=0;ee.a1.from(t))}getImageVersions(e){return this.imageVersions.get(e)||new Map}getImages(e,t,i){const o=[],r=[],n=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){o.push(i);continue}const e=n.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i));}if(0===o.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of o)l.has(e.toString())||(s=!1);a||s?this._notify(o,t,i):this.requestors.push({ids:o,scope:t,callback:i});}rasterizeImages(e,t){const i=new Map,{iconTasks:o,patternTasks:r,scope:n}=e;for(const e of [o,r])for(const[t,o]of e.entries()){const e=this.getImage(o.id,n);e&&i.set(t,{image:e,imageVariant:o});}t(null,this._rasterizeImages(n,i));}_rasterizeImages(e,t){const i=new Map;for(const[o,{image:r,imageVariant:n}]of t.entries())i.set(o,this.imageRasterizer.rasterize(n,r,e,0));return i}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,o){const r=this.images.get(i),n=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.x("styleimagemissing",{id:i.name}));}const t=r.get(i.toString());if(!t){e.f_(`Image "${i.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const o={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(o,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),n.set(e.a1.toString(i),o);}o(null,{images:n,versions:this.getImageVersions(i)});}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return {width:t,height:i}}getPattern(t,i,o){const r=t.toString(),n=this.patterns.get(i),s=n.get(r),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.position.version=a.version;}else {if(a.usvg&&!a.data){const n=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(n))return null;this.patternsInFlight.add(n);const s=new e.a4(t).scaleSelf(e.co.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]),c=this._rasterizeImages(i,l);return this.storePatternImage(s,i,a,o,c),null}this.storePattern(t,i,a);}return this._updatePatternAtlas(i,o),n.get(r).position}getPatternInFlightId(t,i){return e.ea(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,o,r){const n=e.toString(),s=r?r.get(n):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,o),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)));}storePattern(t,i,o){const r={w:o.data.width+2*e.aq,h:o.data.height+2*e.aq,x:0,y:0},n=new e.a2(r,o,e.aq);this.patterns.get(i).set(t.toString(),{bin:r,position:n});}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear();}bind(t,i){const o=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.a_(t,this.atlasImage.get(i),o.RGBA8),this.atlasTexture.set(i,r)),r.bind(o.LINEAR,o.CLAMP_TO_EDGE);}_updatePatternAtlas(t,i){const o=this.patterns.get(t),r=Array.from(o.values()).map(({bin:e})=>e),{w:n,h:s}=e.eT(r),a=this.atlasImage.get(t);a.resize({width:n||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:r,position:n}]of o.entries()){let o=n.padding;const s=r.x+o,c=r.y+o,h=l.get(t).data,d=h.width,u=h.height;o=o>1?o-1:o,e.ay.copy(h,a,{x:0,y:0},{x:s,y:c},{width:d,height:u},i),e.ay.copy(h,a,{x:0,y:u-o},{x:s,y:c-o},{width:d,height:o},i),e.ay.copy(h,a,{x:0,y:0},{x:s,y:c+u},{width:d,height:o},i),e.ay.copy(h,a,{x:d-o,y:0},{x:s-o,y:c},{width:o,height:u},i),e.ay.copy(h,a,{x:0,y:0},{x:s+d,y:c},{width:o,height:u},i),e.ay.copy(h,a,{x:d-o,y:u-o},{x:s-o,y:c-o},{width:o,height:o},i),e.ay.copy(h,a,{x:0,y:u-o},{x:s+d,y:c-o},{width:o,height:o},i),e.ay.copy(h,a,{x:0,y:0},{x:s+d,y:c+u},{width:o,height:o},i),e.ay.copy(h,a,{x:d-o,y:0},{x:s-o,y:c+u},{width:o,height:o},i);}this.dirty=!0;}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set);this.imageAtlasCache.beginFrame();}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const o of e){if(this.callbackDispatchedThisFrame.get(t).has(o.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(o.toString());const e=i.get(o.toString());se(e)&&this.updateImage(o,t,e);}}}class qe{constructor(e,t,i,o){this.message=(e?`${e}: `:"")+i,o&&(this.identifier=o),null!=t&&t.__line__&&(this.line=t.__line__);}}class $e extends qe{}function Xe(t){const i=t.value,o=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,a=t.arrayElementValidator||wt;if(!Array.isArray(i))return [new qe(s,i,`array expected, ${e.da(i)} found`)];if(o.length&&i.length!==o.length)return [new qe(s,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.lengthe)return [new qe(i,o,`${o} is greater than the maximum value ${e}`)]}return []}function Ke(t){const i=t.key,o=t.value;if(!e.dN(o))return [new qe(i,o,`object expected, ${e.da(o)} found`)];const r=t.valueSpec,n=e.fT(o.type);let s,a,l,c={};const h="categorical"!==n&&void 0===o.property,d=!h,u=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.dN(i[0][0])}(o),_=Tt({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return [new qe(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(Xe({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:f})),Array.isArray(i)&&0===i.length&&t.push(new qe(e.key,i,"array must have at least one stop")),t},default:function(e){return wt({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===n&&h&&_.push(new qe(t.key,t.value,'missing required property "property"')),"identity"===n||o.stops||_.push(new qe(t.key,t.value,'missing required property "stops"')),"exponential"===n&&r.expression&&!e.fA(r)&&_.push(new qe(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(d&&!e.fC(r)?_.push(new qe(t.key,t.value,"property functions not supported")):h&&!e.fD(r)&&_.push(new qe(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==o.property||_.push(new qe(t.key,t.value,'"property" property is required')),_;function f(t){let i=[];const o=t.value,n=t.key;if(!Array.isArray(o))return [new qe(n,o,`array expected, ${e.da(o)} found`)];if(2!==o.length)return [new qe(n,o,`array length 2 expected, length ${o.length} found`)];if(u){if(!e.dN(o[0]))return [new qe(n,o,`object expected, ${e.da(o[0])} found`)];const r=o[0];if(void 0===r.zoom)return [new qe(n,o,"object stop key must have zoom")];if(void 0===r.value)return [new qe(n,o,"object stop key must have value")];const s=e.fT(r.zoom);if("number"!=typeof s)return [new qe(n,r.zoom,"stop zoom values must be numbers")];if(l&&l>s)return [new qe(n,r.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(Tt({key:`${n}[0]`,value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Ye,value:p}}));}else i=i.concat(p({key:`${n}[0]`,value:o[0],style:t.style,styleSpec:t.styleSpec},o));return e.dv(e.c3(o[1]))?i.concat([new qe(`${n}[1]`,o[1],"expressions are not allowed in function stops.")]):i.concat(wt({key:`${n}[1]`,value:o[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function p(t,i){const o=e.da(t.value),l=e.fT(t.value),h=null!==t.value?t.value:i;if(s){if(o!==s)return [new qe(t.key,h,`${o} stop domain type must match previous stop domain type ${s}`)]}else s=o;if("number"!==o&&"string"!==o&&"boolean"!==o&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new qe(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==n){let i=`number expected, ${o} found`;return e.fC(r)&&void 0===n&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new qe(t.key,h,i)]}return "categorical"!==n||"number"!==o||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===o&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew qe(`${t.key}${e.key}`,t.value,e.message));const o=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!o.outputDefined())return [new qe(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&&!e.dP(o))return [new qe(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return Je(o,t);if("appearance"===t.expressionContext)return it(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.dC(o,["zoom","feature-state"]))return [new qe(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.dy(o))return [new qe(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function Je(t,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const r=[];return t instanceof e.j&&o.has(t.name)?[new qe(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...Je(e,i));}),r)}const et=new Set(["get","has","properties","geometry-type","id"]),tt=new Set(["zoom","pitch","distance-from-center","feature","feature-state","measure-light","heatmap-density","line-progress","raster-value","raster-particle-speed","sky-radial-progress"]);function it(t,i){if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)tt.delete(e);if(0===tt.size)return [];const o=[];if(t instanceof e.j){const e=et.has(t.name)?"feature":t.name;if(tt.has(e))return [new qe(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]}return t.eachChild(e=>{o.push(...it(e,i));}),o}function ot(t){const i=t.key,o=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?r.values.includes(e.fT(o))||n.push(new qe(i,o,`expected one of [${r.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(r.values).includes(e.fT(o))||n.push(new qe(i,o,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(o)} found`)),n}function rt(t){return e.dw(e.c3(t.value))?Qe(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):nt(t)}function nt(t){const i=t.value,o=t.key;if(!Array.isArray(i))return [new qe(o,i,`array expected, ${e.da(i)} found`)];if(i.length<1)return [new qe(o,i,"filter array must have at least 1 element")];const r=t.styleSpec;let n=ot({key:`${o}[0]`,value:i[0],valueSpec:r.filter_operator});const s=()=>{i.length>=2&&(e.dQ(i[1])||n.push(new qe(`${o}[1]`,i[1],`string expected, ${e.da(i[1])} found`)));for(let t=2;t":case ">=":i.length>=2&&"$type"===e.fT(i[1])&&n.push(new qe(o,i,`"$type" cannot be use with operator "${i[0]}"`)),3!==i.length&&n.push(new qe(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),s();break;case "==":case "!=":3!==i.length&&n.push(new qe(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),s();break;case "in":case "!in":s();break;case "any":case "all":case "none":for(let e=1;e{e in o&&i.push(new qe(r,o[e],`"${e}" is prohibited for ref layers`));}),n.layers.forEach(i=>{e.fT(i.id)===l&&(t=i);}),t?t.ref?i.push(new qe(r,o.ref,"ref cannot reference another ref layer")):a=e.fT(t.type):"string"==typeof l&&i.push(new qe(r,o.ref,`ref layer "${l}" not found`));}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(o.source)if(e.dQ(o.source)){const t=n.sources&&Object.hasOwn(n.sources,o.source)?n.sources[o.source]:void 0,s=t&&e.fT(t.type);t?"vector"===s&&"raster"===a?i.push(new qe(r,o.source,`layer "${o.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new qe(r,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==s||o["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new qe(r,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&o.paint&&o.paint["line-gradient"]&&"geojson"===s&&!t.lineMetrics?i.push(new qe(r,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"line"===a&&o.paint&&o.paint["line-trim-offset"]&&"geojson"===s&&!t.lineMetrics?i.push(new qe(r,o,`layer "${o.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new qe(r,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new qe(r,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new qe(r,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new qe(r,o.source,`source "${o.source}" not found`));}else i.push(new qe(`${r}.source`,o.source,'"source" must be a string'));else i.push(new qe(r,o,'missing required property "source"'));return i=i.concat(Tt({key:r,value:o,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>wt({key:`${r}.type`,value:o.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:e=>rt(Object.assign({layerType:a},e)),layout:e=>Tt({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ct(Object.assign({layerType:a},e))}}),paint:e=>Tt({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>lt(Object.assign({layerType:a,layer:o},e))}}),appearances(t){const i=Xe({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:o,layerType:r}=t,n=e.fT(t.value),s=e.fT(n.name),a=e.fT(n.condition),l=Tt({key:i,value:n,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...Qe({key:t.key,value:t.object.condition,valueSpec:e.fs.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:o,layerType:r},t)),properties:e=>function(e){const t=[],{styleSpec:i,layer:o,layerType:r}=e,n=i[`paint_${r}`],s=i[`layout_${r}`],a=e.object[e.objectKey];for(const i in a){const l=i in n?"paint":i in s?"layout":void 0;if(!l){t.push(new qe(e.key,i,`unknown property "${i}" for layer type "${r}"`));continue}const c=Object.assign({},e,{key:`${e.key}.${i}`,object:a,objectKey:i,layer:o,layerType:r,value:a[i],valueSpec:"paint"===l?n[i]:s[i]});t.push(...at(c,l));}return t}(Object.assign({layer:o,layerType:r},e))}});return "hidden"!==s&&void 0===a&&l.push(new qe(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:o},t))}),r=Array.isArray(t.value)?t.value:[],n=new Set;return r.forEach((r,s)=>{const a=e.fT(r.name);if(a)if(n.has(a)){const r=e.fT(o.id);i.push(new qe(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`));}else n.add(a);}),i}}})),i}function dt({key:t,value:i}){return e.dQ(i)?[]:[new qe(t,i,`string expected, ${e.da(i)} found`)]}const ut={promoteId:function t({key:i,value:o}){if(e.dQ(o))return dt({key:i,value:o});if(Array.isArray(o)){const t=[],r=e.c3(o),n=e.bY(r);return "error"===n.result?(n.value.forEach(e=>{t.push(new qe(`${i}${e.key}`,null,`${e.message}`));}),t):(e.dC(n.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new qe(`${i}`,null,"promoteId expression should be only feature dependent")),t)}if(!e.dN(o))return [new qe(i,o,`string, expression or object expected, "${e.da(o)}" found`)];const r=[];for(const e in o)r.push(...t({key:`${i}.${e}`,value:o[e]}));return r}};function _t(t){const i=t.value,o=t.key,r=t.styleSpec,n=t.style;if(!e.dN(i))return [new qe(o,i,`object expected, ${e.da(i)} found`)];if(!("type"in i))return [new qe(o,i,'"type" is required')];const s=e.fT(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new $e(o,i,'Either "url" or "tiles" is required.'))),s){case "vector":case "raster":case "raster-dem":case "raster-array":return a=a.concat(Tt({key:o,value:i,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ut})),a;case "geojson":if(a=Tt({key:o,value:i,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:ut}),"cluster"in i&&"clusterProperties"in i){if(!e.dN(i.clusterProperties))return [new qe(`${o}.clusterProperties`,i,`object expected, ${e.da(i)} found`)];for(const e in i.clusterProperties){const t=i.clusterProperties[e];if(!Array.isArray(t))return [new qe(`${o}.clusterProperties.${e}`,t,"array expected")];const[r,n]=t,s="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...Qe({key:`${o}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...Qe({key:`${o}.${e}.reduce`,value:s,expressionContext:"cluster-reduce"}));}}return a;case "video":return Tt({key:o,value:i,valueSpec:r.source_video,style:n,styleSpec:r});case "image":return Tt({key:o,value:i,valueSpec:r.source_image,style:n,styleSpec:r});case "canvas":return [new qe(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ot({key:`${o}.type`,value:i.type,valueSpec:{values:ft(r)}})}}function ft(e){return e.source.reduce((t,i)=>{const o=e[i];return "enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values||{}))),t},[])}function pt(e,t){const i=!e.includes("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return !1}}function mt(t){const i=t.value;return i?e.dQ(i)?pt(i,!0)?[]:[new qe(t.key,i,`invalid url "${i}"`)]:[new qe(t.key,i,`string expected, "${e.da(i)}" found`)]:[]}function gt(t){const i=t.value,o=t.styleSpec,r=o.light,n=t.style;if(void 0===i)return [];if(!e.dN(i))return [new qe("light",i,`object expected, ${e.da(i)} found`)];let s=[];for(const t in i){const a=t.match(e.aY),l=t.match(e.b3);s=s.concat(l&&r[l[1]]?wt({key:t,value:i[t],valueSpec:{type:"string"},style:n,styleSpec:o}):a&&r[a[1]]&&r[a[1]].transition?wt({key:t,value:i[t],valueSpec:o.transition,style:n,styleSpec:o}):r[t]?wt({key:t,value:i[t],valueSpec:r[t],style:n,styleSpec:o}):[new qe(t,i[t],`unknown property "${t}"`)]);}return s}function vt(t){const i=t.value;if(!i)return [];const o=t.key;if(!e.dN(i))return [new qe(o,i,`object expected, ${e.da(i)} found`)];let r=[];const n=t.styleSpec,s=n["light-3d"],a=t.style,l=t.style.lights;for(const e of ["type","id"])if(!(e in i))return r=r.concat([new qe(o,i,`missing property "${e}"`)]),r;if(!e.dQ(i.type))return r=r.concat([new qe(`${o}.type`,i.type,"string expected")]),r;if(l)for(let n=0;n[],array:Xe,boolean:function(t){const i=t.value,o=t.key;return e.du(i)?[]:[new qe(o,i,`boolean expected, ${e.da(i)} found`)]},number:Ye,color:function({key:t,value:i}){return e.dQ(i)?void 0===e.i.parse(e.fT(i))?[new qe(t,i,`color expected, "${i}" found`)]:[]:[new qe(t,i,`color expected, ${e.da(i)} found`)]},enum:ot,filter:rt,function:Ke,layer:ht,object:Tt,source:_t,model:mt,light:gt,"light-3d":vt,terrain:yt,fog:xt,string:dt,formatted:function(e){return 0===dt(e).length?[]:Qe(e)},resolvedImage:function(e){return 0===dt(e).length?[]:Qe(e)},projection:function(t){const i=t.value,o=t.styleSpec,r=o.projection,n=t.style;if(e.dN(i)){let e=[];for(const t in i)e=e.concat(wt({key:t,value:i[t],valueSpec:r[t],style:n,styleSpec:o}));return e}return e.dQ(i)?[]:[new qe("projection",i,`object or string expected, ${e.da(i)} found`)]},import:function(t){const i=t.key,{value:o,styleSpec:r}=t;if(!e.dN(o))return [new qe(i,o,"import must be an object")];const{data:n,...s}=o;Object.defineProperty(s,"__line__",{value:o.__line__,enumerable:!1});let a=Tt(Object.assign({},t,{value:s,valueSpec:r.import}));return ""===e.fT(s.id)&&a.push(new qe(`${t.key}.id`,s,"import id can't be an empty string")),"__proto__"===e.fT(s.id)&&a.push(new qe(`${t.key}.id`,s,'import id can\'t be "__proto__"')),n&&(a=a.concat(St(n,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,o=t.key,r=t.styleSpec,n=t.style;if(!e.dN(i))return [new qe(o,i,"object expected")];if(!i.type)return [new qe(o,i,'"type" is required')];const s=e.fT(i.type);let a=[];if(a=a.concat(Tt({key:o,value:i,valueSpec:r[`iconset_${s}`],style:n,styleSpec:r})),function(e,t){return !("source"!==e||!t.source)}(s,i)){const t=n.sources&&Object.hasOwn(n.sources,i.source)?n.sources[i.source]:void 0,r=t&&e.fT(t.type);t?"raster-array"!==r&&a.push(new qe(o,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new qe(o,i.source,`source "${i.source}" not found`));}return a},option:function(t){const i=t.styleSpec,o=t.value,r=e.dN(o)&&!0===e.fT(o.array)||!e.dN(o)?void 0:e.fT(o.type);return Tt(Object.assign({},t,{valueSpec:i.option,objectElementValidators:r?{default:e=>Array.isArray(e.value)?wt(Object.assign({},e,{valueSpec:Object.assign({},e.valueSpec,{type:r})})):wt(e)}:void 0}))}};function wt(t,i=!1){const o=t.value,r=t.valueSpec,n=t.styleSpec;if(r.expression){if(e.dB(e.fT(o)))return Ke(t);if(e.dv(e.c3(o)))return Qe(t)}if(r.type&&bt[r.type]){const e=bt[r.type](t);return !0===i&&e.length>0&&Array.isArray(t.value)?Qe(t):e}return Tt(Object.assign({},t,{valueSpec:r.type?n[r.type]:r}))}function Tt(t){const i=t.key,o=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.dN(o))return [new qe(i,o,`object expected, ${e.da(o)} found`)];let l=[];for(const e in o){if(!Object.hasOwn(o,e))continue;const t=e.split(".")[0],c=Object.hasOwn(r,t),h=Object.hasOwn(r,"*"),d=c?r[t]:h?r["*"]:void 0;let u;Object.hasOwn(n,t)?u=n[t]:c?u=wt:Object.hasOwn(n,"*")?u=n["*"]:h&&(u=wt),u?l=l.concat(u({key:(i?`${i}.`:i)+e,value:o[e],valueSpec:d,style:s,styleSpec:a,object:o,objectKey:e},o)):l.push(new $e(i,o[e],`unknown property "${e}"`));}for(const e in r){if(!Object.hasOwn(r,e))continue;if(Object.hasOwn(n,e))continue;const t=r[e];!t.required||void 0!==t.default||Object.hasOwn(o,e)&&void 0!==o[e]||l.push(new qe(i,o,`missing required property "${e}"`));}return l}function Et({key:e,value:t}){const i=dt({key:e,value:t});if(i.length)return i;const o=t;return o.includes("{fontstack}")||i.push(new qe(e,t,'"glyphs" url must include a "{fontstack}" token')),o.includes("{range}")||i.push(new qe(e,t,'"glyphs" url must include a "{range}" token')),i}function St(t,i=e.fs,o={}){return Tt({key:o.key||"",value:t,valueSpec:Object.assign({},i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:Et}})}function It(t,i=e.fs){return Nt(St(t,i))}const Ct=e=>Nt(_t(e)),Rt=e=>Nt(gt(e)),Dt=e=>Nt(vt(e)),At=e=>Nt(yt(e)),Lt=e=>Nt(xt(e)),Ot=t=>Nt(function(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.snow;if(void 0===i)return [];if(!e.dN(i))return [new qe("snow",i,`object expected, ${e.da(i)} found`)];let s=[];for(const t in i){const a=t.match(e.aY);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?wt({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?wt({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new $e(t,i[t],`unknown property "${t}"`)]);}return s}(t)),Pt=t=>Nt(function(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.rain;if(void 0===i)return [];if(!e.dN(i))return [new qe("rain",i,`object expected, ${e.da(i)} found`)];let s=[];for(const t in i){const a=t.match(e.aY);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?wt({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?wt({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new $e(t,i[t],`unknown property "${t}"`)]);}return s}(t)),Mt=e=>Nt(ht(e)),Ft=e=>Nt(rt(e)),zt=e=>Nt(lt(e)),kt=e=>Nt(ct(e)),Bt=e=>Nt(mt(e));function Nt(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Ut(t,i){let o=!1;if(i&&i.length)for(const r of i)r instanceof $e?e.f_(r.message):(t.fire(new e.v(new Error(r.message))),o=!0);return o}const jt=e.fs.light;let Gt;class Vt extends e.y{constructor(t,i="flat"){super(),this._transitionable=new e.b2(Gt||(Gt=new e.ax({anchor:new e.l(jt.anchor),position:new e.av(jt.position),color:new e.l(jt.color),intensity:new e.l(jt.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Rt,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&Ut(this,t.call(It,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.fs})))}}const Ht=e.fs.terrain;let Wt=class extends e.y{constructor(t,i,o,r,n){super(),this.scope=o,this._transitionable=new e.b2(new e.ax({source:new e.l(Ht.source),exaggeration:new e.l(Ht.exaggeration)}),o,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=n;}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.w(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let o=-1,r=-1,n=1;for(const t of i.zoomStops)n=i.evaluate(new e.w(t,{worldview:this.worldview})),n>.01?(o=t,r=-1):r=t;return n<.01&&o>0&&r>o?[o,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.bh}};const Zt=.05;function qt(t,i,o){const r=e.fq(45,65,o),[n,s]=t.range;let a=1-Math.min(1,Math.exp((i-n)/(s-n)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*r*t.alpha}function $t(t,i,o,r,n){const s=e.fL([],[i,o,r],n.mercatorFogMatrix);return qt(t,e.dW(s),n.pitch)}function Xt(t,i,o,r,n,s,a){const l=[[o,r,0],[n,r,0],[n,s,0],[o,s,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.fL([],t,i),r=e.dW(o);c=Math.min(c,r),h=Math.max(h,r);}return [qt(t,c,a.pitch),qt(t,h,a.pitch)]}const Yt=e.fs.fog;class Kt extends e.y{constructor(t,i,o,r){super();const n=new e.ax({range:new e.l(Yt.range),color:new e.l(Yt.color),"color-use-theme":new e.l({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.l(Yt["high-color"]),"high-color-use-theme":new e.l({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.l(Yt["space-color"]),"space-color-use-theme":new e.l({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.l(Yt["horizon-blend"]),"star-intensity":new e.l(Yt["star-intensity"]),"vertical-range":new e.l(Yt["vertical-range"])});this._transitionable=new e.b2(n,o,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.aw(n),this.scope=o;}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.dm(t.zoom),r=this.properties.get("range"),n=[2,4.5],s=.5/Math.tan(.5*t._fov),a=[r[0]+s,r[1]+s];return {range:i?[e.dY(n[0],a[0],o),e.dY(n[1],a[1],o)]:a,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Lt,e,i))return;const o=Object.assign({},e);for(const e of Object.keys(Yt))void 0===o[e]&&(o[e]=Yt[e].default);this._options=o,this._transitionable.setTransitionOrValue(this._options,t);}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:e.fq(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const r=e.ag.fromLngLat(i),n=o.elevation?o.elevation.getAtPointOrZero(r):0;return $t(t,r.x,r.y,n,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Xt(this.state,i,0,0,e.r,e.r,this._transform)}getOpacityForBounds(e,t,i,o,r){return this._transform.projection.supportsFog?Xt(this.state,e,t,i,o,r,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let r;if(i[2]>=0)r=i;else {const n=t.points[o-4];r=e.bo(n,i,n[2]/(n[2]-i[2]));}if($t(this.state,r[0],r[1],0,this._transform)>=Zt)return !0}return !1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&Ut(this,t.call(It,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.fs})))}}let Qt,Jt,ei=class extends e.y{constructor(t,i,o,r){super();const n=Qt||(Qt=new e.ax({density:new e.l(e.fs.snow.density),intensity:new e.l(e.fs.snow.intensity),color:new e.l(e.fs.snow.color),opacity:new e.l(e.fs.snow.opacity),vignette:new e.l(e.fs.snow.vignette),"vignette-color":new e.l(e.fs.snow["vignette-color"]),"center-thinning":new e.l(e.fs.snow["center-thinning"]),direction:new e.l(e.fs.snow.direction),"flake-size":new e.l(e.fs.snow["flake-size"])}));this._transitionable=new e.b2(n,o,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.aw(n),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),r=e.c4(o[0]),n=-Math.max(e.c4(o[1]),.01),s=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color"),c=new e.i(l.r,l.g,l.b,a);return {density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.i(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:c}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Ot,t,o))return;const r=Object.assign({},t),n=e.fs.snow;for(const e of Object.keys(n))void 0===r[e]&&(r[e]=n[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&Ut(this,t.call(It,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.fs})))}},ti=class extends e.y{constructor(t,i,o,r){super();const n=Jt||(Jt=new e.ax({density:new e.l(e.fs.rain.density),intensity:new e.l(e.fs.rain.intensity),color:new e.l(e.fs.rain.color),opacity:new e.l(e.fs.rain.opacity),vignette:new e.l(e.fs.rain.vignette),"vignette-color":new e.l(e.fs.rain["vignette-color"]),"center-thinning":new e.l(e.fs.rain["center-thinning"]),direction:new e.l(e.fs.rain.direction),"droplet-size":new e.l(e.fs.rain["droplet-size"]),"distortion-strength":new e.l(e.fs.rain["distortion-strength"])}));this._transitionable=new e.b2(n,o,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.aw(n),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),r=e.c4(o[0]),n=-Math.max(e.c4(o[1]),.01),s=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],a=this.properties.get("vignette-color"),l=new e.i(a.r,a.g,a.b,this.properties.get("vignette"));return {density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.i(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Pt,t,o))return;const r=Object.assign({},t),n=e.fs.rain;for(const e of Object.keys(n))void 0===r[e]&&(r[e]=n[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&Ut(this,t.call(It,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.fs})))}};const ii={workerUrl:"",workerClass:null,workerParams:void 0};function oi(e){return null!=ii.workerClass?new ii.workerClass:new self.Worker(ii.workerUrl,Object.assign({name:e},ii.workerParams))}const ri="mapboxgl_preloaded_worker_pool";class ni{constructor(e){this.active={},this.name=e;}acquire(e,t=ni.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate();}),this.workers=null);}isPreloaded(){return !!this.active[ri]}numActive(){return Object.keys(this.active).length}}ni.workerCount=2;class si{constructor(t,i,o="Worker",r=ni.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.fU();const n=this.workerPool.acquire(this.id,r);for(let e=0;e{this.ready=!0;});}broadcast(t,i,o){e.bp(this.actors,(e,o)=>{e.send(t,i,o);},o=o||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove();}),this.actors=[],this.workerPool.release(this.id);}}si.Actor=e.a;class ai extends e.y{constructor(t,i,o,r){super(),this.scope=o,this._options=t,this.properties=new e.aw(i),this._transitionable=new e.b2(i,o,r),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}let li;const ci=()=>li||(li=new e.ax({color:new e.l(e.fs.properties_light_ambient.color),"color-use-theme":new e.l({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.l(e.fs.properties_light_ambient.intensity)}));let hi;const di=()=>hi||(hi=new e.ax({direction:new e.p(e.fs.properties_light_directional.direction),color:new e.l(e.fs.properties_light_directional.color),"color-use-theme":new e.l({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.l(e.fs.properties_light_directional.intensity),"cast-shadows":new e.l(e.fs.properties_light_directional["cast-shadows"]),"shadow-quality":new e.l(e.fs.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.l(e.fs.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new e.l(e.fs.properties_light_directional["shadow-draw-before-layer"])})),ui=(e,t,i,o,r,n,s,a,l,c=[0,0,1])=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:o,u_camera_pos:r,u_tile_to_meter:n,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l,u_front_cutoff_params:c}),_i=e=>({u_matrix:e}),fi=e=>({u_matrix:e}),pi=1029,mi=2305;class gi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}gi.disabled=new gi(!1,pi,mi),gi.backCCW=new gi(!0,pi,mi),gi.backCW=new gi(!0,pi,2304),gi.frontCW=new gi(!0,1028,2304),gi.frontCCW=new gi(!0,1028,mi);class vi{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}vi.ReadOnly=!1,vi.ReadWrite=!0,vi.disabled=new vi(519,vi.ReadOnly,[0,1]);class yi{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.dY(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.dY(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.dY(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.dY(t.right,i.right,o)),this}getCenter(t,i){const o=e.bG((this.left+t-this.right)/2,0,t),r=e.bG((this.top+i-this.bottom)/2,0,i);return new e.au(o,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new yi(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function xi(t,i){const o=e.cL(t,3);e.ct(t,i),e.fk(t,3,o);}function bi(t,i){const o=e.dp([]);return e.f5(o,o,-i),e.f2(o,o,-t),o}function wi(t,i){const o=[t[0],t[1],0],r=[i[0],i[1],0];if(e.dW(o)>=1e-15){const t=e.ex([],o);e.fa(r,t,e.c7(r,t)),i[0]=r[0],i[1]=r[1];}const n=e.c1([],i,t);if(e.dV(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return bi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class Ti{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ag?t:new e.ag(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.f$(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i,o){if(this.orientation=null,!this.position)return;const r=this.position,n=o||(this._elevation?this._elevation.getAtPointOrZero(e.ag.fromLngLat(t)):0),s=e.ag.fromLngLat(t,n),a=[s.x-r.x,s.y-r.y,s.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=wi(a,i);}setPitchBearing(t,i){this.orientation=bi(e.c4(t),e.c4(-i));}}class Ei{constructor(t,i){this._transform=e.dq([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.ag(t[0],t[1],t[2])}get position(){const t=e.cL(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.fk(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.dp([]),t&&xi(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=bi(e,t),xi(this._transform,this._orientation);}forward(){const t=e.cL(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.cL(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.cL(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.dr(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const r=this.position;e.fa(r,r,-t);const n=new Float64Array(16);return e.cv(n,[o,o,o]),e.fQ(n,n,r),n[10]*=i,n}getWorldToCamera(t,i){const o=new Float64Array(16),r=new Float64Array(4),n=this.position;return e.bO(r,this._orientation),e.fa(n,n,-t),e.ct(o,r),e.fQ(o,o,n),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,r){const n=new Float64Array(16);return e.eE(n,t,i,o,r),n}getCameraToClipOrthographic(t,i,o,r,n,s){const a=new Float64Array(16);return e.eB(a,t,i,o,r,n,s),a}getDistanceToElevation(t,i=!1){const o=0===t?0:e.em(t,i?e.dT(this.position[1]):this.position[1]),r=this.forward();return (o-this.position[2])/r[2]}clone(){return new Ei([...this.position],[...this.orientation])}}const Si=Math.tan(85*Math.PI/180);function Ii(t,i,o,r,n,s,a){const l=e.bT();if(o)if("globe"===s.name){const t=e.bw(n,i);e.er(l,l,t);}else {const t=e.ds([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.f6(l,l,n.angle);}else e.er(l,n.labelPlaneMatrix,t);return l}function Ci(e,t,i,o,r,n,s){const a=Ii(e,t,i,o,r,n,s);return "globe"===n.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function Ri(t,i,o,r,n,s,a){if(o){if("globe"===s.name){const l=Ii(t,i,o,r,n,s,a);return e.dr(l,l),e.er(l,t,l),l}{const i=e.bJ(t),[o,s,l,c]=a,[h,d,u,_,f,p,m,g]=i;return i[0]=o*h+s*f,i[1]=o*d+s*p,i[2]=o*u+s*m,i[3]=o*_+s*g,i[4]=l*h+c*f,i[5]=l*d+c*p,i[6]=l*u+c*m,i[7]=l*_+c*g,r||e.f6(i,i,-n.angle),i}}return n.glCoordMatrix}function Di(t,i,o,r){const n=[t,i,o,1];o?e.fM(n,n,r):Ui(n,n,r);const s=n[3];return n[0]/=s,n[1]/=s,n[2]/=s,n}function Ai(e,t){return Math.min(.5+e/t*.5,1.5)}function Li(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function Oi(t,i,o,r,n,s,a,l,c,h,d=1){const u=o.transform,_=r?t.textSizeData:t.iconSizeData,f=e.ci(_,o.transform.zoom,d),p="globe"===u.projection.name,m=[256/o.width*2+1,256/o.height*2+1],g=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let v=null;p&&(v=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,b=o.transform.width/o.transform.height;let w,T=!1;for(let d=0;dMath.abs(o)?{useVertical:!0}:t===e.bg.vertical?r>0?{needsFlipping:!0}:null:0!==i&&function(e,t){return 0===e||Math.abs(t/e)>Si}(o,r)?1===i?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Fi(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y,x){const b=i/24,w=t.lineOffsetX*b,T=t.lineOffsetY*b,{lineStartIndex:E,glyphStartIndex:S,numGlyphs:I,segment:C,writingMode:R,flipState:D}=t,A=E+t.lineLength,L=t=>{if(d){const[i,o,r]=t.up,n=h.length;e.fW(d,n+0,i,o,r),e.fW(d,n+1,i,o,r),e.fW(d,n+2,i,o,r),e.fW(d,n+3,i,o,r);}const[i,o,r]=t.point;e.bl(h,i,o,r,t.angle);};if(I>1){const e=Pi(b,l,w,T,o,u,_,t,c,s,f,m,!1,g,v,y,x);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[n,s,l]=e.last.point;[i,o]=Di(i,o,r,a),[n,s]=Di(n,s,l,a);const c=Mi(R,D,(n-i)*p,s-o);if(t.flipState=c&&c.needsFlipping?1:2,c)return c}L(e.first);for(let e=S+1;e0?s:ki(_,r,i,1,n,void 0,g,v.canonical),l=Mi(R,D,(a[0]-i[0])*p,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=Bi(b*l.getoffsetX(S),w,T,o,u,_,C,E,A,c,s,f,m,!1,!1,g,v,y,x);if(!i)return {notEnoughRoom:!0};L(i);}return {}}function zi(e,t,i,o,r){const{x:n,y:s,z:a}=o.projectTilePoint(e.x,e.y,t);if(!r)return Di(n,s,a,i);const[l,c,h]=r.getElevation(e,r.elevation,r.elevationFeature);return Di(n+l,s+c,a+h,i)}function ki(t,i,o,r,n,s,a,l){const c=zi(t.sub(i)._unit()._add(t),l,n,a,s);return e.fx(c,o,c),e.ex(c,c),e.fe(c,o,c,r)}function Bi(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y){const x=r?t-i:t+i;let b=x>0?1:-1,w=0;r&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=l+a+(b>0?0:1)|0,E=n,S=n,I=0,C=0;const R=Math.abs(x),D=[],A=[];let L=s,O=L,P=e.g0([]);const M=()=>ki(O,L,S,R-I+1,d,_,m,g.canonical);for(;I+C<=R;){if(T+=b,T=c)return null;if(S=E,O=L,D.push(S),f&&A.push(O),L=new e.au(h.getx(T),h.gety(T)),E=u[T],!E){const e=zi(L,g.canonical,d,m,_);E=e[3]>0?u[T]=e:M();}I+=C;const t=e.fx([],E,S),i=e.c5(S,E);if(o&&i>0&&C>0&&e.c7(P,t)/(C*i)0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e);}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let r=0,n=0;for(let s=0;s{const a=e.bz(i,t,o,r,s);l.has(a)||(n.push(new e.ap(t,i,o,r,s)),l.add(a));};for(let e=0;en.canonical.z)continue;const l=n.canonical,h=n.overscaledZ,d=n.wrap,u=1<0,p=l.y+10,g=n.wrap-(f?0:1),v=n.wrap+(_?0:1),y=f?l.x-1:u-1,x=_?l.x+1:0;if(s)o[0]<0?(c(h,v,l.z,x,l.y),o[1]<0&&p&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))):o[0]>0?(c(h,g,l.z,y,l.y),o[1]<0&&p&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))):o[1]<0&&p?c(h,d,l.z,l.x,l.y+1):m&&c(h,d,l.z,l.x,l.y-1);else {const e=n.visibleQuadrants;1&e&&(c(h,g,l.z,y,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))),2&e&&(c(h,v,l.z,x,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))),4&e&&(c(h,g,l.z,y,l.y),p&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1))),8&e&&(c(h,v,l.z,x,l.y),p&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)));}}const h=[];for(const e of n)n.some(t=>e.isChildOf(t))||h.push(e);if(n=h.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-o[0],i=e.canonical.y+.5-o[1];return t*t+i*i{const l=e.bz(i,t,o,s,a);n.has(l)||(r.push(new e.ap(t,i,o,s,a)),n.add(l));},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),o),l=1<{const r=Math.floor(t[0]),n=Math.floor(t[1]),u=(t[0]-r)*e.r,_=(t[1]-n)*e.r,f=Math.floor(i[0]),p=Math.floor(i[1]),m=(i[0]-f)*e.r,g=(i[1]-p)*e.r;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){h.x=u-t*e.r,d.x=m-(i-f)*e.r;for(let t=-1;t<=1;t++){const r=n+t;h.y=_-t*e.r,d.y=g-(r-p)*e.r,e.ce(h,d,c)&&s(a,0,o,i,r);}}}},_=i.points,f=_[e.ak],p=_[e.al],m=this._projectToGround(f,_[e.F]),g=this._projectToGround(p,_[e.z]);return u(f,m),u(p,g),r}_projectToGround(t,i){return e.dZ(e.bU(),t,i,t[2]/(t[2]-i[2]))}_projectToZ(t,i,o){const r=t[2]-i[2];return Math.abs(r)<1e-6?e.bK(t):e.dZ(e.bU(),t,i,(t[2]-o)/r)}extendTileCoverForTunnels(t,i,o,r){if(o<18)return [];const n=i.points,s=n[e.am],a=n[e.an],l=n[e.G],c=n[e.H];if(l[2]>=0&&c[2]>=0||s[2]<=0||a[2]<=0)return [];const h=l[2]<0?this._projectToZ(s,l,0):l,d=c[2]<0?this._projectToZ(a,c,0):c,u=-r,_=l[2]3&&(p.length=3),p}_findExtensionTilesInQuad(t,i,o,r){const n=[],s=new Set;for(const e of t)s.add(e.key);const a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),i),l=1<{const i=e.canonical.x+.5-w,o=e.canonical.y+.5-T,r=t.canonical.x+.5-w,n=t.canonical.y+.5-T;return i*i+o*o-(r*r+n*n)||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y}),n}coveringTiles(t){let i=this.coveringZoomLevel(t);const o=i,r=this.elevation&&this.elevation.exaggeration(),n=r&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,o=new e.ag(t.x+i,t.y,t.z),r=new e.ag(t.x,t.y+i,t.z),n=t.toLngLat(),s=o.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(n),c=this.locationCoordinate(s),h=this.locationCoordinate(a),d=Math.hypot(c.x-l.x,c.y-l.y),u=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(d*u)*T/i},S=t=>{const i=b,o=w;return {aabb:e.fE(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},I=[];let C=[];const R=i,D=t.reparseOverscaled?o:i,A=(m-this._centerAltitude)*p,L=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=P(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},O=(e,t)=>{if(.707*t{if(t.zoom=.9)return !0}else if(n&&(a=t.aabb.distanceZ(g)*p),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.ag((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!s&&!d){const e=Math.sqrt(i*i+r*r+a*a);let o=(1<0;){const o=I.pop(),r=o.x,a=o.y;let l=o.fullyVisible;const u=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<n)continue;let s=0;if(!l){let i=v?o.aabb.intersectsPrecise(_):o.aabb.intersectsPreciseFlat(_);if(0===i&&u()){const t=new e.f(o.zoom,r,a);i=e.bi(this,c,t,!0).intersectsPrecise(_);}if(0===i)continue;if(t.calculateQuadrantVisibility)if(_.containsPoint(o.aabb.center))s=15;else for(let e=0;e<4;e++)0!==o.aabb.quadrant(e).intersects(_)&&(s|=1<>1),u={aabb:s?o.aabb.quadrant(t):e.fE(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};n&&!d&&(u.tileID=new e.ap(o.zoom+1===R?D:o.zoom+1,o.wrap,o.zoom+1,i,h),L(u)),I.push(u);}}if(this.fogCullDistSq){const i=this.fogCullDistSq,o=this.horizonLineFromTop();C=C.filter(r=>{const n=[0,0,0,1],s=[e.r,e.r,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.fM(n,n,a),e.fM(s,s,a);const l=e.en([],n,s),c=e.ee([],n,s),h=e.cD(l,c);if(0===h)return !0;let d=!1;const u=this._elevation;if(u&&h>i&&0!==o){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;t.isTerrainDEM||(n=u.getMinMaxForTile(r.tileID)),n||(n={min:w,max:b});const s=e.cC(this.rotation),a=[s[0]*e.r,s[1]*e.r,n.max];e.fL(a,a,i),d=(1-a[1])*this.height*.5e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(t){const i=e.bG(t.lat,-e.ae,e.ae),o=this.projection.project(t.lng,i);return new e.au(o.x*this.worldSize,o.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.em(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;o=(i.x-n.x)/e,r=(i.y-n.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(n);o=e.x-t.x,r=e.y-t.y;}const s=this.locationCoordinate(t);this.setLocation(new e.ag(s.x-o,s.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const o=i?e.em(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ag(r.x,r.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],n=[t.x,t.y,1,1];e.fM(r,r,this.pixelMatrixInverse),e.fM(n,n,this.pixelMatrixInverse);const s=n[3];e.fb(r,r,1/r[3]),e.fb(n,n,1/s);const a=r[2],l=n[2];return {p0:r,p1:n,t:a===l?0:(o-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.fM(i,i,this.pixelMatrixInverse),e.fM(o,o,this.pixelMatrixInverse),e.fb(i,i,1/i[3]),e.fb(o,o,1/o[3]),i[2]=e.em(i[2],this._center.lat)*this.worldSize,o[2]=e.em(o[2],this._center.lat)*this.worldSize,e.fb(i,i,1/this.worldSize),e.fb(o,o,1/this.worldSize),new e.aB([i[0],i[1],i[2]],e.ex([],e.fx([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:r}=t,n=e.em(i[2],this._center.lat),s=e.em(o[2],this._center.lat);return new e.ag(e.dY(i[0],o[0],r)/this.worldSize,e.dY(i[1],o[1],r)/this.worldSize,e.dY(n,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let o=this.projection.pointCoordinate3D(this,t.x,t.y);if(o)return new e.ag(o[0],o[1],o[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t,i);const s=.02*n,a=t.clone();for(let t=0;t<10&&n-r>s;t++){a.y=e.dY(r,n,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(n=a.y,o=t):r=a.y;}return o?new e.ag(o[0],o[1],o[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return !1;if(this.elevation||this.zoom>=e.R)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.fM(r,r,this.pixelMatrix),r[3]>0?new e.au(r[0]/r[3],r[1]/r[3]):new e.au(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,n=this.pointLocation3D(new e.au(i,t)),s=this.pointLocation3D(new e.au(r,t)),a=this.pointLocation3D(new e.au(r,o)),l=this.pointLocation3D(new e.au(i,o));let c=Math.min(n.lng,s.lng,a.lng,l.lng),h=Math.max(n.lng,s.lng,a.lng,l.lng),d=Math.min(n.lat,s.lat,a.lat,l.lat),u=Math.max(n.lat,s.lat,a.lat,l.lat);const _=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,p=(t,i,o,r,n)=>{const s=(t+o)/2,a=(i+r)/2,l=new e.au(s,a),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,d-g,m-h,g-u);c=Math.min(c,m),h=Math.max(h,m),d=Math.min(d,g),u=Math.max(u,g),(n_)&&(p(t,i,s,a,n+1),p(s,a,o,r,n+1));};if(p(i,t,r,t,1),p(r,t,r,o,1),p(r,o,i,o,1),p(i,o,i,t,1),"globe"===this.projection.name){const[t,i]=e.eK(this);t?(u=90,h=180,c=-180):i&&(d=-90,h=180,c=-180);}return new e.ac(new e.ab(c,d),new e.ab(h,u))}_getBoundsRectangular(t,i){const{top:o,left:r}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.au(r,o),l=new e.au(s,o),c=new e.au(s,n),h=new e.au(r,n);let d=this.pointCoordinate(a,t),u=this.pointCoordinate(l,t);const _=this.pointCoordinate(c,i),f=this.pointCoordinate(h,i),p=(e,t)=>(t.y-e.y)/(t.x-e.x);return d.y>1&&u.y>=0?d=new e.ag((1-f.y)/p(f,d)+f.x,1):d.y<0&&u.y<=1&&(d=new e.ag(-f.y/p(f,d)+f.x,0)),u.y>1&&d.y>=0?u=new e.ag((1-_.y)/p(_,u)+_.x,1):u.y<0&&d.y<=1&&(u=new e.ag(-_.y/p(_,u)+_.x,0)),(new e.ac).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(_))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.ae,this.maxLat=e.ae,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngd&&(a=d-c),d-ht&&(s=t-l),t-e{for(let n=0;n<16;n++)t[n]=e.dY(i[n],o[n],r);})(a,a,l,e.cc(this.pitch>=ji?1:this.pitch/ji));}else a=l;const c=e.eo([],l,s),h=e.eo([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center);e.dq(this._mat4Scratch);const i=this._mat4Scratch;e.fQ(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.er(i,i,e.d1(this)),e.fQ(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.er(h,h,i),e.er(c,c,i),this.inverseAdjustmentMatrix=e.d0(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(e.fc(this.mercatorMatrix,h,[this.worldSize,this.worldSize,this.worldSize/n,1]),this.projMatrix=h,e.dr(this.invProjMatrix,this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,e.eo(this._expandedFarZProjMatrixBuf,i,s),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf;}else this.expandedFarZProjMatrix=this.projMatrix;e.dr(this._mat4Scratch,a),this.frustumCorners=e.O.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.N.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i),e.cv(this.skyboxMatrix,[1,-1,1]),e.f3(this.skyboxMatrix,this.skyboxMatrix,this._pitch),e.f6(this.skyboxMatrix,this.skyboxMatrix,this.angle),e.eE(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);const d=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;e.bS(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-t.x/this.width,this._mat4Scratch[9]=2*(t.y+d)/this.height,e.er(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);const u=this.point,_=u.x,f=u.y,p=this.width%2/2,m=this.height%2/2,g=Math.cos(this.angle),v=Math.sin(this.angle),y=_-Math.round(_)+g*p+v*m,x=f-Math.round(f)+g*m+v*p;if(e.bS(this.alignedProjMatrix,h),e.fQ(this.alignedProjMatrix,this.alignedProjMatrix,[y>.5?y-1:y,x>.5?x-1:x,0]),e.cv(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),e.fQ(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),e.cv(this.glCoordMatrix,[1,-1,1]),e.fQ(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),e.fc(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),e.er(this.pixelMatrix,this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},!e.dr(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if("globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bx(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.fL(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[t,t,i];e.fa(n,n,r),e.fa(o,o,-1),e.es(o,o,n),e.cw(this.mercatorFogMatrix,o),e.fc(this.mercatorFogMatrix,this.mercatorFogMatrix,n),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*r,o.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=this._camera.position[2],r=t[2];let n=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(n=Math.min((i-o)/r,1)),this._camera.position=e.fe([],this._camera.position,t,n),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:r}=this._camera.getPitchBearing(),n=e.em(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.c4(this._maxPitch)),a=Math.max((t[2]-n)/Math.cos(o),s),l=this._zoomFromMercatorZ(a);e.fe(t,t,i,a),this._pitch=e.bG(o,e.c4(this.minPitch),e.c4(this.maxPitch)),this.angle=e.f$(r,-Math.PI,Math.PI),this._setZoom(e.bG(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ag(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.R,r=0,n=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.eX(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.au(0,0),new e.au(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.dW(e.fx([],this._camera.position,t)),r=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,o],r){const n=[t,i,o,1];e.fM(n,n,r);const s=n[3]=Math.max(n[3],1e-6);return n[0]/=s,n[1]/=s,n[2]/=s,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.au(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.au(0,t))}}getCameraToCenterDistance(t,i=this.zoom,o=this.worldSize){const r=e.d2(t,i,this.width,this.height,1024),n=t.pixelSpaceConversion(this.center.lat,o,r);let s=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(s=e.dY(1,s,e.cc(this.pitch>=ji?1:this.pitch/ji))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.er(t,t,this.globeMatrix),t}getFrustum(t){return e.N.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const Vi=(t,i)=>{if(i<=0||t.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=t.transform,r=o.pitch,n=o.isLODDisabled(!1)?60:30;if(r0,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(d-o._nearZ)/s,(d-u-o._nearZ)/s]}}},Hi=7680;class Wi{constructor(e,t,i,o,r,n){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=r,this.pass=n;}}Wi.disabled=new Wi({func:519,mask:0},0,0,Hi,Hi,Hi);const Zi=770,qi=771;class $i{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=o;}}function Xi(t,i,o=0){const r=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=n*(i.tileID.canonical.x+i.tileID.wrap*r),a=n*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.eG(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:o}}$i.Replace=[1,0,1,0],$i.disabled=new $i($i.Replace,e.i.transparent,[!1,!1,!1,!1]),$i.unblended=new $i($i.Replace,e.i.transparent,[!0,!0,!0,!0]),$i.alphaBlended=new $i([1,qi,1,qi],e.i.transparent,[!0,!0,!0,!0]),$i.alphaBlendedNonPremultiplied=new $i([Zi,qi,Zi,qi],e.i.transparent,[!0,!0,!0,!0]),$i.multiply=new $i([774,0,774,0],e.i.transparent,[!0,!0,!0,!0]),$i.multiplyAccumulateAlpha=new $i([774,0,1,qi],e.i.transparent,[!0,!0,!0,!0]),$i.additive=new $i([1,1,1,1],e.i.transparent,[!0,!0,!0,!0]),$i.additiveAlphaWeighted=new $i([Zi,1,773,1],e.i.transparent,[!0,!0,!0,!0]),$i.additiveAlphaWeightedUnboundedAlpha=new $i([Zi,1,1,1],e.i.transparent,[!0,!0,!0,!0]);const Yi={terrain:0,flat:1},Ki=e.bT(),Qi=(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y=[0,0,1])=>{const x=i.style.light,b=x.properties.get("position"),w=[b.x,b.y,b.z],T=e.bV();"viewport"===x.properties.get("anchor")&&(e.cu(T,-i.transform.angle),e.fK(w,w,T));const E=x.properties.get("color").toPremultipliedRenderColor(null),S=i.transform,I={u_matrix:t,u_lightpos:w,u_lightintensity:x.properties.get("intensity"),u_lightcolor:[E.r,E.g,E.b],u_vertical_gradient:+o,u_opacity:r,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,u_height_type:Yi[h],u_base_type:Yi[d],u_ao:n,u_edge_radius:s,u_width_scale:a,u_flood_light_color:p,u_vertical_scale:m,u_flood_light_intensity:g,u_ground_shadow_factor:v,u_front_cutoff_params:y};return "globe"===S.projection.name&&(I.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:o,u_height_type:Yi[r],u_base_type:Yi[n]}),eo=(e,t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g)=>{const v=Qi(e,t,i,o,r,n,s,a,c,h,d,u,_,f,p,m,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(v,Xi(t,l,g),y)},to=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),io=[];function oo(e){return io[e]=io[e]||new Float64Array(16)}const ro=[],no=new Float32Array(16);class so{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class ao{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new so(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const r=e.A.fromPoints(t.points);let n=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!r.intersectsAabb(s.aabb))continue;s.aabb.min=r.closestPoint(s.aabb.min),s.aabb.max=r.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){r=!1;break}}if(s.lastCascade=t,n=Math.max(n,t),r)break}}return n+1}}class lo{constructor(e){this.painter=e,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new ao,this._depthMode=new vi(e.context.gl.LEQUAL,vi.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(t,i){const o=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity"),n=i.properties.get("shadow-draw-before-layer");if(!i.shadowsEnabled()||r<=0)return;let s=-1,a=0;for(const e of o.style.order){const i=o.style._mergedLayers[e];i.hasShadowPass()&&!i.isHidden(t.zoom)&&(s=a),!n||n!==e&&n!==i.slot||(this._drawShadowAfterLayer=a>0?a-1:0),a+=1;}if(this._enabled=s>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=s);const l=o.context,c=this._shadowParameters.shadowMapResolution,h=this._shadowParameters.shadowMapResolution;if(0===this._cascades.length||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.dem).forEach(e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);}),1e4!==i[0]&&(d=(i[1]-i[0])*e.exaggeration());}const u=1.5*t.cameraToCenterDistance,_=3*u,f=new Float64Array(16);for(let i=0;i=0)return {};const n=function(t,i,o){const r=o/(1<0&&(e.bj(n[1],n[1],[r[0]*s,0,0]),e.bj(n[2],n[2],[r[0]*s,0,0])),r[1]<0?(e.bj(n[0],n[0],[0,r[1]*s,0]),e.bj(n[1],n[1],[0,r[1]*s,0])):r[1]>0&&(e.bj(n[2],n[2],[0,r[1]*s,0]),e.bj(n[3],n[3],[0,r[1]*s,0]));const a={};return a.vertices=n,a.planes=[co(n[1],n[0],n[4]),co(n[2],n[1],n[5]),co(n[3],n[2],n[6]),co(n[0],n[3],n[7])],a}addShadowReceiver(t,i,o){this._receivers.add(t,e.A.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function co(t,i,o){const r=e.fx([],o,i),n=e.fx([],t,i),s=e.c1([],r,n),a=e.dW(s);return 0===a?[0,0,1,0]:(e.fa(s,s,1/a),[s[0],s[1],s[2],-e.c7(s,i)])}function ho(t){const i=t.properties.get("direction"),o=e.bB(i.x,i.y,i.z);o[2]=e.bG(o[2],0,75);const r=e.ft([o[0],o[1],o[2]]);return e.cx(r.x,r.y,r.z)}function uo(t,i,o){const r="none"===i.properties.get("color-use-theme"),n=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===o.properties.get("color-use-theme"),h=o.properties.get("color"),d=o.properties.get("intensity"),u=Math.max(e.c7([0,0,1],l),0),_=[0,0,0];e.fa(_,h.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),d);const f=[0,0,0];return e.fa(f,n.toPremultipliedRenderColor(r?null:t.getLut(o.scope)).toArray01Linear().slice(0,3),u*s),e.e4([_[0]>0?_[0]/(_[0]+f[0]):0,_[1]>0?_[1]/(_[1]+f[1]):0,_[2]>0?_[2]/(_[2]+f[2]):0])}function _o(t,i,o,r,n,s){const a=t.zoom,l=t.scale,c=t.worldSize,h=1/c,d=t.aspect,u=Math.sqrt(1+d*d)*Math.tan(.5*t.fovX),_=u*u,f=r-o,p=r+o;let m,g;_>f/p?(m=r,g=r*u):(m=.5*p*(1+_),g=.5*Math.sqrt(f*f+2*(r*r+o*o)*_+p*p*_*_));const v=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),x=[0,0,-m*h];e.fL(x,x,y);let b=g*h;const w=function(i){return i[0]/=l,i[1]/=l,i[2]=e.em(i[2],t._center.lat),i},T=t._edgeInsets;if(!(0===T.left&&0===T.top&&0===T.right&&0===T.bottom||T.left===T.right&&T.top===T.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?v:1),n=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,r);n[8]=2*-t.centerOffset.x/t.width,n[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.eo(s,n,i);const l=new Float64Array(16);e.dr(l,s);const h=e.N.fromInvProjectionMatrix(l,c,a,!0);for(const t of h.points){const i=w(t);b=Math.max(b,e.dV(e.fz([],x,i)));}}b*=n/(n-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),I=new Ei;I.position=x,I.setPitchBearing(E,S);const C=I.getWorldToCamera(c,v),R=b*c,D=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*R),A=I.getCameraToClipOrthographic(-R,R,-R,R,D,(R+s*v)/i[2]),L=new Float64Array(16);e.er(L,A,C);const O=e.cx(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),P=.5*n,M=[0,0,0];e.fL(M,O,L),e.fa(M,M,P);const F=[Math.floor(M[0]),Math.floor(M[1]),Math.floor(M[2])],z=[0,0,0];e.fx(z,M,F),e.fa(z,z,-1/P);const k=new Float64Array(16);return e.dq(k),e.fQ(k,k,z),e.er(L,k,L),[L,R]}const fo=new Float32Array(16);function po(t,i,o,r,n,s,a,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,d=t.transform,u=o.paint.get("fill-extrusion-pattern"),_=o.paint.get("fill-extrusion-pattern-cross-fade"),f=u.constantOr(null),p=u.constantOr(1),m=o.paint.get("fill-extrusion-opacity"),g=t.style.enable3dLights(),v=o.paint.get(g&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),v],x=o.layout.get("fill-extrusion-edge-radius"),b=x>0&&!o.paint.get("fill-extrusion-rounded-roof"),w=b?0:x,T="globe"===d.projection.name?e.cq():0,E="globe"===d.projection.name,S=E?e.dm(d.zoom):0,I=[e.ek(d.center.lng),e.el(d.center.lat)],C="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),R=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(C?null:o.lut).toArray01().slice(0,3),D=o.paint.get("fill-extrusion-flood-light-intensity"),A=o.paint.get("fill-extrusion-vertical-scale"),L=0!==o.paint.get("fill-extrusion-line-width").constantOr(1),O=o.paint.get("fill-extrusion-height-alignment"),P=o.paint.get("fill-extrusion-base-alignment"),M=Vi(t,o.paint.get("fill-extrusion-cutoff-fade-range")),F=o.paint.get("fill-extrusion-front-cutoff"),z=go(d.pitch,F,!!t.terrain),k=z[2]<1;k&&(t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,F[0]));const B=[];let N;E&&B.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&B.push("FAUX_AO"),b&&B.push("ZERO_ROOF_RADIUS"),l&&B.push("HAS_CENTROID"),D>0&&B.push("FLOOD_LIGHT"),M.shouldRenderCutoff&&B.push("RENDER_CUTOFF"),k&&B.push("RENDER_FRONT_CUTOFF"),L&&B.push("RENDER_WALL_MODE");const U="shadow"===t.renderPass,j=t.shadowRenderer,G=U&&!!j,V=U?gi.disabled:gi.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let H=[0,0,0];if(j){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(H=uo(t.style,e,i)),U||(B.push("RENDER_SHADOWS"),j.useNormalOffset&&B.push("NORMAL_OFFSET")),N=B.concat(["SHADOWS_SINGLE_CASCADE"]);}const W=G?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",Z=o.getLayerRenderingStats();for(const u of r){const r=i.getTile(u),g=r.getBucket(o);if(!g||g.projection.name!==d.projection.name)continue;let v=!1;j&&(v=0===j.getMaxCascadeForTile(u.toUnwrapped()));const x=t.isTileAffectedByFog(u),b=g.programConfigurations.get(o.id);let C=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.aG.from(f),o=i.getPrimary().scaleSelf(e.co.devicePixelRatio).toString(),n=i.getSecondary(),s=t.patternPositions.get(o),a=n?t.patternPositions.get(n.scaleSelf(e.co.devicePixelRatio).toString()):null;C=!!s&&!!a,s&&b.setConstantPatternPositions(s,a);}_>0&&(C||b.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&B.push("FILL_EXTRUSION_PATTERN_TRANSITION");const F=t.getOrCreateProgram(W,{config:b,defines:v?N:B,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(r,F,{useMeterToDem:!0}),!g.centroidVertexBuffer){const e=F.getAttributeLocation(h,"a_centroid_pos");-1!==e&&h.vertexAttribI4ui(e,0,0,0,0);}!U&&j&&j.setupShadows(r.tileID.toUnwrapped(),F,"vector-tile"),p&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers());const k=o.paint.get("fill-extrusion-vertical-gradient"),G=1/g.tileToMeter;let q;if(U&&j){if(To(r.tileID,g.maxHeight,t))continue;const e=j.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());q=Ji(e,w,G,A,O,P);}else {const e=t.translatePosMatrix(u.expandedProjMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=d.projection.createInversionMatrix(d,u.canonical);q=p?eo(e,t,k,m,y,w,G,u,r,T,O,P,S,I,i,R,A,_):Qi(e,t,k,m,y,w,G,u,T,O,P,S,I,i,R,A,D,H,z);}t.uploadCommonUniforms(c,F,u.toUnwrapped(),null,M);let $=g.segments;if("mercator"===d.projection.name&&!U&&($=g.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!$.get().length))continue;if(Z)if(U)for(const e of $.get())Z.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of $.get())Z.numRenderedVerticesInTransparentPass+=e.primitiveLength;const X=[];(t.terrain||l)&&X.push(g.centroidVertexBuffer),E&&X.push(g.layoutVertexExtBuffer),L&&X.push(g.wallVertexBuffer),F.draw(t,c.gl.TRIANGLES,n,s,a,V,q,o.id,g.layoutVertexBuffer,g.indexBuffer,$,o.paint,t.transform.zoom,b,X);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}class mo{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0;}}function go(e,t,i){if(!(t[2]<1)||i)return [0,0,1];const o=180*e/Math.PI;if(o<15)return [-.5,t[1],t[2]];const r=Math.min(1,Math.max(0,(o-15)/5)),n=r*r*(3-2*r);return [-.5*(1-n)+t[0]*n,t[1],t[2]]}function vo(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y,x,b){const w=i.context,T=w.gl,E=i.transform,S=i.transform.zoom,I=[],C=t.translate,R=t.translateAnchor,D=t.edgeRadius,A=Vi(i,t.cutoffFadeRange);"clear"===d?(I.push("CLEAR_SUBPASS"),x&&(I.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE))):"sdf"===d?I.push("SDF_SUBPASS"):"emissive"===d&&(I.push("USE_MRT1"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE)),v&&I.push("HAS_CENTROID"),A.shouldRenderCutoff&&I.push("RENDER_CUTOFF");const L=(e,t,o,n,d)=>{let y=I;null!=t.groundRadiusBuffer&&(y=I.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),T=i.isTileAffectedByFog(e),E=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:T}),C=((e,t,i,o,r,n,s,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:o?1:0,u_meter_to_tile:r,u_ao:n,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h,u_dynamic_offset:1}))(0,n,u,h,d,[_,f*d],p,m,g,S>=17?0:D*d,x?x.size[0]:0),R=[];v&&R.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&R.push(t.groundRadiusBuffer),i.uploadCommonUniforms(w,E,e.toUnwrapped(),null,A),E.draw(i,w.gl.TRIANGLES,s,a,l,c,C,r.id,t.vertexBuffer,t.indexBuffer,o,r.paint,S,b,R);};for(const t of n){const n=o.getTile(t),s=n.getBucket(r);if(!s||s.projection.name!==E.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,n,C,R),o=a.getDefaultSegment();L(t,a,o,e,l);}if(y)for(let s=0;s<4;s++){const a=e.ev[s](t),c=o.getTile(a);if(!c)continue;const h=c.getBucket(r);if(!h||h.projection.name!==E.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const d=h.groundEffect;let u,_;0===s?(u=[-e.r,0,0],_=1):1===s?(u=[e.r,0,0],_=0):2===s?(u=[0,-e.r,0],_=3):(u=[0,e.r,0],_=2);const f=d.regionSegments[_];f&&(e.fQ(fo,t.projMatrix,u),L(t,d,f,i.translatePosMatrix(fo,n,C,R),l));}}}function yo(t,i,o,r,n,s,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=s?s.findDEMTileFor(o):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=(t,i)=>{(t.flags|i.flags)&e.Y?(t.flags|=e.Y,i.flags|=e.Y):(t.flags&=~e.Y,i.flags&=~e.Y);},h=t=>new e.au(Math.ceil((t+e.E)*e.q),0),d=(t,i,o)=>{const r=Math.ceil((t+e.E)*e.q),n=Math.floor(Math.max(0,Math.min(e.r-1,o))/4);return new e.au(r,n<<5|(3&i)<<3|7)},u=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(n)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(_[0]=Math.min(t.min.y,i.min.y),_[1]=Math.max(t.max.y,i.max.y),_[2]=e.r-i.min.x>t.max.x?i.min.x-e.r:t.max.x,_),p=(t,i)=>(_[0]=Math.min(t.min.x,i.min.x),_[1]=Math.max(t.max.x,i.max.x),_[2]=e.r-i.min.y>t.max.y?i.min.y-e.r:t.max.y,_),m=[(e,t)=>f(e,t),(e,t)=>f(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],g=(t,i,r,n,a,c,h)=>{if(!s)return 0;const d=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],u=h<0?e.r+h:h,_=[c?u:(t+i)/2,c?(t+i)/2:u,0];return 0===r&&h<0||0!==r&&h>0?s.getForTilePoints(a,[_],!0,n):d.push(_),s.getForTilePoints(o,d,!0,l),Math.max(d[0][2],d[1][2],_[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const n=e.ev[t](o),l=u(n);if(!(l&&l instanceof e.K))continue;const _=s?s.findDEMTileFor(n):null;if(!(_&&_.dem||a))continue;if(s&&_&&_.dem&&r.borderDEMTileTimestamp[t]!==_.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=_.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const f=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[f]!==r.canonical.z,v=l.borderFeatureIndices[f];let y=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(p)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;continue}const x=new Map,b=new Set,w=new Set;for(let e=0;e1||u.intersectsCount()>1;{let i=0;if(_&&_.dem&&!S){const o=m[t](s,p),r=t%2?e.r-1:0;i=g(o[0],Math.min(e.r-1,o[1]),r,_,n,t<2,o[2]);}s.centroidXY=d(i,t,E),p.centroidXY=d(i,f,E);}if(r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(p),void 0!==i.buildingId){for(const e of r.centroidData)e.buildingId===i.buildingId&&e!==s&&(e.centroidXY=s.centroidXY,r.writeCentroidToBuffer(e));for(const e of l.centroidData)e.buildingId===i.buildingId&&e!==p&&(e.centroidXY=p.centroidXY,l.writeCentroidToBuffer(e));}}for(const o of i){if(b.has(o))continue;const i=r.featuresOnBorder[o],s=r.centroidData.get(i.centroidDataIndex),d=i.borders[t];let u;for(;yd[0]+3||e[0]>d[0]-3)break;l.showCentroid(u),y++;}if(u&&yd[1]-3)break;if(p++,++y===v.length)break;u=l.featuresOnBorder[v[y]];}for(;o=v.length){r.showCentroid(i);continue}u=l.featuresOnBorder[v[o]];let x=!1;if(p>=1){const e=u.borders[f];Math.abs(d[0]-e[0])<3&&Math.abs(d[1]-e[1])<3&&(p=1,x=!0,y=o+1);}else if(0===p){r.showCentroid(i);continue}const b=l.centroidData.get(u.centroidDataIndex);a&&x&&c(s,b);const T=i.intersectsCount()>1||u.intersectsCount()>1;if(p>1)y=o,s.centroidXY=b.centroidXY=new e.au(0,0);else if(_&&_.dem&&!T){const i=m[t](s,b),o=t%2?e.r-1:0,r=g(i[0],Math.min(e.r-1,i[1]),o,_,n,t<2,i[2]);s.centroidXY=b.centroidXY=h(r);}else T?s.centroidXY=b.centroidXY=new e.au(0,0):(s.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(u));r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const xo=[1,0,0],bo=[0,1,0],wo=[0,0,1];function To(t,i,o){const r=o.transform,n=o.shadowRenderer;if(!n)return !0;const s=o.frameCounter,a=o.currentShadowCascade;let l=o._shadowCullCache;if(!l||l.frame!==s||l.cascade!==a){const t=r.tileSize*n._cascades[a].scale,i=r.scaleZoom(t),c=n.shadowDirection,h=[c[0],c[1],-c[2]],d=[xo,bo,wo,h,[h[0],0,h[2]],[0,h[1],h[2]]];l={frame:s,cascade:a,cameraFrustum:e.N.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,i,!("globe"===r.projection.name)),edges:d,shadowDir:h,ws:t,zoom:i},o._shadowCullCache=l;}const{cameraFrustum:c,edges:h,shadowDir:d,ws:u,zoom:_}=l;let f=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(f+=e.max);}f/=e.cX(r.center.lat,_);const p=n.computeSimplifiedTileShadowVolume(t.toUnwrapped(),f,u,d);if(!p)return !1;const{vertices:m,planes:g}=p;return 0===c.intersectsPrecise(m,g,h)||0===n.getCurrentCascadeFrustum().intersectsPrecise(m,g,h)}const Eo=new Float32Array(16),So=new Float32Array(16);function Io(t){const{painter:i,source:o,layer:r,coords:n}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,h=i.shadowRenderer,d=e.cX(i.transform.center.lat,i.transform.zoom),u=Vi(i,r.paint.get("building-cutoff-fade-range"));u.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF"));const _=r.paint.get("building-front-cutoff"),f=_[2]<1&&!i.terrain,p=go(i.transform.pitch,_,!!i.terrain);f&&(s=s.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,_[0])),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const _ of n){const n=o.getTile(_),f=n.getBucket(r);if(!f)continue;h&&0===h.getMaxCascadeForTile(_.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=f.programConfigurations.get(r.id);let g,v;const y=i.translatePosMatrix(_.expandedProjMatrix,n,[0,0],"map");e.fc(Eo,y,[1,1,t.verticalScale]);const x=Eo;let b;if(l&&h){if(To(n.tileID,f.maxHeight*d,i))continue;const o=h.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());e.fc(o,o,[1,1,t.verticalScale]),b=fi(o),g=v=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1});}else if(c)g=v=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),b=_i(x);else {const o=i.transform.calculatePosMatrix(_.toUnwrapped(),i.transform.worldSize);e.fc(o,o,[1,1,t.verticalScale]),e.fc(So,o,[1,-1,1/d]),e.dr(So,So),e.fR(So,So);const r=So,n=i.transform.getFreeCameraOptions().position,l=1<<_.canonical.z;if(b=ui(x,r,t.opacity,t.facadeAOIntensity,[((n.x-_.wrap)*l-_.canonical.x)*e.r,(n.y*l-_.canonical.y)*e.r,n.z*l*e.r],f.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity,p),v=i.getOrCreateProgram("building",{config:m,defines:s,overrideFog:!1}),!0===t.depthOnly)g=v;else {const e=s.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);g=i.getOrCreateProgram("building",{config:m,defines:e,overrideFog:!1});}h&&(h.setupShadowsFromMatrix(o,v,!0),g!==v&&g.setShadowUniformValues(a,h.getShadowUniformValues()));}const w=(e,o)=>{if(c){const n=e.entranceBloom;o.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,gi.disabled,b,r.id,n.layoutVertexBuffer,n.indexBuffer,n.segmentsBucket,r.paint,i.transform.zoom,m,[n.layoutAttenuationBuffer,n.layoutColorBuffer]);}else {const n=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),o.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,l?gi.disabled:gi.backCW,b,r.id,e.layoutVertexBuffer,e.indexBuffer,n,r.paint,i.transform.zoom,m,s);}};i.uploadCommonUniforms(a,v,_.toUnwrapped(),null,u),f.buildingWithoutFacade&&w(f.buildingWithoutFacade,v),f.buildingWithFacade&&(g!==v&&i.uploadCommonUniforms(a,g,_.toUnwrapped(),null,u),w(f.buildingWithFacade,g));}}function Co(t,i,o,r,n,s,a,l,c,h,d,u,_,f){const p=t.context.gl,m=t.depthModeForSublayer(1,vi.ReadOnly,p.LEQUAL,!0),g=e.dY(.1,3,d),v=t._showOverdrawInspector,y=u,x=new mo;v||vo(x,t,i,o,r,m,new Wi({func:p.ALWAYS,mask:255},255,255,p.KEEP,p.KEEP,p.REPLACE),new $i([p.ONE,p.ONE,p.ONE,p.ONE],e.i.transparent,[!1,!1,!1,!0],p.MIN),gi.disabled,n,"sdf",s,a,l,c,h,g,y,!1,void 0);{const d=v?Wi.disabled:new Wi({func:p.EQUAL,mask:255},255,255,p.KEEP,p.DECR,p.DECR),u=v?t.colorModeForRenderPass():new $i([p.ONE_MINUS_DST_ALPHA,p.DST_ALPHA,p.ONE,p.ONE],e.i.transparent,[!0,!0,!0,!0]);vo(x,t,i,o,r,m,d,u,gi.disabled,n,"color",s,a,l,c,h,g,y,!1,void 0);}}class Ro{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16;}findClosestBuilding(e,t,i,o,r){if(ia*this._hysteresisRatio&&(n=this._previousClosestBuildingId):l&&!n&&(n=this._previousClosestBuildingId),this._previousClosestBuildingId=n,n}_calculateDistance(e,t){if(!t.center)return Number.MAX_VALUE;const i=e.lat-t.center[1],o=e.lng-t.center[0];return i*i+o*o}_isBuildingVisible(t,i,o){if(!o)return !1;for(const i of t.floorIds){const r=t.floors[i];if(!r.geometry)continue;const n=r.geometry;if("Polygon"===n.type){const t=this._convertRingToPoints(n.coordinates[0]);if(e.eO(t,o))return !0}else if("MultiPolygon"===n.type){const t=this._convertMultiPolygonToPoints(n.coordinates);if(e.eN(o,t))return !0}}return !1}_convertRingToPoints(t){return t.map(t=>new e.au(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new e.au(t[0],t[1])))}}const Do=.05,Ao=(e,t,i,o,r,n,s,a,l,c,h,d)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:r,u_tl_parent:n,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Lo=(e,t,i,o,r,n,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:o,u_color_ramp:n,u_velocity_res:r,u_max_speed:s,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Do,Do]}),Oo=(e,t,i,o,r,n,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:o,u_max_speed:r,u_speed_factor:n,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Do,Do]});function Po(e,[t,i,o,r],[n,s]){if(n===s)return [0,0,0,0];const a=255*(e-1)/(e*(s-n));return [t*a,i*a,o*a,r*a]}function Mo(e,t,[i,o]){return i===o?0:.5/e+(t-i)*(e-1)/(e*(o-i))}e.af.setPbf(e.as);class Fo extends e.b0{constructor(e,t,i,o,r){super(e,t,i,o,r),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map;}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(e){return this._mrt&&this._mrt.getLayer(e)}setTexturePerLayer(t,i,o){const r=o.context,n=r.gl;let s=this.texturePerLayer.get(t)||o.getTileTexture(i.width);s&&s instanceof e.a_?s.update(i,{premultiply:!1}):s=new e.a_(r,i,n.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,s);}flushQueues(e){const t=this._workQueuePerLayer.get(e)||[],i=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();for(;i.length;)i.pop()();}flushAllQueues(){for(const e of this._workQueuePerLayer.keys()){const t=this._workQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();}for(const e of this._fetchQueuePerLayer.keys()){const t=this._fetchQueuePerLayer.get(e)||[];for(;t.length;)t.pop()();}}fetchHeader(t=16384,i){const o=this._mrt=new e.af(30),r=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.cG(r,(e,r,n)=>{if(e)i(e);else try{const e=o.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));o.parseHeader(r),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(o.layers))s=Math.max(s,e.dataIndex.at(-1).lastByte);r.byteLength>=s&&(this.entireBuffer=r),i(null,this.entireBuffer||r,n);}catch(e){i(e);}}),this.request}fetchBandForRender(e,t,i,o){this.fetchBand(e,t,i,r=>{if(r)return void o(r);this.updateTextureDescriptor(e,t,i);const n=this.textureDescriptorPerLayer.get(t);o(null,n?n.img:null);});}fetchBand(t,i,o,r,n=!0){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void r(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void r(new Error("Can't fetch tile band without an actor"));let l;const c=e.ea(String(o),e.ea(this.tileID.key,t));let h=this._taskQueue.get(c);h?h.add(r):(h=new Set,h.add(r),this._taskQueue.set(c,h));const d=(e,t)=>{l.complete(e,t),e?r(e):(h.forEach(e=>e(null,t)),this._taskQueue.delete(c));},u=(e,t)=>{if(e)return r(e);const o=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},d,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{o&&o.cancel(),l.cancel();}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e);}};let _;try{_=s.getLayer(t);}catch(e){if("reloading"===this.state)return;throw e}if(!_)return void r(new Error(`Unknown sourceLayer "${t}"`));if(_.hasDataForBand(o))return h.forEach(e=>e(null,null)),void this._taskQueue.delete(c);const f=_.getDataRange([o]);if(l=s.createDecodingTask(f),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)u(null,this.entireBuffer.slice(f.firstByte,f.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${f.firstByte}-${f.lastByte}`}}),o=e.cG(t,u);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{o.cancel(),l.cancel();}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e);}}}updateNeeded(e,t){return (!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,o){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(o)||!r.hasDataForBand(o))return;const{bytes:n,tileSize:s,buffer:a,offset:l,scale:c}=r.getBandView(o),h=s+2*a,d=new e.ay({width:h,height:h},n),u=this.texturePerLayer.get(i);u&&u instanceof e.a_&&u.update(d,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:o,img:d,buffer:a,offset:l,tileSize:s,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]});}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.a_&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1;}}function zo(t,i){const o=Math.pow(2,i.z),r=Math.floor(e.ek(t.getWest())*o),n=Math.floor(e.el(t.getNorth())*o),s=Math.ceil(e.ek(t.getEast())*o),a=Math.ceil(e.el(t.getSouth())*o);return i.x>=r&&i.x=n&&i.ythis.maxzoom||e.z{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.v(i)):o&&(Object.assign(this,o),o.raster_layers&&(this.rasterLayers=o.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=ko.fromTileJSON(o),H(o.tiles),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i);};this.provider="string"==typeof this._options.provider?this._options.provider:void 0,this._tileProvider=void 0;const r=e.f1(this._options);return r instanceof Error?(this._loaded=!0,this.fire(new e.v(r)),void(t&&t())):this.provider&&!r?(this._loaded=!0,this.fire(new e.v(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=r?this.loadTileJSONWithProvider(r,o):e.e7(this._options,this.map._requestManager,null,i,o))}loadTileJSONWithProvider(t,i){this.provider=t.name;const{request:o,options:r}=e.eC(this._options,this.map._requestManager),n=new AbortController;return e.e8(t.name,t.url).then(e=>{if(n.signal.aborted)return;const t=new e(r);return t.load&&o?t.load({request:o}).then(e=>(this._tileProvider=t,e)):(this._tileProvider=t,null)}).then(t=>{if(n.signal.aborted)return;const o=e.eW(this._options,t,this.map._requestManager);o instanceof Error?i(o):i(null,o);}).catch(e=>{n.signal.aborted||i(e instanceof Error?e:new Error(String(e)));}),{cancel:()=>n.abort()}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.ea(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return Object.assign({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.co.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize),n=this.map._requestManager.transformRequest(r,e.aH.Tile);if(this._tileProvider){const e=new AbortController;t.request={cancel:()=>e.abort()},this.loadTileWithProvider(t,this._tileProvider,n,e,i);}else t.request=e.cQ(n,(o,r,n)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(o)return t.state="errored",i(o);if(!r)return i(null);const s=e.cO(n);this.map._refreshExpiredTiles&&t.setExpiryData(s),t.setTexture(r,this.map.painter),t.state="loaded",e.bv(this.dispatcher),i(null);});}async loadTileWithProvider(e,t,i,o,r){const{z:n,x:s,y:a}=e.tileID.canonical;try{const l=await t.loadTile({z:n,x:s,y:a},{request:i,signal:o.signal});if(o.signal.aborted)return e.state="unloaded",r(null);if(null==l){const t=new Error("Tile not found");return t.status=404,e.state="errored",r(t)}if(null==l.data)return e.state="loaded",r(null);const c=l.data instanceof ImageBitmap?l.data:await createImageBitmap(new Blob([l.data]));if(o.signal.aborted)return e.state="unloaded",r(null);e.setTexture(c,this.map.painter),e.state="loaded",this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:l.cacheControl,expires:l.expires}),r(null);}catch(t){if(o.signal.aborted)return e.state="unloaded",r(null);if(t instanceof DOMException&&"AbortError"===t.name)return e.state="unloaded",r(null);e.state="errored",r(t instanceof Error?t:new Error(String(t)));}finally{delete e.request;}}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t();}unloadTile(t,i){t.texture&&t.texture instanceof e.a_?(t.destroy(!1),t.texture&&t.texture instanceof e.a_&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function No([t,i],o,r,{scaled:n=!0}={}){const{tileSize:s,buffer:a}=r,{x:l,y:c,z:h}=o;if(!isFinite(l)||!isFinite(c)||!isFinite(h))throw new Error("Invalid MRT header");const d=2**h,u=d*e.ek(t),_=d*e.el(i);return function([e,t],i,{scaled:o=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:n,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>n+s||t<-s||t>n+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${n}, buffer=${s}`);const h=(t+s)*(n+2*s)+(e+s);if(4294967295===new Uint32Array(r.buffer)[h])return null;let d=[];d=o?[]:new(0,i.data.constructor)(c);for(let e=0;e{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(o){if("AbortError"===o.name)return;return t.state="errored",i(o)}if(this.map._refreshExpiredTiles&&r){const i=e.cO(n);t.setExpiryData(i);}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r;}i(null);};t.request=this.partial?t.fetchHeader(void 0,s.bind(this)):t.actor.send("loadTile",n,s.bind(this),void 0,!0);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!1);for(const e of i.values())this.map.painter.saveTileTexture(e);}else e.destroy();}prepareTile(t,i,o,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,o,r,(i,r)=>{i?(t.state="errored",this.fire(new e.v(i))):r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(o,r,this.map.painter),t.state="loaded"),this.triggerRepaint(t);}));}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let n=null;i instanceof e.aA?n=i.paint.get("raster-array-band"):i instanceof e.az&&(n=i.paint.get("raster-particle-array-band"));const s=n||this.getInitialBand(r);if(null==s)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,r,i.id,s);if(t.updateNeeded(i.id,s)&&!o)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const o=new Map;for(const r of t)for(const t of i){const[i,n]=t.split("/"),s=r.getLayer(i);if(!s)continue;if(!s.hasBand(n)||!s.hasDataForBand(n))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(n),h=l+2*c,d={data:new e.ay({width:h,height:h},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};o.set(t,d);}return o}queryRasterArrayValueByBandId(t,i,o){const r=i._mrt;return new Promise(n=>{const s={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(o.layerName&&l!==o.layerName)continue;const h={};s[l]=h;for(const{bands:d}of c.dataIndex)for(const u of d)o.bands&&!o.bands.includes(u)||(a.add(e.ea(l,u)),i.fetchBand(l,null,u,i=>{e.co.frame(()=>{h[u]=i?null:No([t.lng,t.lat],r,c.getBandView(u)),a.delete(e.ea(l,u)),0===a.size&&n(s);});},!1));}0===a.size&&n(s);})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.aH.Tile);t.actor.send("loadTile",{request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,o,r)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!o)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&o){const i=e.cO(r);t.setExpiryData(i);}t._mrt=o,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,o)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid];},void 0,!0);}queryRasterArrayValueByAllBands(e,t,i){return new Promise((o,r)=>{this._loadTileForQuery(t,(n,s)=>{n?r(n):o(s?this.queryRasterArrayValueByBandId(e,t,i):null);});})}queryRasterArrayValue(t,i){const o=e.ab.convert(t),r=this.findLoadedParent(o);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(o,r,i):this.queryRasterArrayValueByAllBands(o,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ag.fromLngLat(t,this.map.transform.tileSize),o=this.maxzoom+1,r=1<0){const s=e.co.now(),a=(s-t.timeAdded)/n,l=i?(s-i.timeAdded)/n:-1,c=o.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),u=d&&t.refreshedUponExpiration?1:e.bG(d?a:1-l,0,1);return i?{opacity:1,mix:1-u,isFading:a<1}:{opacity:u,mix:0,isFading:a<1}}return {opacity:1,mix:0,isFading:!1}}function Ho(t,i,o){if(!t)return null;const r=i.getTextureDescriptor(t,o,!0);if(!r)return null;let{texture:n,mix:s,offset:a,tileSize:l,buffer:c,format:h}=r;if(!n||!h)return null;let d=!1;return "uint32"===h&&(d=!0,s[3]=0,s=Po(e.d,s,[0,o.paint.get("raster-particle-max-speed")]),a=Mo(e.d,a,[0,o.paint.get("raster-particle-max-speed")])),{texture:n,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:d,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function Wo(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,n=t+r;return [t,i,(n-r-t)/o,(n-t)/o]}var Zo="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",qo="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",$o="\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#elif defined(FLOAT_RENDER_TARGET)\nlayout(location=0) out highp vec4 glFragColor;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nconst float DITHER_THRESHOLDS[16]=float[16](\n1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0\n);vec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}float cutoutGroundRoofOpacity(vec4 groundRoof) {\n#ifdef INDICATOR_CUTOUT\nfloat fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);\n#else\nreturn 1.0;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}",Xo="\n#define EXTENT 8192.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\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);}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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)\n{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Yo="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",Ko="\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\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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;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 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*texture(u_dem,pos).r;\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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;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*texture(u_dem_prev,pos).r;\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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;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) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return 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;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; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",Qo="#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;out 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",Jo="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in 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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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 opacity_limit) {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,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",er="\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif",tr="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",ir="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif",or="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const rr=/#include\s+"([^"]+)"/g,nr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,sr=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,ar=new Set(["ifdef","ifndef","elif","if","defined"]),lr=new Set;vr(qo,lr),vr(Xo,lr),vr($o,lr);const cr={"_prelude_fog.vertex.glsl":Qo,"_prelude_terrain.vertex.glsl":Ko,"_prelude_shadow.vertex.glsl":ir,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":Jo,"_prelude_shadow.fragment.glsl":or,"_prelude_lighting.glsl":er,"_prelude_raster_array.glsl":tr},hr={},dr="precision highp float;",ur="precision mediump float;",_r="\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif",fr={preludeTerrain:xr("",Ko),preludeFog:xr(Jo,Qo),preludeShadow:xr(or,ir),preludeRasterArray:xr(tr,""),preludeLighting:xr(er,er),preludePrecisionQualifiers:xr(ur,dr),prelude:xr($o,Xo),preludeExtensions:xr(_r,"")},pr=[_r,ur,qo,fr.prelude.fragmentSource].join("\n"),mr=[dr,qo,fr.prelude.vertexSource].join("\n");var gr={background:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nfloat factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);\n#else\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifndef FEATURE_CUTOUT\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\n}'),backgroundPattern:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),circle:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void 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 blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\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;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\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.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),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() {\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 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nsurface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,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)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;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);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);\n#endif\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\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();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;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:xr("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:xr('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\nout 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() {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(vec2(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(vec2(a_pos)*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=vec3(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=vec3(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;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=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:xr("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:xr("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_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+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}'),collisionCircle:xr("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));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=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:xr("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);\n#endif\n}'),fill:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fillOutlinePattern:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillPattern:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),lineBlendComposite:xr("uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;\n#define ADDITIVE 1\nvoid main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:xr("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,h);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform 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;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\nout vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;\n#else\nh=t > 0.0 ? height : base;\n#endif\npos=vec3(pos_nx.xy,h);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);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 cutoff=1.0;vec3 scaled_pos=pos;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);\n#endif\n#ifdef RENDER_CUTOFF\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);\n#endif\n#endif\n}'),fillExtrusionDepth:xr("void main() {}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}'),fillExtrusionPattern:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.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=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:xr('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\n#ifdef FEATURE_CUTOUT\nshadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:xr("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=float(a_hidden_by_landmark);\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:xr("precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}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+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=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+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),line:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;in vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 v_elevation_id_col;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);float pxStep;float delta;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\npxStep=fwidth(dist);float out_edge=v_width2_dilute.x-dist;float in_edge=dist-(v_width2_dilute.y-2.0*ANTIALIASING);delta=v_width2_dilute.y > 0.0 ? min(in_edge,out_edge) : out_edge;float edge=ANTIALIASING;alpha=delta > 0.0 ? smoothstep(edge-pxStep,u_width_scale*blur+edge+pxStep,delta) : 0.0;\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=ANTIALIASING/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edge2=border_width*u_width_scale+ANTIALIASING;float alpha2=smoothstep(edge2-pxStep,edge2+pxStep,delta);if (alpha2 < 1.) {if (border_color.a==0.0) {\n#ifndef RENDER_LINE_GRADIENT\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-alpha2));} else {out_color.rgb*=(0.6+0.4*alpha2);}\n#else\nout_color.rgb*=(0.6+0.4*alpha2);\n#endif\n} else {out_color=mix(border_color*trim_alpha,out_color,alpha2);}out_color*=v_width2_dilute.w;}\n#endif\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\n#ifdef LINE_BLEND_ADDITIVE\n{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}\n#else\n#ifdef LINE_BLEND_MULTIPLY\nglFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);\n#else\nglFragColor=out_color;\n#endif\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef DEBUG_ELEVATION_ID\nglFragColor=vec4(v_elevation_id_col,1.0);\n#endif\nif (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) || defined(VARIABLE_LINE_EMISSIVE_STRENGTH)\nin vec4 a_z_offset_width;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 a_elevation_id_col;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nout vec3 v_elevation_id_col;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin 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;uniform float u_width_scale;uniform float u_z_offset;uniform highp float u_floor_width_scale;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;out vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(\n2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2\n);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\n#ifdef VARIABLE_LINE_EMISSIVE_STRENGTH\nemissive_strength=a_z_offset_width.w;\n#endif\nfloat a_z_offset=u_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset+=a_z_offset_width.x;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nv_elevation_id_col=a_elevation_id_col;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\nvec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;\n#ifdef RENDER_LINE_CURVE\nCurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;float symmetric_outset=0.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=u_width_scale*(left ? left_width : right_width);if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=apply;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;symmetric_outset=zero_right_width ? u_width_scale*left_width : halfwidth;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth > 0.0 ? ANTIALIASING : 0.0);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);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\nv_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\nv_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else\n{\n#ifdef RENDER_LINE_BORDER\nfloat border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);\n#endif\n}}\n#endif\n#endif\nv_tile_pos=(v_tile_pos+extrude)/EXTENT;\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\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=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nvec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef VARIABLE_LINE_WIDTH\nv_width2_dilute.x=symmetric_outset;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity*u_opacity_multiplier);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec4 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\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=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;in uvec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nfloat tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=vec2(a_pos);\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=vec2(a_texture_pos)/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef ELEVATED\nfloat z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbol:xr('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;uniform lowp float u_opacity_multiplier;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef USE_PAINT_PROPERTIES_UBO\nin lowp float v_opacity;\n#ifdef RENDER_SDF\nin lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nin lowp float v_emissive_strength;\n#endif\n#else\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\n#pragma mapbox: define lowp float emissive_strength\n#endif\nvoid main() {\n#ifdef USE_PAINT_PROPERTIES_UBO\nlowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;\n#ifdef RENDER_SDF\nfill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;\n#endif\nlowp float emissive_strength=0.0;\n#ifdef LIGHTING_3D_MODE\nemissive_strength=v_emissive_strength;\n#endif\n#else\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\n#pragma mapbox: initialize lowp float emissive_strength\n#endif\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity*u_opacity_multiplier;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity*u_opacity_multiplier;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin uvec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\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_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;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;uniform bool u_is_halo;\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\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef USE_PAINT_PROPERTIES_UBO\n#ifndef MAX_UBO_SIZE_VEC4\n#define MAX_UBO_SIZE_VEC4 1024u\n#endif\n#define SPP_HEADER_SIZE_VEC4 3u\n#define DWORDS_PER_VEC4 4u\nstruct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;float zoomFactor;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;uniform highp float u_spp_fill_color_zoom_factor;uniform highp float u_spp_halo_color_zoom_factor;uniform highp float u_spp_opacity_zoom_factor;uniform highp float u_spp_halo_width_zoom_factor;uniform highp float u_spp_halo_blur_zoom_factor;uniform highp float u_spp_emissive_strength_zoom_factor;uniform highp float u_spp_occlusion_opacity_zoom_factor;uniform highp float u_spp_z_offset_zoom_factor;uniform highp float u_spp_translate_zoom_factor;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;\n#ifdef RENDER_SDF\nout lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nout lowp float v_emissive_strength;\n#endif\nPropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords,float zoomFactor) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;type.zoomFactor=zoomFactor;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask =u_spp_header.header[0][0];uint zoomDependentMask =u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3],u_spp_fill_color_zoom_factor);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0],u_spp_halo_color_zoom_factor);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1],u_spp_opacity_zoom_factor);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2],u_spp_halo_width_zoom_factor);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3],u_spp_halo_blur_zoom_factor);header.emissive_strength=getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0],u_spp_emissive_strength_zoom_factor);header.occlusion_opacity=getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1],u_spp_occlusion_opacity_zoom_factor);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2],u_spp_z_offset_zoom_factor);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3],u_spp_translate_zoom_factor);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,propertyType.zoomFactor);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {return mix(slot.xy,slot.zw,propertyType.zoomFactor);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,propertyType.zoomFactor);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;}\n#else\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\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define highp float z_offset\n#endif\nvec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {\n#ifdef USE_PAINT_PROPERTIES_UBO\nSymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;\n#ifdef RENDER_SDF\nv_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_emissive_strength=paint_properties.emissive_strength;\n#endif\nlowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;\n#else\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\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize highp float z_offset\n#endif\nvec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); \n#endif\n#else\nprojected_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 TERRAIN\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\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\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);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);\n#ifdef USE_PAINT_PROPERTIES_UBO\n{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(\nu_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y\n);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=vec2(a_texb)/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:xr("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:xr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Yo),skyboxGradient:xr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Yo),skyboxCapture:xr("\nin 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;precision highp float;\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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform float u_far_z_cutoff;in 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() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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 norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform 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;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:xr('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));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\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat 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);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 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=c2;glFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in 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;out highp vec3 v_ray_dir;out 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);}"),stars:xr("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),occlusion:xr("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function vr(e,t){const i=e.split("\n");for(let e of i){if(e=e.trimStart(),"#"!==e[0])continue;if(!e.includes("if"))continue;if(e.startsWith("#endif"))continue;const i=e.match(sr);if(i)for(const e of i)ar.has(e)||t.add(e);}}function yr(e){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(e)}function xr(e,t){const i=new Set,o=[],r=[];e=e.replace(rr,(e,t)=>(r.push(t),"")),t=t.replace(rr,(e,t)=>(o.push(t),""));let n=new Set(lr);vr(e,n),vr(t,n);for(const e of [...o,...r])hr[e]||(hr[e]=new Set,vr(cr[e],hr[e])),n=new Set([...n,...hr[e]]);return {fragmentSource:e=e.replace(nr,(e,t,o,r,n)=>(i.add(n),"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\n${yr(r)?"flat ":""}in ${o} ${r} ${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${o} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${o} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(nr,(e,t,o,r,n)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${n}`,a="float"===r?"vec2":r,l=`GET_ATTRIBUTE_${a}(a_${n}, materialInfo, ${s})`,c=n.includes("color")?"color":a;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${o} ${r} a_${n};\n#endif\n`:i.has(n)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\n #if !defined(${s})\n in ${o} ${a} a_${n};\n #endif\n${yr(r)?"flat ":""}out ${o} ${r} ${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${n})\n #ifdef ${s}\n ${n} = unpack_mix_${c}(${l}, u_${n}_t);\n #else\n ${n} = unpack_mix_${c}(a_${n}, u_${n}_t);\n #endif\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${o} ${r} a_${n};\n out ${o} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\n #if !defined(${s})\n in ${o} ${a} a_${n};\n #endif\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${o} ${a} a_${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${o} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${n}\n #ifdef ${s}\n ${o} ${r} ${n} = ${l};\n #else\n ${o} ${r} ${n} = a_${n};\n #endif\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n #ifdef ${s}\n ${o} ${r} ${n} = unpack_mix_${c}(${l}, u_${n}_t);\n #else\n ${o} ${r} ${n} = unpack_mix_${c}(a_${n}, u_${n}_t);\n #endif\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`}),usedDefines:n,vertexIncludes:o,fragmentIncludes:r}}cr["_prelude_raster_particle.glsl"]||(cr["_prelude_raster_particle.glsl"]=Zo);var br={building:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nhighp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);\n#ifdef BUILDING_FAUX_FACADE\nvec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);\n#endif\n#endif\n}'),buildingBloom:xr("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:xr("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:xr("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:xr("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:xr('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:xr("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:xr("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:xr("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),elevatedStructuresDepth:xr("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructures:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;uniform float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);\n#endif\nout_color*=u_opacity_multiplier;glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),elevatedStructuresDepthReconstruct:xr("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}")};xr(Zo,"");const wr=e.b_([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),Tr=e.b_([{type:"Float32",name:"a_pos_2f",components:2}]);class Er{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy();}draw(t,i){const o=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.aO,o=new e.aT;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,Tr.members),this.vignetteIdx=t.context.createIndexBuffer(o);}const r=e.aJ.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,o);const e={u_vignetteShape:(n={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:n.vignetteColor};o.draw(t,t.context.gl.TRIANGLES,vi.disabled,Wi.disabled,$i.alphaBlended,gi.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r);}var n;}}class Sr{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;}update(t,i){const o=t.getFreeCameraOptions().position,r=o.toAltitude(),n=o.toLngLat(),s=e.c4(n.lng),a=e.c4(n.lat),l=t.pixelsPerMeter/i,c=s*e.c9,h=e.c9*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else {const e=-this._offsetYPrev+h,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=h,this._elevationPrev=r;}}getPosition(){return [this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Ir(e,t){return [-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Cr(t){const i=e.eq(1323123451230),o=[];for(let r=0;r({u_matrix:e,u_depth_bias:t}),Or=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t,u_opacity_multiplier:1}),Pr=(e,t,i,o,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:o,u_reset_depth:r}),Mr={building:t=>({u_matrix:new e.bb(t),u_normal_matrix:new e.bb(t),u_opacity:new e.b4(t),u_faux_facade_ao_intensity:new e.b4(t),u_camera_pos:new e.b7(t),u_tile_to_meter:new e.b4(t),u_facade_emissive_chance:new e.b4(t),u_flood_light_color:new e.b7(t),u_flood_light_intensity:new e.b4(t),u_front_cutoff_params:new e.b7(t)}),buildingBloom:t=>({u_matrix:new e.bb(t)}),buildingDepth:t=>({u_matrix:new e.bb(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.bb(t),u_depth_bias:new e.b4(t)}),elevatedStructures:t=>({u_matrix:new e.bb(t),u_ground_shadow_factor:new e.b7(t),u_opacity_multiplier:new e.b4(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.bb(t),u_camera_pos:new e.b7(t),u_depth_bias:new e.b4(t),u_height_scale:new e.b4(t),u_reset_depth:new e.b4(t)}),rasterParticle:t=>({u_matrix:new e.bb(t),u_normalize_matrix:new e.bb(t),u_globe_matrix:new e.bb(t),u_merc_matrix:new e.bb(t),u_grid_matrix:new e.ba(t),u_tl_parent:new e.b6(t),u_scale_parent:new e.b4(t),u_fade_t:new e.b4(t),u_opacity:new e.b4(t),u_image0:new e.b5(t),u_image1:new e.b5(t),u_raster_elevation:new e.b4(t),u_zoom_transition:new e.b4(t),u_merc_center:new e.b6(t),u_cutoff_params:new e.b8(t)}),rasterParticleTexture:t=>({u_texture:new e.b5(t),u_opacity:new e.b4(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.b5(t),u_particle_texture_side_len:new e.b4(t),u_tile_offset:new e.b6(t),u_velocity:new e.b5(t),u_color_ramp:new e.b5(t),u_velocity_res:new e.b6(t),u_max_speed:new e.b4(t),u_uv_offset:new e.b6(t),u_data_scale:new e.b6(t),u_data_offset:new e.b4(t),u_particle_pos_scale:new e.b4(t),u_particle_pos_offset:new e.b6(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.b5(t),u_particle_texture_side_len:new e.b4(t),u_velocity:new e.b5(t),u_velocity_res:new e.b6(t),u_max_speed:new e.b4(t),u_speed_factor:new e.b4(t),u_reset_rate:new e.b4(t),u_rand_seed:new e.b4(t),u_uv_offset:new e.b6(t),u_data_scale:new e.b6(t),u_data_offset:new e.b4(t),u_particle_pos_scale:new e.b4(t),u_particle_pos_offset:new e.b6(t)}),snowParticle:t=>({u_modelview:new e.bb(t),u_projection:new e.bb(t),u_time:new e.b4(t),u_cam_pos:new e.b7(t),u_velocityConeAperture:new e.b4(t),u_velocity:new e.b4(t),u_horizontalOscillationRadius:new e.b4(t),u_horizontalOscillationRate:new e.b4(t),u_boxSize:new e.b4(t),u_billboardSize:new e.b4(t),u_simpleShapeParameters:new e.b6(t),u_screenSize:new e.b6(t),u_thinningCenterPos:new e.b6(t),u_thinningShape:new e.b7(t),u_thinningAffectedRatio:new e.b4(t),u_thinningParticleOffset:new e.b4(t),u_particleColor:new e.b8(t),u_direction:new e.b7(t)}),rainParticle:t=>({u_modelview:new e.bb(t),u_projection:new e.bb(t),u_time:new e.b4(t),u_cam_pos:new e.b7(t),u_texScreen:new e.b5(t),u_velocityConeAperture:new e.b4(t),u_velocity:new e.b4(t),u_boxSize:new e.b4(t),u_rainDropletSize:new e.b6(t),u_distortionStrength:new e.b4(t),u_rainDirection:new e.b7(t),u_color:new e.b8(t),u_screenSize:new e.b6(t),u_thinningCenterPos:new e.b6(t),u_thinningShape:new e.b7(t),u_thinningAffectedRatio:new e.b4(t),u_thinningParticleOffset:new e.b4(t),u_shapeDirectionalPower:new e.b4(t),u_shapeNormalPower:new e.b4(t),u_mode:new e.b4(t)}),vignette:t=>({u_vignetteShape:new e.b7(t),u_vignetteColor:new e.b8(t)})};function Fr(t,i){const o=1<0;--t){const i=Math.floor(e.x/(1<0;--e){const r=Math.floor(t.x/(1<a[t]!=_>a[t]&&s[t]o&&(f|=2),dr&&(f|=8),uo&&(p|=2),_r&&(p|=8),!(f&p)){if(0===f||0===p)return !1;if(Nr(e,d,u,_,t,i,o,r))return !1}}}for(let e=0;e<4;++e)if(!(1&n[e]))return !1;return !0}function Nr(e,t,i,o,r,n,s,a){const l=(e,t,i,o,r,n,s,a)=>{const l=(i-e)*(n-t)-(o-t)*(r-e),c=(i-e)*(a-t)-(o-t)*(s-e);if(l>0&&c>0||l<0&&c<0)return !1;const h=(s-r)*(t-n)-(a-n)*(e-r),d=(s-r)*(o-n)-(a-n)*(i-r);return !(h>0&&d>0||h<0&&d<0)};return !!(l(e,t,i,o,r,n,s,n)||l(e,t,i,o,s,n,s,a)||l(e,t,i,o,r,a,s,a)||l(e,t,i,o,r,n,r,a))}class Ur{constructor(){this._tileCoverages=[],this._snapshot=new kr;}clear(){this._tileCoverages=[];}addTileCoverage(e,t){this._tileCoverages.push({tileId:e,polygons:t,frcMask:zr(t)});}empty(){return 0===this._tileCoverages.length}updateSnapshotIfNeeded(){if(this._snapshot.equals(this._tileCoverages))return this._snapshot;const e=this._tileCoverages.map(e=>({tileId:e.tileId,polygons:e.polygons,frcMask:e.frcMask}));return this._snapshot=new kr(e),this._snapshot}}class jr{constructor(e,t){this.max=e,this.onRemove=t,this.reset();}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const o=e.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r);},i)),this.data[o].push(r),this.order.push(o),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,o=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][o];return this.data[i].splice(o,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const o of this.data[i])e(o.value)||t.push(o);for(const e of t)this.remove(e.value.tileID,e);}}class Gr{constructor(){this.state=Object.create(null),this.stateChanges=Object.create(null),this.deletedStates=Object.create(null);}updateState(e,t,i){const o=String(t);if(this.stateChanges[e]=this.stateChanges[e]||Object.create(null),this.stateChanges[e][o]=this.stateChanges[e][o]||Object.create(null),Object.assign(this.stateChanges[e][o],i),null===this.deletedStates[e]){this.deletedStates[e]=Object.create(null);for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]=Object.create(null);for(const t in this.state[e][o])i[t]||(this.deletedStates[e][o][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const o=String(t);if(this.deletedStates[e]=this.deletedStates[e]||Object.create(null),i&&void 0!==t)null!==this.deletedStates[e][o]&&(this.deletedStates[e][o]=this.deletedStates[e][o]||Object.create(null),this.deletedStates[e][o][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]=Object.create(null),this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null;}getState(e,t){const i=this.state[e]||Object.create(null),o=this.stateChanges[e]||Object.create(null),r=this.deletedStates[e];if(null===r)return Object.create(null);if(void 0!==t){const e=String(t),n=Object.assign(Object.create(null),i[e],o[e]);if(r){const e=r[t];if(null===e)return Object.create(null);for(const t in e)delete n[t];}return n}const n=Object.assign(Object.create(null),i,o);if(r)for(const e in r)delete n[e];return n}initializeTileState(e,t){e.refreshFeatureState(t);}coalesceChanges(e,t){const i=Object.create(null);for(const e in this.stateChanges){this.state[e]=this.state[e]||Object.create(null);const t=Object.create(null);for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]=Object.create(null)),Object.assign(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||Object.create(null);const t=Object.create(null);if(null===this.deletedStates[e])for(const i in this.state[e])t[i]=Object.create(null),this.state[e][i]=Object.create(null);else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]=Object.create(null);else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||Object.create(null),Object.assign(i[e],t);}if(this.stateChanges=Object.create(null),this.deletedStates=Object.create(null),0!==Object.keys(i).length)for(const o in e)e[o].refreshFeatureState(t,i);}}class Vr extends e.y{constructor(e,t,i){super(),this.id=e,this._renderSourceType=i,this._maxzoomOverride=null,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));}),t.on("error",()=>{this._sourceErrored=!0;}),this._source=t,this._tiles={},this._cache=new jr(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Gr,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles)if(!this._tiles[e].loaded())return !1;return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform);}setMaxzoomOverride(e){this._maxzoomOverride=e;}_loadTile(e,t){return e.renderSourceType=this._renderSourceType,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Hr).map(e=>e.key)}getRenderableIds(t,i){const o=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&o.push(this._tiles[e]);return t?o.sort((t,i)=>{const o=t.tileID,r=i.tileID,n=new e.au(o.canonical.x,o.canonical.y)._rotate(this.transform.angle),s=new e.au(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-r.overscaledZ||s.y-n.y||s.x-n.x}).map(e=>e.tileID.key):o.map(e=>e.tileID).sort(Hr).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(t,i,o,r,n){if(r){if(t.state="errored",e.dD(r)){if(this._source.fire(new e.x("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else this._source.fire(new e.v(r,{tile:t}));return}t.timeAdded=e.co.now(),"expired"===o&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let s=new Map;n&&n.responseHeaders&&(s=n.responseHeaders),this._source.fire(new e.x("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}));}_hasTunnelGeometry(){for(const e in this._tiles){const t=this._tiles[e];if(t&&t.hasTunnelGeometry)return !0}return !1}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,o),e.neighboringTiles&&e.neighboringTiles[n]&&(e.neighboringTiles[n].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,o){for(const r in this._tiles){let n=this._tiles[r];if(o[r]||!n.hasData()||n.tileID.overscaledZ<=t||n.tileID.overscaledZ>i)continue;let s=n.tileID;for(;n&&n.tileID.overscaledZ>t+1;){const e=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[e.key],n&&n.hasData()&&(s=e);}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){o[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),o=this._getLoadedTile(t);if(o)return o}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,o=Math.ceil(e.height/t)+1,r=Math.floor(i*o*5),n="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),e[o.tileID.key]=o;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(t,i,o,r,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;null!==this._maxzoomOverride&&(l=Math.min(l,this._maxzoomOverride));const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t);}const h=null===this._maxzoomOverride&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.ap(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.ap(1,0,1,0,0)),a.push(new e.ap(1,0,1,1,0)),a.push(new e.ap(1,0,1,0,1)),a.push(new e.ap(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t));}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),c=Math.min(e,l);if(s){const e=t.extendTileCover(a,c);for(const t of e)a.push(t);}else if(n){const e=this.transform.getFrustum(c),i=t.extendTileCoverToNearPlane(a,e,c);for(const e of i)a.push(e);if(c>=18&&this._hasTunnelGeometry()){const i=t.extendTileCoverForTunnels(a,e,c,20);for(const e of i)a.push(e);}}else if(this.castsShadows&&r){const e=t.extendTileCover(a,c,r,16);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}const d=this._updateRetainedTiles(a);if(this._supportsFading&&0!==a.length){const t={},i={},o=e.co.now(),r=Object.keys(d);for(const e of r){const r=d[e],n=this._tiles[e];if(!n||void 0!==n.fadeEndTime&&n.fadeEndTime<=o)continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-Vr.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[e]=r;}const n=a.at(-1).overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(d[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>n;){o=o.scaledTo(o.overscaledZ-1);const r=this._tiles[o.key];if(r&&r.hasData()&&i[o.key]){d[e]=t.tileID;break}}}for(const e in t)d[e]||(this._coveredTiles[e]=!0,d[e]=t[e]);}for(const e in d)this._tiles[e].clearFadeHold();const u=e.dS(this._tiles,d);for(const e of u){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._renderSourceType===e.aC.Symbol&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},o=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,n=Math.max(r-Vr.maxOverzooming,this._source.minzoom),s=Math.max(r+Vr.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=o.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=o.overscaledZ-1;s>=n;--s){const n=o.scaledTo(s);if(i[n.key])break;if(i[n.key]=!0,e=this.getTile(n),!e&&r&&(e=this._addTile(n)),e&&(t[n.key]=n,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}t.push(o.key);const e=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;o=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return !0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const o=Boolean(i);if(!o){const o=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Fo(t,r,this.transform.tileZoom,o,this._isRaster):new e.b0(t,r,this.transform.tileZoom,o,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.x("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e];},i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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,i,o){const r=[],n=this.transform;if(!n)return r;const s="globe"===n.projection.name,a=e.ek(n.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(o&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.bG(a,...Wr(t,-1))-a),Math.abs(e.bG(a,...Wr(t,1))-a)];h=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.bG(a,...Wr(t,-1))-a),Math.abs(e.bG(a,...Wr(t,0))-a),Math.abs(e.bG(a,...Wr(t,1))-a)];h=[i.indexOf(Math.min(...i))-1];}}else h=[0];for(const e of h){const o=t.containsTile(c,n,i,e);o&&r.push(o);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){if(!this.transform)return [];const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),o="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=o?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return !0;if(this._supportsFading){const t=e.co.now();for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t)return !0}}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const o=this._tiles[e];o&&o.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,t));}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i));};return void this._source.on("data",e)}const o=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,s=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)o.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const a=Array.from(o.values());e.bp(a,(t,i)=>{const o=new e.b0(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(o,e=>{"raster-dem"===this._source.type&&o.dem&&this._backfillDEM(o),i(e,o);});},i);}}function Hr(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),o=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||o-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Wr(e,t){const i=1<({u_matrix:e});function qr(e,t){const i=e.context.gl;return new Wi({func:i.EQUAL,mask:255},e._tileClippingMaskIDs[t.key]||0,0,i.KEEP,i.KEEP,i.KEEP)}function $r(e,t){const i=e.context.gl;return new Wi({func:i.EQUAL,mask:255},255&~(e._tileClippingMaskIDs[t.key]||0),0,i.KEEP,i.KEEP,i.KEEP)}function Xr(t,i){if(!t.frcCoverageSnapshot||!t.frcCoverageRenderer)return null;const o=t.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!o||0===o.frcMask)return null;const r=t.frcCoverageRenderer.getBuffers(o.tileId);if(!r)return null;const n=new e.f(o.tileId.z,o.tileId.x,o.tileId.y),s=new e.bc(i.wrap,n);return {buffers:r,projMatrix:t.transform.calculateProjMatrix(s),coverageTile:o}}function Yr(e,t,i){if(!e.frcCoverageSnapshot)return;const o=e.context,r=o.gl,n=e.getOrCreateProgram("clippingMask");o.setColorMode($i.disabled),o.setDepthMode(vi.disabled);for(const o of t){const t=Xr(e,o);if(!t)continue;const s=t.buffers.frcLevelSegments[i];s&&n.draw(e,r.TRIANGLES,vi.disabled,new Wi({func:r.EQUAL,mask:255},e._tileClippingMaskIDs[o.key]||0,255,r.KEEP,r.KEEP,r.INVERT),$i.disabled,gi.disabled,Zr(t.projMatrix),`$frc_coverage_${i}`,t.buffers.vertexBuffer,t.buffers.indexBuffer,s);}}function Kr(e,t,i){if(!e.frcCoverageSnapshot)return;const o=e.context,r=o.gl,n=e.getOrCreateProgram("clippingMask");o.setColorMode($i.disabled),o.setDepthMode(vi.disabled);for(const o of t){const t=Xr(e,o);if(!t)continue;const s=t.buffers.frcLevelSegments[i];s&&n.draw(e,r.TRIANGLES,vi.disabled,new Wi({func:r.EQUAL,mask:255},255&~(e._tileClippingMaskIDs[o.key]||0),255,r.KEEP,r.KEEP,r.INVERT),$i.disabled,gi.disabled,Zr(t.projMatrix),`$frc_coverage_restore_${i}`,t.buffers.vertexBuffer,t.buffers.indexBuffer,s);}}function Qr(e,t,i,o,r){if(0===t.length)return;let n=0;for(const e of t)n|=e.frcMask;const s=t.map(e=>e.coord);for(let a=0;a<9;++a)if(n&1<0&&r)for(const i of t)i.frcMask&1<0&&t.rings[0].length>0)return !0;return !1}function en(e){const t=e.frcCoverageFadeRange;return !t||t[1]<=t[0]?0:1-Math.max(0,Math.min(1,(e.transform.zoom-t[0])/(t[1]-t[0])))}const tn={loaded:!0,drawBuilding:function(e,t,i,o){e.currentLayer0&&n>0,c=!0;const h=i.paint.get("building-vertical-scale");if(h<=0)return;e.shadowRenderer||(c=!1);const d=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),u=e.style.order.indexOf(i.fqid);if(function(e,t,i,o,r,n){for(const s of n){const n=t.getTile(s).getBucket(i);n&&(r&&n.updateReplacement(s,e.replacementSource,o),n.uploadUpdatedIndexBuffer(e.context));}}(e,t,i,u,d,o),function(e,t,i,o){for(const r of o){const o=t.getTile(r).getBucket(i);o&&o.needsEvaluation()&&o.uploadUpdatedColorBuffer(e.context);}}(e,t,i,o),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=[],n=e.shadowRenderer.getShadowPassDepthMode();Io({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:$i.disabled,depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}else if("translucent"===e.renderPass){let u=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(u=u.concat("RENDER_SHADOWS")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(u=u.concat("NORMAL_OFFSET"));const _=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),p=i.paint.get("building-flood-light-intensity"),m="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),g=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(m?null:i.lut).toArray01().slice(0,3),v=i.paint.get("building-flood-light-ground-attenuation"),y=p>0,x=new vi(e.context.gl.LEQUAL,vi.ReadWrite,e.depthRangeFor3D);a<1&&Io({painter:e,source:t,layer:i,coords:o,defines:u,blendMode:$i.disabled,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:_,facadeAOIntensity:f,floodLightIntensity:p,floodLightColor:g,depthOnly:!0});const b=e.colorModeForRenderPass();Io({painter:e,source:t,layer:i,coords:o,defines:u,blendMode:b,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:_,facadeAOIntensity:f,floodLightIntensity:p,floodLightColor:g});const w=i.paint.get("building-front-cutoff");go(e.transform.pitch,w,!!e.terrain),l&&Co(e,t,i,o,!0,a,r,n,p,g,s,d),y&&Co(e,t,i,o,!1,a,r,n,p,g,v,d);}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],n=new vi(e.context.gl.LEQUAL,vi.ReadOnly,e.depthRangeFor3D);Io({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:$i.alphaBlended,depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks();},drawRasterParticle:function(t,i,o,r,n,s){"offscreen"===t.renderPass&&function(t,i,o,r){if(!r.length)return;const n=t.context,s=n.gl,a=i.getSource();if(!(a instanceof Uo))return;const l=Math.ceil(Math.sqrt(o.paint.get("raster-particle-count")));let c=o.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(t){const i=t*t,o=new Uint8Array(4*i),r=.9090909090909091;for(let t=0;te.ev[t](r));f.push(r);const p=r.canonical.x,m=r.canonical.y;for(const e of f){const n=i.getTile(l?e.wrapped():e);if(!n)continue;const a=n.rasterParticleState;if(!a)continue;const h=e.canonical.x+(1<t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,n)&&o.prepareTile(t,r,e.id,n);},Rain:class extends Dr{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null;}destroy(){super.destroy();}update(t){const i=t.context;if(!this.particlesVx){const t=Cr(this.particlesCount),o=new e.aW,r=new e.aT;let n=0;const s=e.eq(1323123451230);for(let e=0;ea)return;const l=Rr(0,1,r.revealStart,r.revealStart+r.revealRange,a);if(!this.particlesVx||!this.particlesIdx)return;s.strength*=l;const c=this.updateOnRender(t,o.timeFactor),h=t.context,d=h.gl,u=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.a_(h,{width:t.width,height:t.height,data:null},d.RGBA8)),o.distortionStrength>0&&(h.activeTexture.set(d.TEXTURE0),this.screenTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),d.copyTexSubImage2D(d.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const _=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(h,_),h.activeTexture.set(d.TEXTURE0),this.screenTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE);const f=[o.color.r,o.color.g,o.color.b,o.color.a],p=(i,r)=>{const s=Ir(this._movement.getPosition(),i),a=o.dropletSizeX,l=o.dropletSizeX*o.dropletSizeYScale,h=t.width/2,p=t.height/2,m=Rr(0,o.screenThinning.start,0,1,o.screenThinning.intensity),g=Rr(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),v=Rr(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(x={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[a,l],distortionStrength:o.distortionStrength,rainDirection:n,color:f,screenSize:[u.width,u.height],thinningCenterPos:[h,p],thinningShape:[m,g,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:v,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:r?0:1},{u_modelview:Float32Array.from(x.modelview),u_projection:Float32Array.from(x.projection),u_time:x.time,u_cam_pos:x.camPos,u_texScreen:0,u_velocityConeAperture:x.velocityConeAperture,u_velocity:x.velocity,u_boxSize:x.boxSize,u_rainDropletSize:x.rainDropletSize,u_distortionStrength:x.distortionStrength,u_rainDirection:x.rainDirection,u_color:x.color,u_screenSize:x.screenSize,u_thinningCenterPos:x.thinningCenterPos,u_thinningShape:x.thinningShape,u_thinningAffectedRatio:x.thinningAffectedRatio,u_thinningParticleOffset:x.thinningParticleOffset,u_shapeDirectionalPower:x.shapeDirectionalPower,u_shapeNormalPower:x.shapeNormalPower,u_mode:x.mode});var x;const b=Math.round(o.intensity*this.particlesCount),w=e.aJ.simpleSegment(0,0,4*b,2*b);_.draw(t,d.TRIANGLES,vi.disabled,Wi.disabled,$i.alphaBlended,gi.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,w);};o.distortionStrength>0&&p(o.boxSize,!0),p(o.boxSize,!1),this._vignette.draw(t,s);}},Snow:class extends Dr{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null;}destroy(){super.destroy();}update(t){const i=t.context;if(!this.particlesVx){const t=Cr(this.particlesCount),o=new e.aK,r=new e.aT;let n=0;const s=e.eq(1323123451230);for(let e=0;ea)return;const l=Rr(0,1,r.revealStart,r.revealStart+r.revealRange,a);s.strength*=l;const c=this.updateOnRender(t,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const h=t.context,d=h.gl,u=t.transform,_=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(h,_),((i,o,r)=>{const s=Ir(this._movement.getPosition(),i),a=u.width/2,l=u.height/2,h=Rr(0,r.screenThinning.start,0,1,r.screenThinning.intensity),f=Rr(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),p=Rr(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),m=(g={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,horizontalOscillationRadius:r.horizontalOscillationRadius,horizontalOscillationRate:r.horizontalOscillationRate,boxSize:i,billboardSize:1*r.billboardSize,simpleShapeParameters:[r.shapeFadeStart,r.shapeFadePower],screenSize:[u.width,u.height],thinningCenterPos:[a,l],thinningShape:[h,f,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:p,color:[r.color.r,r.color.g,r.color.b,r.color.a],direction:n},{u_modelview:Float32Array.from(g.modelview),u_projection:Float32Array.from(g.projection),u_time:g.time,u_cam_pos:g.camPos,u_velocityConeAperture:g.velocityConeAperture,u_velocity:g.velocity,u_horizontalOscillationRadius:g.horizontalOscillationRadius,u_horizontalOscillationRate:g.horizontalOscillationRate,u_boxSize:g.boxSize,u_billboardSize:g.billboardSize,u_simpleShapeParameters:g.simpleShapeParameters,u_screenSize:g.screenSize,u_thinningCenterPos:g.thinningCenterPos,u_thinningShape:g.thinningShape,u_thinningAffectedRatio:g.thinningAffectedRatio,u_thinningParticleOffset:g.thinningParticleOffset,u_particleColor:g.color,u_direction:g.direction});var g;const v=Math.round(r.intensity*this.particlesCount),y=e.aJ.simpleSegment(0,0,4*v,2*v);this.particlesVx&&this.particlesIdx&&_.draw(t,d.TRIANGLES,vi.disabled,Wi.disabled,$i.alphaBlended,gi.disabled,m,"snow_particles",this.particlesVx,this.particlesIdx,y);})(o.boxSize,0,o),this._vignette.draw(t,s);}},shaders:br,programUniforms:Mr,drawElevatedStructures:function(e){const{painter:t,sourceCache:i,layer:o,coords:r,colorMode:n}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new vi(t.context.gl.LEQUAL,vi.ReadOnly,t.depthRangeFor3D);let h=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(h=uo(t.style,e,i));}const d=e=>{for(const d of r){const r=i.getTile(d),u=r.getBucket(o);if(!u)continue;const _=u.hdExt?u.hdExt.elevatedStructures:void 0;if(!_)continue;let f,p;if(e?(f=_.renderableBridgeSegments,p=_.bridgeProgramConfigurations.get(o.id)):(f=_.renderableTunnelSegments,p=_.tunnelProgramConfigurations.get(o.id)),!f||0===f.segments[0].primitiveLength)continue;p.updatePaintBuffers(),t.prepareDrawTile();const m=t.isTileAffectedByFog(d),g=[];l&&g.push("RENDER_SHADOWS","NORMAL_OFFSET");const v=t.getOrCreateProgram("elevatedStructures",{config:p,overrideFog:m,defines:g}),y=t.translatePosMatrix(d.projMatrix,r,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),v,"vector-tile");const x=Or(y,h);t.uploadCommonUniforms(t.context,v,d.toUnwrapped()),v.draw(t,s.TRIANGLES,c,Wi.disabled,n,gi.backCCW,x,o.id,_.vertexBuffer,_.indexBuffer,f,o.paint,t.transform.zoom,p,[_.vertexBufferNormal]);}};d(!0),d(!1);},drawElevatedFillShadows:function(e){const{painter:t,sourceCache:i,layer:o,coords:r}=e,n=t.context.gl,s=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(o);if(!a)continue;const l=a.hdExt?a.hdExt.elevatedStructures:void 0;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(o.id),h=t.isTileAffectedByFog(e),d=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:h}),u=s.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,d,e.toUnwrapped());const _=Lr(u,0);d.draw(t,n.TRIANGLES,s.getShadowPassDepthMode(),Wi.disabled,$i.disabled,gi.disabled,_,o.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,o.paint,t.transform.zoom,c);}},drawDepthPrepass:function(t,i,o,r,n){if(!i)return;if(!o.layout||"none"===o.layout.get("fill-elevation-reference")||0===o.paint.get("fill-opacity").constantOr(1))return;const s=t.context.gl,a=new vi(t.context.gl.LEQUAL,vi.ReadWrite,t.depthRangeFor3D),l=new vi(t.context.gl.GREATER,vi.ReadWrite,t.depthRangeFor3D),c=function(t){let i=.01;return t.isOrthographic&&(i=e.dY(1e-4,i,e.cc(t.pitch>=ji?1:t.pitch/ji))),2*i}(t.transform),h=t.transform.getFreeCameraOptions().position,d="elevatedStructuresDepthReconstruct",u=t.getOrCreateProgram(d,{defines:["DEPTH_RECONSTRUCTION"]}),_=t.getOrCreateProgram(d);for(const e of r){const r=i.getTile(e),d=r.getBucket(o);if(!d)continue;if(!d.hdExt)continue;const f=d.hdExt.elevatedStructures,p=d.hdExt.elevationBufferData;if(!f||!f.depthSegments||!p)continue;const m=p.heightRange,g=Fr(e.toUnwrapped(),h),v=t.translatePosMatrix(e.projMatrix,r,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));let y,x,b,w;if("initialize"===n){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;y=Pr(v,g,c,1,0),x=a,b=f.depthSegments,w=u;}else if("reset"===n){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;y=Pr(v,g,0,0,1),x=l,b=f.maskSegments,w=u;}else if("geometry"===n){if(0===f.depthSegments.segments[0].primitiveLength)continue;y=Pr(v,g,c,1,0),x=a,b=f.depthSegments,w=_;}w.draw(t,s.TRIANGLES,x,Wi.disabled,$i.disabled,gi.disabled,y,o.id,f.vertexBuffer,f.indexBuffer,b,o.paint,t.transform.zoom);}},drawGroundShadowMask:function(e,t,i,o){if(!t)return;if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,n=new vi(r.LEQUAL,vi.ReadOnly,e.depthRangeFor3D),s=new Wi({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of o){const o=t.getTile(c),h=o.getBucket(i);if(!h)continue;const d=h.hdExt?h.hdExt.elevatedStructures:void 0;if(!d||!d.depthSegments||0===d.depthSegments.segments[0].primitiveLength)continue;const u=Fr(c.toUnwrapped(),a),_=e.translatePosMatrix(c.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=Pr(_,u,0,1,0);l.draw(e,r.TRIANGLES,n,s,$i.disabled,gi.disabled,f,i.id,d.vertexBuffer,d.indexBuffer,d.depthSegments,i.paint,e.transform.zoom);}},IndoorManager:class extends e.y{constructor(t,i=!1){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Ro,this._initialLoadDone=!1,e.bs(["_updateUI"],this);const o=()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI();}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI));};i?(this._initialLoadDone=!0,o()):this._style.on("style.load",o);}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null;}selectFloor(e){e===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=e,this._recalculateActiveFloors());}setActiveFloorsVisibility(e){this._updateActiveFloors(e),this._updateIndoorSelector();}setIndoorData(e){let t=!1;for(const[i,o]of Object.entries(e.buildings))if(this._buildings[i])for(const e of o.floorIds)this._buildings[i].floorIds.add(e),this._buildings[i].floors[e]?this._mergeFloors(this._buildings[i].floors[e],o.floors[e]):(this._buildings[i].floors[e]=o.floors[e],t=!0);else this._buildings[i]=o,t=!0;t&&this._recalculateActiveFloors();}getIndoorTileOptions(e,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(e,t),indoorState:this._indoorState}:null}getControlState(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return {selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let o=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){o=e;break}const r=Array.from(i.floorIds).map(e=>({id:e,name:i.floors[e].name,zIndex:i.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex).filter((e,t,i)=>0===t||e.zIndex!==i[t-1].zIndex);return {selectedFloorId:o,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:r}}_updateUI(){this._initialLoadDone=!0;const e=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,e.center,e.zoom,e.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const e=this._closestBuildingId;this._closestBuildingId=t,this._onBuildingTransition(e,t),this._updateIndoorSelector();}}_onBuildingTransition(e,t){if(!this._indoorState)return;const i=!!t&&!e;!t&&e?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):i&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0));}_updateIndoorSelector(){this.fire(new e.x("selector-update",this.getControlState()));}_updateActiveFloors(e){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:e,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0;}_recalculateActiveFloors(){if(!this._buildings)return;const t=e.a5.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(e,t){if(e===t)return !0;if(!e||!t)return !1;if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector());}_mergeFloors(e,t){t.geometry&&(e.geometry?("Polygon"===e.geometry.type&&(e.geometry={type:"MultiPolygon",coordinates:[e.geometry.coordinates]}),"Polygon"===t.geometry.type?e.geometry.coordinates.push(t.geometry.coordinates):"MultiPolygon"===t.geometry.type&&e.geometry.coordinates.push(...t.geometry.coordinates)):e.geometry=t.geometry);}_makeViewportPolygon(){const t=this._style.map.transform,i=t.width,o=t.height;return [t.pointLocation(new e.au(0,0)),t.pointLocation(new e.au(i,0)),t.pointLocation(new e.au(i,o)),t.pointLocation(new e.au(0,o))].map(t=>new e.au(t.lng,t.lat))}},HdCoverageState:class{constructor(){this.coverageSourceCaches={},this.manager=new Ur;}},updateFrcCoverage:function(e,t){t.manager.clear();for(const i in e._mergedHdRoadCoverageSourceCaches){const o=e._mergedHdRoadCoverageSourceCaches[i]._tiles;for(const e in o){const i=o[e];if(!i||!i.loaded())continue;const r=i.frcCoveragePolygons;t.manager.addTileCoverage(i.tileID.canonical,r&&r.length>0?r:[]);}}const i=t.manager.updateSnapshotIfNeeded();if(e.map.painter&&(e.map.painter.frcCoverageSnapshot=i.empty()?null:i),!i.empty()){const t=[e._mergedOtherSourceCaches,e._mergedSymbolSourceCaches];for(const e of t)for(const t in e){const i=e[t];for(const e in i._tiles){const t=i._tiles[e];t&&t.hasDeferredRoadStructure&&(t.hasDeferredRoadStructure=!1,i._reloadTile(+e,"reloading"));}}}},updateHdCoverageSourceCache:function(t,i,o){if("fill"!==o.type||o.sourceLayer!==e.X)return;if(i.coverageSourceCaches[o.source])return;const r=t.getOwnSource(o.source);if(!r||"vector"!==r.type)return;const n=`hd-road-coverage:${o.source}`,s=e.ea(n,t.scope),a=t._sourceCaches[n]=new Vr(s,r,e.aC.HdRoadCoverage);i.coverageSourceCaches[o.source]=a,a.setMaxzoomOverride(14),a.onAdd(t.map);const l=t._otherSourceCaches[o.source];l&&l._sourceLoaded&&(a._sourceLoaded=!0);},updateFrcCoverageFadeRange:function(t,i){let o=null,r=null;const n={globals:{zoom:0}};t.forEachFragmentStyle(i=>{if(o)return;const s=i.stylesheet?i.stylesheet.schema:null;if(!s||!s.sdCoverageFadeRange)return;const a=e.ea("sdCoverageFadeRange",i.scope),l=i.options?i.options.get(a):void 0,c=l?l.value||l.default:null;if(c){const e=c.evaluate(n);Array.isArray(e)&&2===e.length&&(e[0]>0||e[1]>0)&&(o=[e[0],e[1]]);}const h=e.ea("sdCoverageSourceLayers",i.scope),d=i.options?i.options.get(h):void 0,u=d?d.value||d.default:null;if(u){const e=u.evaluate(n);Array.isArray(e)&&e.length>0&&(r=e);}else {const e=t.stylesheet&&t.stylesheet.imports||[];for(const t of e)if(t.id===i.scope){const e=t.config?t.config.sdCoverageSourceLayers:void 0;Array.isArray(e)&&e.length>0&&(r=e);break}}}),i.frcCoverageFadeRange=o,i.frcCoverageSourceLayers=null!=o?r||["road","structure"]:[];},FrcCoverageRenderer:class{constructor(){this.tileBuffers=new Map,this._context=null;}update(e,t){this._context=e;const i=new Set;for(const o of t){if(0===o.frcMask)continue;let t=!1;for(const e of o.polygons)if(e.hasGeometry()){t=!0;break}if(!t)continue;const r=`${o.tileId.z}/${o.tileId.x}/${o.tileId.y}`;if(i.add(r),!this.tileBuffers.has(r)){const t=this._createBuffers(e,o);t&&this.tileBuffers.set(r,t);}}for(const e of this.tileBuffers.keys())if(!i.has(e)){const t=this.tileBuffers.get(e);t.vertexBuffer.destroy(),t.indexBuffer.destroy();for(const e of t.frcLevelSegments)e&&e.destroy();this.tileBuffers.delete(e);}}getBuffers(e){return this.tileBuffers.get(`${e.z}/${e.x}/${e.y}`)||null}destroy(){for(const e of this.tileBuffers.values()){e.vertexBuffer.destroy(),e.indexBuffer.destroy();for(const t of e.frcLevelSegments)t&&t.destroy();}this.tileBuffers.clear();}_createBuffers(t,i){const o=new e.aQ,r=new e.aT,n=[];for(const t of i.polygons){if(!t.hasGeometry()||0===t.rings.length)continue;const i=o.length,s=r.length,a=o.length,l=[],c=[];let h=0;for(let e=0;e0&&c.push(h);for(const e of i)o.emplaceBack(e.x,e.y),l.push(e.x,e.y),h++;}}const d=e.c8(l,c.length>0?c:void 0);for(let e=0;e0&&e.program.draw(t,e.drawMode,e.depthMode,e.stencilMode,e.colorMode,gi.disabled,e.uniformValues,e.layer.id,e.bufferData.layoutVertexBuffer,e.indexBuffer,l.frcNonRoadSegments,e.layer.paint,o,e.programConfiguration,e.dynamicBuffers),"drawn"}return "fallthrough"},drawFillFrcCoverageSecondPass:function(e,t,i,o,r){if(0===i.length)return;const n=en(e),s=e.transform.zoom,a=(i,n,a)=>{1!==a&&(i.uniformValues.u_opacity_multiplier=a),i.program.draw(e,o,i.depthMode,n,r,gi.disabled,i.uniformValues,t.id,i.bufferData.layoutVertexBuffer,i.indexBuffer,i.segments,t.paint,s,i.programConfiguration,i.dynamicBuffers),1!==a&&(i.uniformValues.u_opacity_multiplier=1);};Qr(e,i,n,(e,t,i)=>a(e,i,1),(e,t,i)=>a(e,i,n));},drawLineFrcCoverageDetect:function(e,t,i,o,r,n,s,a,l,c){const h=t.hdExt&&t.hdExt.frcData;if(!h||0===h.frcPerLevel.size)return null;if(!e.frcCoverageSnapshot||o)return null;const d=e.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!d||0===d.frcMask)return null;const u=Jr(d.polygons),_=e.frcCoverageFadeRange,f=null!=_&&e.transform.zoom>=_[0];if(u&&f){let e=!1;for(const t of h.frcPerLevel.keys())if(d.frcMask&1<0&&o(i,s);},drawLineFrcFadePass:function(e,t,i,o,r,n,s){if(o.hasPolygonGeometry)return;const a=t.hdExt&&t.hdExt.frcData;if(!a||!e.frcCoverageFadeRange)return;const[l,c]=e.frcCoverageFadeRange;if(l>=c)return;const h=1-Math.max(0,Math.min(1,(e.transform.zoom-l)/(c-l)));if(h<=0)return;const d=r?n:e.stencilModeForClipping(i),u=o.frcMask;for(const[e,t]of a.frcPerLevel)u&1<{const l=i.bucket.hdExt&&i.bucket.hdExt.frcData,c=l&&l.frcPerLevel.get(r);c&&0!==c.segments.length&&(1!==a&&(i.uniformValues.u_opacity_multiplier=a),i.program.draw(e,o.TRIANGLES,i.depthMode,s,i.colorMode,gi.disabled,i.uniformValues,t.id,i.bucket.layoutVertexBuffer,i.bucket.indexBuffer,c,t.paint,n,i.programConfiguration,[i.bucket.layoutVertexBuffer2,i.bucket.patternVertexBuffer,i.bucket.zOffsetVertexBuffer,i.bucket.elevationIdColVertexBuffer,i.bucket.elevationGroundScaleVertexBuffer]),1!==a&&(i.uniformValues.u_opacity_multiplier=1));};Qr(e,i,r,(e,t,i)=>s(e,t,i,1),(e,t,i)=>s(e,t,i,r));}},on=tn;async function rn(){return Promise.resolve()}const nn=new Float32Array(e.dq([])),sn=(t,i,o,r,n,s,a,l,c,h,d,u,_,f=[0,0,0],p,m,g,v=1)=>{const y=n.style.light,x=y.properties.get("position"),b=[-x.x,-x.y,x.z],w=e.bV();"viewport"===y.properties.get("anchor")&&(e.cu(w,-n.transform.angle),e.fK(b,b,w));const T="MASK"===d.alphaMode,E=y.properties.get("color").toNonPremultipliedRenderColor(null),S=_.paint.get("model-ambient-occlusion-intensity"),I=_.paint.get("model-color").constantOr(e.i.white).toNonPremultipliedRenderColor(null);return I.a=_.paint.get("model-color-mix-intensity").constantOr(0),g&&(I.r=g[0],I.g=g[1],I.b=g[2],I.a=g[3]),m&&(I.r=m.color.r,I.g=m.color.g,I.b=m.color.b,I.a=m.colorMix,u=m.emissionStrength,s*=m.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:r||nn,u_lightpos:b,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[E.r,E.g,E.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+T,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:I.toArray01(),u_aoIntensity:S,u_emissive_strength:u,u_occlusionTextureTransform:p||[0,0,0,0],u_dithered_discard_threshold:v}},an=(e,t=nn,i=nn)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),ln=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),cn=new Float64Array(16),hn=new Float64Array(16),dn=new Float64Array(16),un=new Float64Array(16),_n=new Float64Array(16),fn=new Float64Array(16),pn=new Float64Array(16),mn=[0,0,0],gn=new Float32Array(16),vn=[0,0,0],yn=[0,0,0],xn=[];function bn(t,i,o){const r=o.cameraWorldSizeForFog/o.worldSize;return e.fc(t,o.worldToFogMatrix,[r,r,1]),e.er(t,t,i),t}function wn(t,i,o,r){return e.fQ(t,i,o),e.cm(r,e.n)||e.fc(t,t,r),t}function Tn(t,i,o,r,n){const s=o.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:d,emissionTexture:u}=s;function _(e,i,o){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+o),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:o,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,o,r);}}_(l,"HAS_TEXTURE_u_baseColorTexture",5),_(c,"HAS_TEXTURE_u_metallicRoughnessTexture",6),_(h,"HAS_TEXTURE_u_normalTexture",7),_(d,"HAS_TEXTURE_u_occlusionTexture",8),_(u,"HAS_TEXTURE_u_emissionTexture",9),n&&(n.texture||(n.texture=new e.a$(r.context,n.image,[n.image.height,n.image.height,n.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+10),n.texture&&n.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(o.texcoordBuffer)),o.colorBuffer&&(t.push(12===o.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(o.colorBuffer)),o.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(o.normalBuffer)),o.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(o.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const f=r.shadowRenderer;f&&(t.push("RENDER_SHADOWS"),f.useNormalOffset&&t.push("NORMAL_OFFSET"));}function En(t,i,o,r,n,s){const a=t.modelOpacity,l=i.context,c=new vi(i.context.gl.LEQUAL,t.isLightMesh?vi.ReadOnly:vi.ReadWrite,i.depthRangeFor3D),h=i.transform,d=t.mesh,u=d.material,_=u.pbrMetallicRoughness,f=i.style.fog;"pixels"===i.transform.projection.zAxisUnit?cn.set(t.nodeModelMatrix):e.er(cn,r.zScaleMatrix,t.nodeModelMatrix),e.er(cn,r.negCameraPosMatrix,cn),e.dr(hn,cn),e.fR(hn,hn);const p="none"===o.paint.get("model-color-use-theme").constantOr("default"),m=o.paint.get("model-emissive-strength").constantOr(0),g=sn(t.worldViewProjection,cn,hn,null,i,a,_.baseColorFactor,u.emissiveFactor,_.metallicFactor,_.roughnessFactor,u,m,o,void 0,void 0,t.materialOverride,t.modelColor),v={defines:[]},y=[],x=i.shadowRenderer;x&&(x.useNormalOffset=!1),Tn(v.defines,y,d,i,p?null:o.lut);let b=null;if(f&&(b=bn(dn,t.nodeModelMatrix,i.transform),"globe"!==h.projection.name)){const e=d.aabb.min,t=d.aabb.max,[i,o]=f.getOpacityForBounds(b,e[0],e[1],t[0],t[1]);v.overrideFog=i>=Zt||o>=Zt;}const w=Vi(i,o.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const T=i.getOrCreateProgram("model",v);i.uploadCommonUniforms(l,T,null,b,w),"shadow"!==i.renderPass&&x&&x.setupShadowsFromMatrix(t.nodeModelMatrix,T),T.draw(i,l.gl.TRIANGLES,c,n,s,d.material.doubleSided?gi.disabled:gi.backCCW,g,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,i.transform.zoom,void 0,y);}function Sn(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function In(t,i,o,r,n,s,a,l,c,h){const d=t.transform,u=!!i.isGeometryBloom&&i.isGeometryBloom;if(void 0!==i.minZoom&&t.transform.zoomi.maxZoom)return;if(u&&"shadow"===t.renderPass)return;const _="globe"===d.projection.name?e.bR(o,d):[...o];e.er(_,_,i.globalMatrix);const f=e.er([],r,_);if(i.meshes)for(const t of i.meshes){const r=l.get(t.material.name);if(r&&r.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:n,worldViewProjection:f,nodeModelMatrix:_,isLightMesh:u,materialOverride:r,modelOpacity:c,modelColor:h,node:i,modelMatrix:o});continue}const p=e.fL([],t.centroid,f);!d.isOrthographic&&p[2]<=0||s.push({mesh:t,depth:p[2],modelIndex:n,worldViewProjection:f,nodeModelMatrix:_,isLightMesh:u,materialOverride:r,modelOpacity:c,modelColor:h,node:i,modelMatrix:o});}if(i.children)for(const e of i.children)In(t,e,o,r,n,s,a,l,c,h);}function Cn(e,t,i,o,r){const n=i.shadowRenderer;if(!n)return;const s=n.getShadowPassDepthMode(),a=r||n.calculateShadowPassMatrixFromMatrix(t),l=an(a);i.getOrCreateProgram("modelDepth").draw(i,i.context.gl.TRIANGLES,s,Wi.disabled,$i.disabled,gi.disabled,l,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function Rn(t,i,o,r){const n=function(t,i){if(i.footprintDebugMesh)return i.footprintDebugMesh;if(!i.footprint)return null;const o=t.context,r=i.footprint.vertices,n=i.footprint.indices,s=new e.aQ;s.reserve(r.length);for(const e of r)s.emplaceBack(e.x,e.y);const a=new e.aT;a.reserve(n.length);for(let e=0;e0){const i=t.terrain,n=i.findDEMTileFor(o);n&&n.dem?r=e.k.create(i,o,n):a=0;}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return !1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eh&&(h=e.max);}const d=e.bG(r.x,s,a)-r.x,u=e.bG(r.y,l,c)-r.y,_=e.em(h,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(d*d+u*u+_*_))}function Fn(e,t,i,o,r,n,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new vi(a.gl.LEQUAL,vi.ReadWrite,e.depthRangeFor3D),d=e.isTileAffectedByFog(n),u="globe"===e.transform.projection.name;if(i.meshes)for(const _ of i.meshes){const f=u?[]:["MODEL_POSITION_ON_GPU"],p=[];let m,g,v;const y=!u&&o.instancedDataArray.length>20;y&&f.push("INSTANCED_ARRAYS");const x=Vi(e,t.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:f}),g=an(s.shadowTileMatrix,s.shadowTileMatrix,i.globalMatrix),v=$i.disabled;else {Tn(f,p,_,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),m=e.getOrCreateProgram("model",{defines:f,overrideFog:d});const o=_.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity").constantOr(1),u=t.paint.get("model-emissive-strength").constantOr(0);g=sn(n.expandedProjMatrix,i.globalMatrix,gn,null,e,h,l.baseColorFactor,o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,u,t,r),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(n.toUnwrapped(),m,"model-tile"),s.shadowUniformsInitialized=!0)),v=x.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?$i.alphaBlended:$i.unblended;}e.uploadCommonUniforms(a,m,n.toUnwrapped(),null,x);const b=_.material.doubleSided?gi.disabled:gi.backCCW;if(y)p.push(o.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,Wi.disabled,v,b,g,t.id,_.vertexBuffer,_.indexBuffer,_.segments,t.paint,e.transform.zoom,void 0,p,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let r=0;r0)if(t.targetLod<0)t.targetLod=i>r?1:0;else {const s=n>0?o/1e3/n:1;t.targetLod=e.bG(i>r?t.targetLod+s:t.targetLod-s,0,1);}else t.targetLod=0;}function kn(t,i,o,r){if(!o.modelManager)return !0;const n=o.modelManager;if(!o.shadowRenderer)return !0;const s=o.shadowRenderer,a=i.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const i in t.instancesPerModel){const t=n.getModel(i,r);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1;}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c);}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.fL(a.min,a.min,i.tileMatrix),e.fL(a.max,a.max,i.tileMatrix);const h=a.intersects(s.getCurrentCascadeFrustum());return 0===o.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===h),0===h}function Bn(t,i){const o=t.uniformValues.u_cutoff_params[0],r=t.uniformValues.u_cutoff_params[1],n=t.uniformValues.u_cutoff_params[2],s=t.uniformValues.u_cutoff_params[3];return r===o||s===n?1:e.bG(((i-o)/(r-o)-n)/(s-n),0,1)}function Nn(t,i,o,r){if(i.pitch<20)return 1;const n=i.getWorldToCameraMatrix();e.er(n,n,t);const s=e.cy(o.min[0],o.min[1],o.min[2],1);let a=e.fM(e.bX(),s,n),l=a,c=a;s[1]=o.max[1],a=e.fM(e.bX(),s,n),l=a[1]c[1]?a:c,s[0]=o.max[0],a=e.fM(e.bX(),s,n),l=a[1]c[1]?a:c,s[1]=o.min[1],a=e.fM(e.bX(),s,n),l=a[1]c[1]?a:c;const h=e.bG(r[0],0,1),d=100*i.pixelsPerMeter*e.bG(r[1],0,1),u=e.bG(r[2],0,1),_=e.d_(e.bX(),l,c,h),f=Math.tan(.5*i.fovX),p=-_[2]*f;if(0===d)return _[1]<-Math.abs(p)?u:1;const m=(-Math.abs(p)-_[1])/d,g=e.bG(e.dY(1,u,m),u,1);return e.dY(1,g,e.bG((i.pitch-20)/20,0,1))}const Un={drawModels:function(t,i,o,r){if("opaque"===t.renderPass)return;const n=o.paint.get("model-opacity").constantOr(1),s=o.paint.get("model-elevation-reference"),a="ground"===s,l="ground"===s;if(0===n)return;const c=o.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!c)return;if(t.terrain&&n<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof e.bh)return}const h=t.shadowRenderer,d=o.paint.get("model-receive-shadows");h&&(h.useNormalOffset=!0,d||(h.enabled=!1));const u=()=>{h&&(h.useNormalOffset=!0,d||(h.enabled=!0));},_=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==_.type)return;if("vector"===_.type||"geojson"===_.type)return function(t,i,o,r,n){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;o.modelManager=c;const h=t.shadowRenderer;if(!Object.hasOwn(o._unevaluatedLayout._values,"model-id"))return;const d=o._unevaluatedLayout._values["model-id"],u=Object.assign({},o.layout.get("model-id").parameters),_=t.style.order.indexOf(o.fqid),f=o.paint.get("model-opacity").constantOr(1);for(const p of r){const r=i.getTile(p).getBucket(o);if(!r||r.projection.name!==s.projection.name)continue;const m=r.getModelUris();if(m&&!r.modelsRequested&&(c.addModelsFromBucket(m,n),r.modelsRequested=!0),a)u.zoom=p.overscaledZ;else {const e=Mn(p,s);u.zoom=e;}const g=d.possiblyEvaluate(u);if(On(t,r,p),Pn.shadowUniformsInitialized=!1,Pn.useSingleShadowCascade=!!h&&0===h.getMaxCascadeForTile(p.toUnwrapped()),"shadow"===t.renderPass&&h){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(p.toUnwrapped(),s.worldSize);if(Pn.tileMatrix.set(i),Pn.shadowTileMatrix.set(h.calculateShadowPassMatrixFromMatrix(i)),Pn.aabb.min=[0,0,0],Pn.aabb.max[0]=Pn.aabb.max[1]=e.r,Pn.aabb.max[2]=0,kn(r,Pn,t,o.scope))continue}const v=1<0&&t.style.isLayerClipped(o,i.getSource())&&r.updateReplacement(p,t.replacementSource,_,o.scope)&&(r.uploaded=!1,r.upload(t.context));let x=0;const b=new Array,w=new Array,T=new Array;for(let i in r.instancesPerModel){const s=r.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const h=c.getModel(i,n);if(h||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),h&&h.uploaded)if(a){const i=e.fa([],[l.x,l.y,l.z],t.transform.worldSize);e.eu(i,i);for(let o=0;o0&&o.elevationUpdate(e.terrain,r,s,i.source),o.needsReEvaluation(e,n,i)&&o.evaluate(i));}}))(t,i,o,r),function(){const c=new Map;let d,u,f;S?(d=r.length-1,u=-1,f=-1):(d=0,u=r.length,f=1);const R=e.bU(),D=new e.au(0,0);for(let A=d;A!==u;A+=f){const d=r[A],u=i.getTile(d).getBucket(o);if(!u||!u.uploaded)continue;let f=!1;l&&(f=0===l.getMaxCascadeForTile(d.toUnwrapped()));const L=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize),O=!!(u.modelTraits&e.aj.HasMapboxMeshFeatures);e.er(un,p,L),e.er(_n,s.expandedFarZProjMatrix,L),e.dr(fn,un),e.fR(fn,fn);const P=!x&&l&&l.enabled?l.computeCascadeTileMatrices(L):null;!x&&S&&(e.dr(hn,L),e.fL(R,h,hn),D.x=R[0],D.y=R[1]);const M=[];u.setFilter(o.filter);for(const i of u.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const o=i.node;let r=0;t.terrain&&o.elevation&&(r=o.elevation*t.terrain.exaggeration());const n=(()=>{const t=i.aabb,o=y.min,n=y.max;return o[0]=t.min[0],o[1]=t.min[1],o[2]=t.min[2]+r,n[0]=t.max[0],n[1]=t.max[1],n[2]=t.max[2]+r,e.fL(o,o,L),e.fL(n,n,L),y})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===n.intersects(T))continue;if(!x){const o=n.min,r=n.max;vn[0]=.5*(o[0]+r[0]),vn[1]=.5*(o[1]+r[1]),vn[2]=.5*(o[2]+r[2]);const s=e.c5(h,vn)*_;zn(i,s,Math.min(t._debugParams.dt,1e3/30),t._debugParams.lodSwitchDistance,t._debugParams.lodSwitchFadeDuration);}if(!x&&S){const t=1/6;i.cameraCollisionOpacity=h[0]>n.min[0]&&h[0]n.min[1]&&h[1]!S||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of M){const r=i.nodeInfo,h=r.node;let d=null;if(t._debugParams.show3DModelFootprints&&h.footprint){const e=h.id||h.name||"footprint";if(!c.has(e)){const t=wn(new Float64Array(16),_n,i.tileTranslation,i.nodeInfo.evaluatedScale);c.set(e,{node:h,mvp:t});}}const u=i.nodeInfo.evaluatedScale;wn(cn,un,i.tileTranslation,u),mn[0]=1/u[0],mn[1]=-1/u[1],mn[2]=1/u[2],e.fc(hn,fn,mn),e.er(cn,cn,h.globalMatrix);const _=O?0:r.evaluatedRMEA[0][2],p=r.targetLod,m=h.lodMeshes&&h.lodMeshes.length>0,y=m&&p>0&&p<1;if(x&&m&&1===Math.round(p))continue;const T=!x&&a?bn(dn,i.nodeModelMatrix,t.transform):null,E=x&&l?l.calculateShadowPassMatrixFromMatrix(i.nodeModelMatrix):null,S=y?2:1,I=m&&1===Math.round(p);for(let e=0;e=Zt||o>=Zt;}const L=p.material;let M;L.occlusionTexture&&L.occlusionTexture.offsetScale&&(M=L.occlusionTexture.offsetScale,R.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),y&&R.defines.push("DITHERED_DISCARD");const F=t.getOrCreateProgram("model",R);if(!x&&l&&l.enabled)if(d!==A){for(let e=0;e0){const e=Array.from(c.keys()).sort();for(const i of e){const{node:e,mvp:o}=c.get(i);Rn(t,0,e,o);}}}();}(t,i,o,r),void u();if("model"!==_.type)return;const f=_.getModels(),p=[],m=t.transform.getFreeCameraOptions().position,g=e.fa([],[m.x,m.y,m.z],t.transform.worldSize);e.eu(g,g);const v=[],y=[];let x=0;for(const r of f){const n=i.getFeatureState("",r.id),s={type:"Unknown",id:r.id,properties:r.featureProperties},c=o.paint.get("model-rotation").evaluate(s,n),h=o.paint.get("model-scale").evaluate(s,n),d=o.paint.get("model-translation").evaluate(s,n),u=o.paint.get("model-opacity").evaluate(s,n);Dn(o,r.id,n,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),An(o,r.id,n,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,h,d,l,a,!1);const _=e.cw([],g),f=e.cX(r.position.lat,t.transform.zoom),m=e.cv([],[1,1,1/f]);p.push({zScaleMatrix:m,negCameraPosMatrix:_});for(const e of r.nodes)In(t,e,r.matrix,t.transform.expandedFarZProjMatrix,x,v,y,r.materialOverrides,u);x++;}if(v.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass){if(t._debugParams.show3DModelFootprints){const i=t.transform.projMatrix,o=new Map,r=(t,r)=>{if(t.footprint){const n=t.id||t.name||"footprint";if(!o.has(n)){const s=e.er([],i,r);o.set(n,{node:t,mvp:s});}}};for(const e of y)r(e.node,e.modelMatrix);for(const e of v)r(e.node,e.modelMatrix);const n=Array.from(o.keys()).sort();for(const e of n){const{node:i,mvp:r}=o.get(e);Rn(t,0,i,r);}}Ln(t,o,v,y,p),u();}else {for(const e of y)Cn(e.mesh,e.nodeModelMatrix,t,o);for(const e of v)Cn(e.mesh,e.nodeModelMatrix,t,o);u();}},prepare:function(e,t,i){const o=t.getSource();if(!o.loaded())return;if("vector"===o.type||"geojson"===o.type)return void(i.modelManager&&i.modelManager.upload(i,Sn(i,e)));if("batched-model"===o.type)return;if("model"!==o.type)return;const r=o.getModels();for(const e of r)e.upload(i.context);},shaders:{model:xr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nin highp float v_cutout_factor;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\ntexColor=vec4(unpremultiplyColor(texColor),1.0);\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));\n#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\napply_feature_cutout_dither(gl_FragCoord,v_cutout_factor);\n#else\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);\n#endif\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nout highp float v_cutout_factor;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp uvec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nv_cutout_factor=1.0;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#ifdef FEATURE_CUTOUT_VERTEX\nhighp vec4 ground_pos=vec4(pos_a.xy,0.0,1.0);highp vec4 cutout_clip_pos=mix(u_matrix*ground_pos,AWAY,hidden);highp vec3 cutout_ndc=cutout_clip_pos.xyz/cutout_clip_pos.w;vec2 uv=cutout_ndc.xy*0.5+0.5;highp float fragDepthNDC=cutout_ndc.z*0.5+0.5;\n#ifdef FLIP_Y\nfragDepthNDC=cutout_ndc.z;\n#endif\nhighp float cutoutFactor=get_cutout_factors_vert(uv).x;highp float cutoutDepthNDC=sample_cutout_depth(u_cutout_depth_image,uv);highp float groundThreshold=0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);v_cutout_factor=mix(1.0-cutoutFactor,1.0,groundLimit);\n#endif\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:xr("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\n}")},programUniforms:{model:t=>({u_matrix:new e.bb(t),u_lighting_matrix:new e.bb(t),u_normal_matrix:new e.bb(t),u_node_matrix:new e.bb(t),u_lightpos:new e.b7(t),u_lightintensity:new e.b4(t),u_lightcolor:new e.b7(t),u_camera_pos:new e.b7(t),u_opacity:new e.b4(t),u_baseColorFactor:new e.b8(t),u_emissiveFactor:new e.b8(t),u_metallicFactor:new e.b4(t),u_roughnessFactor:new e.b4(t),u_baseTextureIsAlpha:new e.b5(t),u_alphaMask:new e.b5(t),u_alphaCutoff:new e.b4(t),u_baseColorTexture:new e.b5(t),u_metallicRoughnessTexture:new e.b5(t),u_normalTexture:new e.b5(t),u_occlusionTexture:new e.b5(t),u_emissionTexture:new e.b5(t),u_lutTexture:new e.b5(t),u_color_mix:new e.b8(t),u_aoIntensity:new e.b4(t),u_emissive_strength:new e.b4(t),u_occlusionTextureTransform:new e.b8(t),u_dithered_discard_threshold:new e.b4(t)}),modelDepth:t=>({u_matrix:new e.bb(t),u_instance:new e.bb(t),u_node_matrix:new e.bb(t)})}};async function jn(){return Promise.resolve()}class Gn{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.au||"number"==typeof t[0]){const n=e.au.convert(t);o=[n],r=i.isPointAboveHorizon(n);}else {const n=e.au.convert(t[0]),s=e.au.convert(t[1]),a=n.add(s)._div(2);o=[n,s],r=e.eP(n,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a);}return new Gn(o,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.eP(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.au(1,1)):this.screenBounds[1],r=e.eP(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.bu(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.au(1,1)):this.screenBounds[1],r=e.eP(i,o,t),n=this.cameraPoint.clone(),s=Number(n.x>i.x)+Number(n.x>o.x);switch(3*(Number(n.y>i.y)+Number(n.y>o.y))+s){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(t,i,o,r=0){const n=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,s=o?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map(i=>e.d8(t.tileTransform,i,a));if(!e.eM(l,0,0,e.r,e.r))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map(i=>e.d9(t.tileTransform,i,a)),h=c.map(t=>new e.au(t[0],t[1])),d=i.getFreeCameraOptions().position||new e.ag(0,0,0),u=e.d9(t.tileTransform,d,a),_=c.map(t=>{const i=e.fx(t,t,u);return e.ex(i,i),new e.aB(u,i)}),f=e.eG(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:_,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(p=e.cI(l),p.min.x=e.bG(p.min.x,0,e.r),p.min.y=e.bG(p.min.y,0,e.r),p.max.x=e.bG(p.max.x,0,e.r),p.max.y=e.bG(p.max.y,0,e.r),p),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var p;}_bufferedScreenMercator(e,t){const i=Wn(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=Wn(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.er([],i.pixelMatrix,i.globeMatrix),r=[0,-e.P,0,1],n=[0,e.P,0,1],s=[0,0,0,1];e.fM(r,r,o),e.fM(n,n,o),e.fM(s,s,o);const a=new e.au(r[0]/r[3],r[1]/r[3]),l=new e.au(n[0]/n[3],n[1]/n[3]),c=e.eL(t,a)&&r[3]1?Vn(t.slice(0,u),i):[],p=unew e.au(Hn(t.x),t.y)),p=p.map(t=>new e.au(Hn(t.x),t.y));const m=[...f];0===m.length&&m.push(p.at(-1));const g=m.at(-1),v=e.dY(g.y,(0===p.length?f[0]:p[0]).y,_);let y;return y=c?[new e.au(0,v),new e.au(0,0),new e.au(1,0),new e.au(1,v)]:[new e.au(1,v),new e.au(1,1),new e.au(0,1),new e.au(0,v)],m.push(...y),0===p.length?m.push(f[0]):m.push(...p),{polygon:m.map(t=>new e.ag(t.x,t.y)),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,n=0;for(let e=0;er&&(r=t[e].x,n=e);for(let e=0;e.5&&(r.x{e.x-=1;}),{polygon:t,unwrapped:o}}(Vn(t,i).map(t=>new e.au(Hn(t.x),t.y)),i);return {polygon:r.polygon.map(t=>new e.ag(t.x,t.y)),unwrapped:r.unwrapped}}}function Vn(t,i){return e.f0(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;},1/256)}function Hn(e){return e<0?1+e%1:e%1}function Wn(e){return 100*e|0}class Zn extends e.y{constructor(t,i,o,r){if(super(),this.id=t,this.dispatcher=o,this.type="vector",this.provider=i.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,e.eF(i,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.m;}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview(),r=(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.v(r))):n&&(this._setTileJSON(n),H(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);};this.provider=this._options.provider;const n=e.f1(this._options);return n instanceof Error?(this._loaded=!0,this.fire(new e.v(n)),void(t&&t())):this.provider&&!n?(this._loaded=!0,this.fire(new e.v(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=n?this.loadTileJSONWithProvider(n,r):e.e7(this._options,this.map._requestManager,i,o,r))}loadTileJSONWithProvider(t,i){this.provider=t.name;const{request:o,options:r}=e.eC(this._options,this.map._requestManager),n=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:r,request:o},(t,o)=>{if(n.signal.aborted)return;if(t)return void i(t);const r=o?o.find(e=>null!=e):null,s=e.eW(this._options,r,this.map._requestManager);s instanceof Error?i(s):i(null,s);}),{cancel:()=>n.abort()}}_setTileJSON(e){if(Object.assign(this,e),this.hasWorldviews=!!e.worldview_options,e.worldview_default&&(this.worldviewDefault=e.worldview_default),e.vector_layers){this.vectorLayers=e.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const t of e.vector_layers)this.vectorLayerIds.push(t.id),e.worldview&&e.worldview[t.source]&&this.localizableLayerIds.add(t.id);}this.tileBounds=ko.fromTileJSON(e);}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.ea(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return Object.assign({},this._options)}loadTile(t,i){const o=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(o),n=this.map._requestManager.transformRequest(r,e.aH.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:n,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.co.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,frcCoverage:(()=>{const e=this.map.painter,i=e?e.frcCoverageFadeRange:null;if(null==i)return null;const o=e?e.frcCoverageSnapshot:null,r=this.map.transform.zoom=Math.ceil(i[1]),a=o&&s?o.getFullCoverageMask(t.tileID.canonical):null;return {frcMask:s&&null!=a?a:null,resolved:r||null!=o,polygons:n&&0!==n.frcMask?n.polygons:null,tileZoom:n&&0!==n.frcMask?n.tileId.z:null,sourceLayers:e?e.frcCoverageSourceLayers:["road","structure"]}})(),brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&e.dL(o)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else {const i=e.e9.call({deduped:this._deduped},l,(i,o)=>{if(i||!o)c.call(this,i);else {const i=e.cO(o.responseHeaders);l.data={rawData:o.rawData.slice(0),expires:i.expires,cacheControl:i.cacheControl},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0);}},!0);t.request={cancel:i};}function c(o,r){return delete t.request,t.aborted?i(null):o?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),void function(){if(t.aborted)return i(null);t.loadVectorData(r,this.map.painter),e.bv(this.dispatcher),i(null,r),t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null);}.call(this))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}const qn={vector:Zn,raster:Bo,"raster-dem":class extends Bo{constructor(e,t,i,o){super(e,t,i,o),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox";}loadTileJSONWithProvider(t,i){this.provider=t.name;const{request:o,options:r}=e.eC(this._options,this.map._requestManager),n=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:r,request:o},(t,o)=>{if(n.signal.aborted)return;if(t)return void i(t);const r=o?o.find(e=>null!=e):null,s=e.eW(this._options,r,this.map._requestManager);s instanceof Error?i(s):i(null,s);}),{cancel:()=>n.abort()}}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.aH.Tile),n={uid:t.uid,tileID:t.tileID,source:this.id,type:this.type,scope:this.scope,request:r,encoding:this.encoding};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,function(e,o){return delete t.request,t.aborted?(t.state="unloaded",i(null)):e?(t.state="errored",i(e)):(o&&(this.map._refreshExpiredTiles&&t.setExpiryData(o),o.borderReady||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID)),t.dem=o.dem,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0),t.state="loaded",void i(null))}.bind(this),void 0,!0));}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),t&&t();}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,n=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+o)%o,a=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.ap(t.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.ap(t.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.v(i));else {const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&o&&o.resourceTiming&&o.resourceTiming[this.id]&&(i.resourceTiming=o.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.x("data",i)),this._partialReload=!1,this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);});}loaded(){return this._loaded}reload(){const t=e.ea(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData();}loadTile(t,i){const o=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,n=r?{image:r.image.clone()}:null,s=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:n,scope:this.scope,pixelRatio:e.co.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.send(o,a,(e,r)=>s&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===o),i(null))),void 0,"loadTile"===o);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.a3{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type="video",this.options=t;}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.aH.Source).url);e.db(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.v(t)):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(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.v(new qe(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.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 e.a_(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.a3,model:e.ai,"batched-model":class extends e.y{constructor(e,t,i,o){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(o);}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.ea(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=e.e7(this._options,this.map._requestManager,i,o,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.v(r))):n&&(Object.assign(this,n),n.bounds&&(this.tileBounds=new ko(n.bounds,this.minzoom,this.maxzoom)),H(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);});}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,e.aH.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.co.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else {if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,n.bind(this));}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,n.bind(this),void 0,!0);function n(e,o){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&o&&t.setExpiryData(o),t.loadModelData(o,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.a3{constructor(t,i,o,r){super(t,i,o,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.v(new qe(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.v(new qe(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.v(new qe(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.v(new qe(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.v(new qe(`sources.${t}`,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 HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.v(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(e){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.bd||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.a_(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.y{constructor(t,i,o,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.v(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.v(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ko(this._implementation.bounds,this.minzoom,this.maxzoom));const n=i;n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.eF(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.eF(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:o,z:r}=e.tileID.canonical,n=new AbortController,s=Promise.resolve(this._implementation.loadTile({x:i,y:o,z:r},{signal:n.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i));});s.cancel=()=>n.abort(),e.request=s;}loadTileData(e,t){e.setTexture(t,this.map.painter);}unloadTile(t,i){if(t.texture&&t.texture instanceof e.a_?(t.destroy(!1),t.texture&&t.texture instanceof e.a_&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}i&&i();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t();}hasTransition(){return !1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){const t=e.ea(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}));}}},$n=function(t,i,o,r){const n=new qn[i.type](t,i,o,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return e.bs(["load","abort","unload","serialize","prepare"],n),n};function Xn(e,t,i=""){return `${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return `layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return `featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function Yn(e,t,i,o=""){if(e.uniqueFeatureID){const r=Xn(e,t,o);if(i.has(r))return !0;i.add(r);}return !1}function Kn(e,t,i,o,r=!1,n=void 0){const s=t.sourceCache.transform,a=t.sourceCache.tilesIn(e,t.has3DLayers,r);a.sort(es);const l=[];for(const e of a){const a=e.tile.queryRenderedFeatures(t,e,i,o,s,r,n);Object.keys(a).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:a});}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,o);Object.keys(i).length&&l.push({wrappedTileID:0,queryResults:i});}}return 0===l.length?{}:function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,n=i[r]=i[r]||{};for(const i in e){const o=e[i],r=n[i]=n[i]||{},s=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e));}}return t}(l)}function Qn(e,t,i,o,r,n){const s={},a=o.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(es);for(const e of l){const o=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,n);for(const t in o){const i=s[t]=s[t]||[],r=o[t];r.sort((t,i)=>{const o=e.featureSortOrder;if(o){const e=o.indexOf(t.featureIndex);return o.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e);}}return s}function Jn(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),o=[],r={};for(let e=0;e0:"building"===i.type?o=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let n=o?o.getTile(t):null;if(!n&&o)for(const e in o._tiles){const i=o._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){n=i;break}}this.currentBuildingBuckets.push({bucket:n?n.getBucket(i):null,tileID:n?n.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o{e in n&&(s[e]=n[e]);}),o}function ns(e){e=e.slice();const t=Object.create(null);for(const i of e)t[i.id]=i;for(let i=0;ie.collisionGroupID===t};}return this.collisionGroups[e]}}function Ts(t,i,o,r,n){const{horizontalAlign:s,verticalAlign:a}=e.cE(t),l=-(s-.5)*i,c=-(a-.5)*o,h=e.cj(t,r);return new e.au(l+h[0]*n,c+h[1]*n)}function Es(t,i,o,r,n){const s=new e.au(t,i);return o&&s._rotate(r?n:-n),s}function Ss(t,i,o,r){const{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=o,h=e.cF(i),d=r===e.bg.vertical?l:"left"===h?n:"center"===h?s:"right"===h?a:-1;n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=d>=0&&n!==d?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=d>=0&&s!==d?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=d>=0&&a!==d?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=d>=0&&l!==d?0:c);}function Is(t,i,o){const r=i===e.bg.horizontal||i===e.bg.horizontalOnly?i:0,n=i===e.bg.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;s>=0&&(h.get(s).placedOrientation=r),a>=0&&(h.get(a).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=n);}class Cs{constructor(e,t,i,o,r,n,s,a){this.transform=e.clone(),this.projection=e.projection.name,this.algorithm=o,this.collisionIndex=this.algorithm.createCollisionDetector(this.transform,n,a),this.buildingIndex=s,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new ws(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0;}getBucketParts(t,i,o,r,n=1){const s=o.getBucket(i),a=o.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,h=o.collisionBoxArray,d=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),u=o.tileSize/e.r,_=o.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(p=o.tileID,m=s.getProjection(),g=this.transform,m.name===this.projection?g.calculateProjMatrix(p.toUnwrapped()):fs(g,m,p));var p,m,g;const v="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const x=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(o),E=Ci(f,o.tileID.canonical,v,y,this.transform,s.getProjection(),T);let S=null;const I=s.getProjection().createInversionMatrix(this.transform,o.tileID.canonical);if(v){const t=Ri(f,o.tileID.canonical,v,y,this.transform,s.getProjection(),T);S=e.er([],this.transform.labelPlaneMatrix,t);}let C=null;x&&o.latestFeatureIndex&&(C={unwrappedTileID:_,dynamicFilter:x,dynamicFilterNeedsFeature:b,needGeometry:w}),this.retainedQueryData[s.bucketInstanceId]=new bs(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,o.tileID);const[R,D]=s.layers[0].layout.get("text-size-scale-range"),A=e.bG(n,R,D),[L,O]=l.get("icon-size-scale-range"),P=e.bG(n,L,O),M={bucket:s,layout:l,paint:c,posMatrix:f,invMatrix:I,mercatorCenter:[e.ek(this.transform.center.lng),e.el(this.transform.center.lat)],textLabelPlaneMatrix:E,labelToScreenMatrix:S,clippingData:C,scale:d,textPixelRatio:u,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.ci(s.textSizeData,this.transform.zoom,A),partiallyEvaluatedIconSize:e.ci(s.iconSizeData,this.transform.zoom,P),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:o.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:M});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:M});}placeLayerBucketPart(e,t,i,o,r=1){this.algorithm.placeLayerBucketPart(this,e,t,i,o,r);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],n=r[e];n?(this.opacities[e]=new vs(n,o,t.text,t.icon,null,t.clipped),i=i||t.text!==n.text.placed||t.icon!==n.icon.placed):(this.opacities[e]=new vs(null,o,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new vs(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in n)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=n[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){o&&(this.lastReplacementSourceUpdateTime=o.updateTime);const r=new Set;for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,n,n.collisionBoxArray,i,o,n.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,n.tileID),"road"===t.elevationType&&t.hdExt&&t.hdExt.updateRoadElevation(t,n.tileID.canonical),t.updateZOffset());}}updateBucketOpacities(t,i,o,r,n,s,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,h=t.layers[0].paint,d=!!t.layers[0].dynamicFilter(),u=new vs(null,0,!1,!1,!0),_=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),p=c.get("text-variable-anchor"),m="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),v=h.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),x=!v.isConstant(),b=new vs(null,0,_&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(_||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const w=(e,t,i)=>{for(let o=0;o0||_>0,P=E>0,M=this.placedOrientations[f],F=M===e.bg.vertical,z=M===e.bg.horizontal||M===e.bg.horizontalOnly;!O&&!P||L.isHidden()||T++;let k=!1;if((O||P)&&s)for(const i of t.activeReplacements){if(e.fp(i,n,e.a8.Symbol,l))continue;if(i.min.x>S||S>i.max.x||i.min.y>I||I>i.max.y)continue;const t=e.fN(S,I,a.canonical,i.footprintTileId.canonical);if(k=e.eI(t,i.footprint),k)break}if(k&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,c.featureIndex),O){const e=k?ks:zs(L.text);w(t.text,h,F?ks:e),w(t.text,_,z?ks:e);const i=L.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||F?1:0;o>=0&&(a.get(o).hidden=l),r>=0&&(a.get(r).hidden=l),n>=0&&(a.get(n).hidden=l),s>=0&&(a.get(s).hidden=i||z?1:0);const d=this.variableOffsets[f];d&&Ss(t,d.anchor,c,M);const u=this.placedOrientations[f];u&&(Ss(t,"left",c,u),Is(t,u,c));}if(P){const e=k?ks:zs(L.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=c,r=t.icon.placedSymbolArray,n=L.icon.isHidden()?1:0;i>=0&&(w(t.icon,E,F?ks:e),r.get(i).hidden=n),o>=0&&(w(t.icon,c.numVerticalIconVertices,z?ks:e),r.get(o).hidden=n);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let o=new e.au(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(p){const e=this.variableOffsets[f];e?(o=Ts(e.anchor,e.width,e.height,e.textOffset,e.textScale),m&&o._rotate(g?this.transform.angle:-this.transform.angle)):r=!1;}d&&(r=!L.clipped),i.textBox&&Rs(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||F,D,y,o.x,o.y),i.verticalTextBox&&Rs(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||z,D,y,o.x,o.y);}const n=r&&Boolean(!z&&i.verticalIconBox);i.iconBox&&Rs(t.iconCollisionBox.collisionVertexArray,L.icon.placed,n,D,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0),i.verticalIconBox&&Rs(t.iconCollisionBox.collisionVertexArray,L.icon.placed,!n,D,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return e-this.lastPlacementChangeTimee}isStale(){return this.stale}setStale(){this.stale=!0;}}function Rs(e,t,i,o,r,n,s){e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0);}const Ds=Math.pow(2,25),As=Math.pow(2,24),Ls=Math.pow(2,17),Os=Math.pow(2,16),Ps=Math.pow(2,9),Ms=Math.pow(2,8),Fs=Math.pow(2,1);function zs(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Ds+t*As+i*Ls+t*Os+i*Ps+t*Ms+i*Fs+t}const ks=0;class Bs{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}const Ns=100;class Us{constructor(e,t){this.gridRightBoundary=0,this.gridBottomBoundary=0,this.clippedSymbols=new Map,this.reset(e,t);}reset(t,i){const o=t.width+200,r=t.height+200;o!==this.gridRightBoundary||r!==this.gridBottomBoundary?(this.grid=new e.V(o,r,25),this.ignoredGrid=new e.V(o,r,25)):(this.grid.clear(),this.ignoredGrid.clear()),this.transform=t,this.fogState=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Ns,this.screenBottomBoundary=t.height+Ns,this.gridRightBoundary=o,this.gridBottomBoundary=r,this.clippedSymbols.clear();}clearClippedSymbolsForBucket(e){this.clippedSymbols.delete(e);}markSymbolAsClipped(e,t){let i=this.clippedSymbols.get(e);i||(i=new Set,this.clippedSymbols.set(e,i)),i.add(t);}placeCollisionBox(t,i,o,r,n,s,a,l,c,h,d){let u=o.projectedAnchorX,_=o.projectedAnchorY,f=o.projectedAnchorZ;const p=o.tileAnchorX,m=o.tileAnchorY,g=o.elevation,v=o.tileID,y=t.getProjection();if(g&&v){const[e,t,i]=y.upVector(v.canonical,o.tileAnchorX,o.tileAnchorY),r=y.upVectorScale(v.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;u+=e*g*r,_+=t*g*r,f+=i*g*r;}const x="globe"===t.projection.name,b="globe"===t.projection.name?e.dm(this.transform.zoom):0;if(v&&x&&b<1&&!s){const t=1<0,y),T=c*w.perspectiveRatio,E=(o.x1*i+a.x-o.padding)*T+w.point.x,S=(o.y1*i+a.y-o.padding)*T+w.point.y,I=(o.x2*i+a.x+o.padding)*T+w.point.x,C=(o.y2*i+a.y+o.padding)*T+w.point.y,R=w.perspectiveRatio<=.55||w.occluded;return !this.isInsideGrid(E,S,I,C)||!l&&this.grid.hitTest(E,S,I,C,d)||R?{box:[],offscreen:!1,occluded:w.occluded}:{box:[E,S,I,C],offscreen:this.isOffscreen(E,S,I,C),occluded:!1}}placeCollisionCircles(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m){const g=[],v=this.transform.elevation,y=t.getProjection(),x="road"===t.elevationType,b=!!v||x,w=e.s.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y),T=new e.au(o.tileAnchorX,o.tileAnchorY),E=new e.au(o.tileAnchorX,o.tileAnchorY);let{x:S,y:I,z:C}=y.projectTilePoint(E.x,E.y,m.canonical),R=null;if(b){const e=x&&t.hdExt?t.hdExt.getElevationFeatureForPlacedSymbol(t,t.text,r):null;R={getElevation:w,elevation:v,elevationFeature:e};const[i,o,n]=w(T,v,e);S+=i,I+=o,C+=n;}const D="globe"===y.name,A=this.projectAndGetPerspectiveRatio(l,S,I,C,m,D||!!v||this.transform.pitch>0,y),{perspectiveRatio:L}=A,O=(u?a/L:a*L)/e.ao,P=Di(S,I,C,c),M=o.lineOffsetX*O,F=o.lineOffsetY*O,z=e.c4(t.layers[0].layout.get("text-max-angle")),k=Math.cos(z),B=A.signedDistanceFromCamera>0?Pi(O,s,M,F,x&&1===o.flipState,P,E,o,n,c,{},b&&!u?R:null,u&&b,y,m,u,k):null;let N=!1,U=!1,j=!0;if(B&&!A.occluded){const t=.5*f*L+p,o=new e.au(-100,-100),r=new e.au(this.screenRightBoundary,this.screenBottomBoundary),n=new Bs,{first:s,last:a}=B,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e(b&&!D&&(i=w(oe[3]<=0)&&(c=[]));let m=[];if(c.length>0){let t=1/0,i=-1/0,n=1/0,s=-1/0;for(const e of c)t=Math.min(t,e[0]),n=Math.min(n,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=o.x&&t<=r.x&&s>=o.y&&n<=r.y&&(m=[c.map(t=>new e.au(t[0],t[1]))],(tr.x||nr.y)&&(m=e.bI(m,o.x,o.y,r.x,r.y)));}for(const e of m){n.reset(e,.25*t);let o=0;o=n.length<=.5*t?1:Math.ceil(n.paddedLength/u)+1;for(let e=0;e0){if(e.fM(l,l,t),this.fogState&&n&&"globe"!==a.name){const t=function(t,i,o,r,n,s){const a=s.calculateFogTileMatrix(n),l=[i,o,r];return e.fL(l,l,a),qt(t,e.dW(l),s.pitch)}(this.fogState,i,o,r,n.toUnwrapped(),this.transform);c=t>.9;}}else Ui(l,l,t);const h=l[3];return {point:new e.au((l[0]/h+1)/2*this.transform.width+Ns,(-l[1]/h+1)/2*this.transform.height+Ns),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:s&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&t2}placeLayerBucketPart(t,i,o,r,n,s=1){const{bucket:a,layout:l,paint:c,posMatrix:h,textLabelPlaneMatrix:d,labelToScreenMatrix:u,clippingData:_,textPixelRatio:f,mercatorCenter:p,invMatrix:m,holdingForFade:g,collisionBoxArray:v,partiallyEvaluatedTextSize:y,partiallyEvaluatedIconSize:x,collisionGroup:b,latestFeatureIndex:w}=i.parameters,T=l.get("text-optional"),E=l.get("icon-optional"),S=l.get("text-allow-overlap"),I=l.get("icon-allow-overlap"),C="map"===l.get("text-rotation-alignment"),R="map"===l.get("icon-rotation-alignment"),D="map"===l.get("text-pitch-alignment"),A=c.get("symbol-z-offset"),L="sea"===l.get("symbol-elevation-reference"),O=l.get("symbol-placement"),[P,M]=l.get("text-size-scale-range"),[F,z]=l.get("icon-size-scale-range"),k=e.bG(s,P,M),B=e.bG(s,F,z),N=l.get("text-variable-anchor"),U=C&&"point"!==O,j=R&&"point"!==O,G=N&&a.hasTextData(),V=a.hasIconTextFit()&&G&&a.hasIconData();t.transform.setProjection(a.projection);const H=G||U,W=j||V;let Z=S&&(I||!a.hasIconData()||E),q=I&&(S||!a.hasTextData()||T);const $=!A.isConstant();!a.collisionArrays&&v&&a.deserializeCollisionBoxes(v),r&&n&&a.updateCollisionDebugBuffers(t.transform.zoom,v,k,B);const X=(i,n,s)=>{const{crossTileID:c,numVerticalGlyphVertices:v}=i;let R=null;if(_&&_.dynamicFilterNeedsFeature||$){const o=t.retainedQueryData[a.bucketInstanceId],r=w.loadFeature({featureIndex:i.featureIndex,bucketIndex:o.bucketIndex,sourceLayerIndex:o.sourceLayerIndex,layoutVertexArrayOffset:0}),n=r.properties?r.properties.worldview:null;if(a.localizable&&a.worldview&&"string"==typeof n)if("all"===n)r.properties.$localized=!0;else {if(!n.split(",").includes(a.worldview))return;r.properties.$localized=!0,r.properties.worldview=a.worldview;}R=_&&_.needGeometry?e.fJ(r,!0):r;}if(_&&!(0,_.dynamicFilter)({zoom:t.transform.zoom,pitch:t.transform.pitch,worldview:a.worldview},R,t.retainedQueryData[a.bucketInstanceId].tileID.canonical,new e.au(i.tileAnchorX,i.tileAnchorY),t.transform.calculateDistanceTileData(_.unwrappedTileID)))return t.placements[c]=new ys(!1,!1,!1,!0),void o.add(c);const O=A.evaluate(R,{});if((i.zOffset||0)+(O||0)>0&&t.frontCutoffStart>0){const r=2*t.frontCutoffStart-1,n=[i.tileAnchorX,i.tileAnchorY,0,1],s=e.fM(e.bX(),n,h);if(s[1]/s[3]{o.tileID=t.retainedQueryData[a.bucketInstanceId].tileID;const r=t.transform.elevation;o.elevation=L?O:O+e.s.getAtTileOffset(o.tileID,new e.au(o.tileAnchorX,o.tileAnchorY),r,J),o.elevation+=i.zOffset;},te=s.textBox;if(te){ee(te);const o=o=>{let r=e.bg.horizontal;if(a.allowVerticalPlacement&&!o&&t.prevPlacement){const e=t.prevPlacement.placedOrientations[c];e&&(t.placedOrientations[c]=e,r=e,Is(a,r,i));}return r},r=(t,i)=>{if(a.allowVerticalPlacement&&v>0&&s.verticalTextBox){for(const o of a.writingModes)if(o===e.bg.vertical?(U=i(),j=U):U=t(),U&&U.box&&U.box.length)break}else U=t();};if(N){let l=N;if(t.prevPlacement&&t.prevPlacement.variableOffsets[c]){const e=t.prevPlacement.variableOffsets[c];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor),l.unshift(e.anchor));}const d=(e,o,r)=>{const s=a.getSymbolInstanceTextSize(y,i,t.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,d=(e.y2-e.y1)*s+2*e.padding,u=i.hasIconTextFit&&!I?o:null;u&&ee(u);let _={box:[],offscreen:!1,occluded:!1};const g=S?2*l.length:l.length;for(let o=0;o=l.length,i,n,a,r,u,y,x);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){P=!0,B=g.shift;break}}return _};r(()=>d(te,s.iconBox,e.bg.horizontal),()=>{const t=s.verticalTextBox;return t&&ee(t),a.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&v>0&&t?d(t,s.verticalIconBox,e.bg.vertical):{box:null,offscreen:null,occluded:null}}),U&&(P=U.box,F=U.offscreen,z=U.occluded);const u=o(!(!U||!U.box));if(!P&&t.prevPlacement){const e=t.prevPlacement.variableOffsets[c];e&&(t.variableOffsets[c]=e,Ss(a,e.anchor,i,u));}}else {const l=(o,r)=>{const s=a.getSymbolInstanceTextSize(y,i,t.transform.zoom,n),l=t.collisionIndex.placeCollisionBox(a,s,o,p,m,H,new e.au(0,0),S,f,h,b.predicate);return l&&l.box&&l.box.length&&(Is(a,r,i),t.placedOrientations[c]=r),l};r(()=>l(te,e.bg.horizontal),()=>{const t=s.verticalTextBox;return a.allowVerticalPlacement&&v>0&&t?(ee(t),l(t,e.bg.vertical)):{box:null,offscreen:null,occluded:null}}),o(!!(U&&U.box&&U.box.length));}}if(G=U,P=G&&G.box&&G.box.length>0,F=G&&G.offscreen,z=G&&G.occluded,i.useRuntimeCollisionCircles){const o=i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex,n=a.text.placedSymbolArray.get(o),s=e.ch(a.textSizeData,y,n),c=l.get("text-padding");V=t.collisionIndex.placeCollisionCircles(a,S,n,o,a.lineVertexArray,a.glyphOffsetArray,s,h,d,u,r,D,b.predicate,i.collisionCircleDiameter*s/e.ao,c,t.retainedQueryData[a.bucketInstanceId].tileID),P=S||V.circles.length>0&&!V.collisionDetected,F=F&&V.offscreen,z=V.occluded;}if(s.iconFeatureIndex&&(Q=s.iconFeatureIndex),s.iconBox){const o=o=>{ee(o);const r=i.hasIconTextFit&&B?Es(B.x,B.y,C,D,t.transform.angle):new e.au(0,0),n=a.getSymbolInstanceIconSize(x,t.transform.zoom,i.placedIconSymbolIndex);return t.collisionIndex.placeCollisionBox(a,n,o,p,m,W,r,I,f,h,b.predicate)};j&&j.box&&j.box.length&&s.verticalIconBox?(X=o(s.verticalIconBox),M=X.box.length>0):(X=o(s.iconBox),M=X.box.length>0),F=F&&X.offscreen,k=X.occluded;}const ie=T||0===i.numHorizontalGlyphVertices&&0===v,oe=E||0===i.numIconVertices;if(ie||oe?oe?ie||(M=M&&P):P=M&&P:M=P=M&&P,P&&G&&G.box&&t.collisionIndex.insertCollisionBox(G.box,l.get("text-ignore-placement"),a.bucketInstanceId,j&&j.box&&K?K:Y,b.ID),M&&X&&t.collisionIndex.insertCollisionBox(X.box,l.get("icon-ignore-placement"),a.bucketInstanceId,Q,b.ID),V&&(P&&t.collisionIndex.insertCollisionCircles(V.circles,l.get("text-ignore-placement"),a.bucketInstanceId,Y,b.ID),r)){const e=a.bucketInstanceId;let i=t.collisionCircleArrays[e];void 0===i&&(i=t.collisionCircleArrays[e]=new xs);for(let e=0;e=0;--e){const t=i[e];X(a.symbolInstances.get(t),t,a.collisionArrays[t]);}a.hasAnyZOffset&&e.f_(`${a.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(a.hasAnyZOffset){const e=a.getSortedIndexesByZOffset();for(let t=0;t0){let i;return e.prevPlacement&&e.prevPlacement.variableOffsets[E]&&e.prevPlacement.placements[E]&&e.prevPlacement.placements[E].text&&(i=e.prevPlacement.variableOffsets[E].anchor),e.variableOffsets[E]={textOffset:S,width:s,height:a,anchor:t,textScale:l,prevAnchor:i},Ss(g,t,p,v),g.allowVerticalPlacement&&(Is(g,v,p),e.placedOrientations[E]=v),{shift:I,placedGlyphBoxes:C}}}}};class Gs{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,o,r,n){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this.isFullPlacementRequested()&&0!==this._fadeDuration&&this.placement.algorithm.shouldPause(e.co.now()-s);for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&"none"!==s.visibility&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),h="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),d=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),u=h&&d,_=this._inProgressLayer=this._inProgressLayer||new Gs(t),f=e.ea(s.source,s.scope);if(_.continuePlacement(i||u?r[f]:o[f],this.placement,this._showCollisionBoxes,s,a,n))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._forceFullPlacement=!1,this._done=!0;}commit(e){return this._retiredCI=this.placement.prevPlacement?this.placement.prevPlacement.collisionIndex:null,this.placement.commit(e),this.placement}}const Hs=512/e.r/2;class Ws{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.a6(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.r,n=t.canonical.y*e.r;for(let e=0;ee-t);for(const e of _){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!o.has(t)){o.add(t),i.crossTileID=t;break}}}}}class Zs{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class qs{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],o={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),o[r.tileID.key]=r;}this.indexes[e]=o;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in r){const n=r[i];n.tileID.isChildOf(e)&&n.findMatches(t.symbolInstances,e,o);}else {const n=r[e.scaledTo(Number(i)).key];n&&n.findMatches(t.symbolInstances,e,o);}}for(let e=0;e{t[e]=!0;});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}class Xs extends e.y{constructor(e){super(),this.requestManager=e,this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null);}loadModel(t,i){return e.e6(this.requestManager.transformRequest(i,e.aH.Model).url).then(o=>{const r=e.bQ(o),n=new e.ah(t,i,void 0,void 0,r);return n.computeBoundsAndApplyParent(),n}).catch(o=>{if(o&&404===o.status)return null;this.fire(new e.v(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));})}load(t,i,o={forceReload:!1}){this.models[i]||(this.models[i]=Object.create(null));const r=Object.keys(t),n=[],s=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!o.forceReload||(this.modelByURL[r]={modelId:e,scope:i},n.push(this.loadModel(e,r)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1});}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(n).then(t=>{for(let e=0;e{this.fire(new e.v(new Error(`Could not load models: ${t.message}`)));});}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t,i={exactIdMatch:!1}){return !!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]=Object.create(null)),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||Object.create(null)}addModel(e,t,i){this.models[i]||(this.models[i]=Object.create(null)),this.modelUris[i]||(this.modelUris[i]=Object.create(null));const o=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===o)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(o)){const{scope:e,modelId:t}=this.modelByURL[o];this.models[e][t].numReferences++;}else this.modelUris[i][e]=o,this.load({[e]:this.modelUris[i][e]},i);}addModelURLs(e,t){this.models[t]||(this.models[t]=Object.create(null)),this.modelUris[t]||(this.modelUris[t]=Object.create(null));const i=this.modelUris[t];for(const t of Object.keys(e))i[t]=this.requestManager.normalizeModelURL(e[t]);}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0});}addModelsFromBucket(e,t){this.models[t]||(this.models[t]=Object.create(null)),this.modelUris[t]||(this.modelUris[t]=Object.create(null));const i=Object.create(null);for(const o of e)this.hasModel(o,t,{exactIdMatch:!0})||this.hasURLBeenRequested(o)?this.models[t][o].numReferences++:this.modelUris[t][o]&&!this.hasURLBeenRequested(o)?i[o]=this.modelUris[t][o]:!this.hasURLBeenRequested(o)&&pt(o,!1)&&(this.modelUris[t][o]=this.requestManager.normalizeModelURL(o),i[o]=this.modelUris[t][o]);this.load(i,t);}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,o=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||o)){const o=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[o];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy();}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy();}this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null);}listModels(e){return this.models[e]||(this.models[e]=Object.create(null)),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]=Object.create(null));for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}const Ys=["RENDER_SHADOWS","NORMAL_OFFSET"],Ks=new Set(["symbol","circle"]),Qs=class t{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null;}needsBuild(){return this._needsBuild}buildQueue(e,t,i){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;const o=i.stylesheet,r=!!i.fog,n=!!(i.getTerrain()||o&&o.terrain),s=!(!i.projection||"globe"!==i.projection.name),a=n||s,l=!(!i.directionalLight||!i.directionalLight.shadowsEnabled()),c=i.map&&i.map.painter,h=!c||!c.context.extParallelShaderCompile,d=!!c&&"mrt-fallback"===c.emissiveMode,u=(e,t=[],i={})=>{this._queue.push({programId:e,params:Object.assign({},i.params,{defines:t,overrideFog:!!i.fog,overrideTerrain:!!i.terrain,overrideGlobe:!!i.globe,overrideRtt:!!i.rtt,precompiled:!0})});};for(const o of e){if("none"===o.visibility)continue;const e=o.getProgramIds();if(e)for(const _ of e){if(Ks.has(_))continue;const e=o.getDefaultProgramParams(_,t.zoom,i._styleColorTheme.lut);if(!e)continue;const f=c?c.getShaderSource(_):null,p=a&&(!f||f.usedDefines.has("RENDER_TO_TEXTURE")),m=d&&p?(e.defines||[]).concat("USE_MRT1"):e.defines;if(h){u(_,e.defines,{params:e}),p&&u(_,m,{params:e,rtt:!0});continue}const g=r&&(!f||f.usedDefines.has("FOG")),v=n&&!o.isDraped()&&(!f||f.usedDefines.has("TERRAIN")),y=s&&(!f||f.usedDefines.has("GLOBE")),x=l&&o.hasElevation()&&(!f||f.usedDefines.has("RENDER_SHADOWS"));for(const t of x?[!1,!0]:[!1]){const i=t?(e.defines||[]).concat(Ys):e.defines||[];for(const t of v?[!1,!0]:[!1])for(const o of y?[!1,!0]:[!1])for(const r of g?[!1,!0]:[!1])u(_,i,{params:e,fog:r,terrain:t,globe:o});}p&&u(_,m,{params:e,rtt:!0});}}if(u("clippingMask"),n)for(const e of [!1,!0])u("terrainRaster",e?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:r});if(!h){if(e.some(e=>"hillshade"===e.type)&&u("hillshadePrepare"),l)for(const e of [!1,!0])for(const t of [!1,!0]){const i=[];e&&i.push("RENDER_CUTOFF"),i.push("RENDER_SHADOWS"),t&&i.push("NORMAL_OFFSET"),u("groundShadow",i),r&&u("groundShadow",i,{fog:!0});}if(s){for(const e of [[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(const t of [!1,!0]){const i=[...e,"PROJECTION_GLOBE_VIEW"];t&&i.push("CUSTOM_ANTIALIASING"),u("globeRaster",i,{terrain:n,globe:!0,fog:r});}for(const e of [!1,!0]){const t=e?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];u("globeAtmosphere",t,{fog:!0,terrain:n,globe:e}),u("globeAtmosphere",[...t,"ALPHA_PASS"],{fog:!0,terrain:n,globe:e});}u("stars",[],{fog:r,terrain:n,globe:!0});}}}_executeBatch(i,o,r){if(r.map&&r.map.isMoving())return void(this._idleHandle=e.co.requestIdleCallback(e=>this._executeBatch(e,o,r)));o.context.sweepPendingPrograms();const n=o.context.extParallelShaderCompile?t.DEADLINE_MARGIN_KHR_MS:t.DEADLINE_MARGIN_SYNC_MS;let s=0;for(;this._queue.length>0;){const e=this._queue.shift();if(!e)break;if(o.style=r,o._fogVisible=!!e.params.overrideFog,o.getOrCreateProgram(e.programId,e.params),s++,i.timeRemaining()<=n)break}const a=0===this._queue.length||i.timeRemaining()>n;s>0&&a&&o.context.gl.flush(),this._idleHandle=this._queue.length>0||o.context._pendingPrograms.size>0?e.co.requestIdleCallback(e=>this._executeBatch(e,o,r)):null;}processQueue(t,i){0!==this._queue.length&&(null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=e.co.requestIdleCallback(e=>this._executeBatch(e,t,i)));}reset(){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0;}};Qs.DEADLINE_MARGIN_KHR_MS=5,Qs.DEADLINE_MARGIN_SYNC_MS=25;let Js=Qs;const ea=e.fs.colorTheme,ta=new e.ax({data:new e.l(ea.data)});function ia(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.co.devicePixelRatio,{left:o,top:r,width:n,height:s}=t.metadata.content_area,a=o*i,l=r*i;return [a,l,a+n*i,l+s*i]}function oa(t){if(t)return t.map(([t,i])=>[t*e.co.devicePixelRatio,i*e.co.devicePixelRatio])}class ra{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set;}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name);}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const o=this.sourceCache.getSource();if(!(o instanceof Uo))return t;const r=i.map(e=>this.sourceCache.getTile(e)),n=o.getImages(r,Array.from(this.pendingRequests));for(const[i,o]of n)t.set(e.a1.from({name:i,iconsetId:this.id}),o),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const na=(e,t)=>Ut(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),sa=(t,i)=>{const o=t.type&&!t.array&&Array.isArray(i)?{type:t.type,"property-type":"data-constant"}:void 0;return e.bY(i,o)},aa=e.eF(ss,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),la=e.eF(ss,["setCenter","setZoom","setBearing","setPitch"]),ca=new Set(["background","sky","slot","custom"]),ha={version:8,layers:[],sources:{}},da={duration:300,delay:0};class ua extends e.y{constructor(t,i={}){if(super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=Object.assign({},da),this._buildingIndex=new ts(this),this.crossTileSymbolIndex=new $s,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers=Object.create(null),this._mergedIndoor={},this._indoorEnabled=!1,this._mergedSourceCaches={},this._mergedOtherSourceCaches=Object.create(null),this._mergedSymbolSourceCaches=Object.create(null),this._mergedFillExtrusionSourceCaches=Object.create(null),this._mergedHdRoadCoverageSourceCaches=Object.create(null),this._hdCoverage=null,this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new ne,this._hasDataDrivenEmissive=!1,this.indoorManager=null,this.dispatcher=i.dispatcher?i.dispatcher:new si(os(),this),this.map.painter&&this.map.painter.context){const e=this.map.painter.context.maxUniformBufferBindings,t=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:e,maxUniformBlockSizeDwords:t,disableSymbolUBO:this.map.painter.context.disableSymbolUBO});}i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new Ze(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.U(t._requestManager,i.localFontFamily?e.ad.all:i.localIdeographFontFamily?e.ad.ideographs:e.ad.none,i.localFontFamily||i.localIdeographFontFamily,i.fontstackCompositing),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new Xs(t._requestManager),this.modelManager.setEventedParent(this)),this._layers=Object.create(null),this._sourceCaches={},this._otherSourceCaches=Object.create(null),this._symbolSourceCaches=Object.create(null),this._fillExtrusionSourceCaches=Object.create(null),this._hdCoverage=null,this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new Js:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.d4()),this.dispatcher.broadcast("setConfig",e.cJ());const o=this;this._rtlTextPluginCallback=ua.registerForPluginStateChange(t=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.fS(t),i&&i.every(e=>e))for(const e in o._sourceCaches){const t=o._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload();}});}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}});}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.dL(t))return t;const i=e.fw(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.et(JSON.stringify(t))}`}_diffStyle(t,i,o){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,o));}catch(e){t(e,!1);}};if("string"==typeof t){const o=this.map._requestManager.normalizeStyleURL(t),n=this.map._requestManager.transformRequest(o,e.aH.Style);e.cT(n,(t,o)=>{t?this.fire(new e.v(t)):o&&r(o,i);});}else "object"==typeof t&&r(t,i);}loadURL(t,i={}){this.fire(new e.x("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.dL(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,o);const n=this.map._requestManager.transformRequest(t,e.aH.Style);this._request=e.cT(n,(i,r)=>{if(this._request=null,i)this.fire(new e.v(i));else if(r)return this.importsCache.set(t,r),this._load(r,o)});}loadJSON(t,i={}){this.fire(new e.x("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.co.frame(()=>{this._request=null,this._load(t,!1!==i.validate);});}loadEmpty(){this.fire(new e.x("dataloading",{dataType:"style"})),this._load(ha,!1);}_loadImports(t,i,o){if(this.importDepth>=4)return e.f_("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const n of t){const t=this._createFragmentStyle(n),s=new Promise(e=>{t.once("style.import.load",e),t.once("error",e);}).then(()=>{this.mergeAll(),this.fire(new e.x("data",{dataType:"style"}));});if(r.push(s),this.resolvedImports.has(n.url)){t.loadEmpty();continue}const a=n.data||this.importsCache.get(n.url);a?(n.data?(t.fire(new e.x("dataloading",{dataType:"style"})),t.globalId=t._getGlobalId(a),queueMicrotask(()=>t._load(a,i))):t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):n.url?t.loadURL(n.url,{validate:i}):t.loadEmpty();const l={style:t,id:n.id,config:n.config};if(o){const e=this.fragments.findIndex(({id:e})=>e===o);this.fragments=this.fragments.slice(0,e).concat(l).concat(this.fragments.slice(e));}else this.fragments.push(l);}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return [...t.values()]}_createFragmentStyle(t){const i=this.scope?e.ea(t.id,this.scope):t.id;let o;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(o=Object.assign({},t.config,r));const n=new ua(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:o,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return n.setEventedParent(this.map,{style:n}),n}_reloadImports(e=!1){this.mergeAll(),this._updateMapProjection(),e||this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),(!e||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(e&&this.isRootStyle()?(this.forEachFragmentStyle(e=>{this.dispatcher.broadcast("setLayers",{layers:e._serializeLayers(e._order),scope:e.scope,options:e.options});}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}));}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},ha,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(e,i)}if(this.updateConfig(this._config,t.schema),i&&na(this,It(t)))return;this._loaded=!0;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});this.stylesheet=e.bL(t);const o=()=>{if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const o=ns(this.stylesheet.layers);if(this._order=o.map(e=>e.id),this.stylesheet.light&&e.f_("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new Vt(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Vt(this.stylesheet.light)),this._layers=Object.create(null);let r=!1;for(const t of o){const i=e.c0(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._updateHdCoverageSourceCache(i)&&(r=!0);const o=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&n&&(o.castsShadows=!0);}if(r&&rn().then(()=>{if(!this.map)return;for(const e in this._layers)this._updateHdCoverageSourceCache(this._layers[e]);this.map.style.mergeAll();const e=this.map.transform;for(const t in this.map.style._mergedHdRoadCoverageSourceCaches){const i=this.map.style._mergedHdRoadCoverageSourceCaches[t];i.used=!0,e&&i.update(e);}this.map._update();}),this.glyphManager.url){const e=new Set;for(const t in this._layers){const i=this._layers[t];if("symbol"===i.type&&i.layout){const t=i.layout.get("text-font");t&&t.value&&"constant"===t.value.kind&&e.add(t.value.value.join(","));}}for(const t of e)this.glyphManager.prefetchRange(t,0);}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(n,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.x("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(!0),this.fire(new e.x(s?"style.load":"style.import.load"));}).catch(t=>{this.fire(new e.v(new Error("Failed to load imports",t))),this.fire(new e.x(s?"style.load":"style.import.load"));}):(this._reloadImports(!0),this.fire(new e.x(s?"style.load":"style.import.load")));};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{o();}).catch(t=>{e.f_(`Couldn't load color theme from the stylesheet: ${t}`),o();});}else this._styleColorTheme.lut=null,o();}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(e=>e.style.hasAppearances())}mergeAll(){let e,t,i,o,r,n,s,a,l,c;const h={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(d.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),null!=d.light&&(e=d.light),d.stylesheet.lights)for(const e of d.stylesheet.lights)"ambient"===e.type&&null!=d.ambientLight&&(t=d.ambientLight),"directional"===e.type&&null!=d.directionalLight&&(i=d.directionalLight);o=this._prioritizeTerrain(o,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(r=d.fog),d.stylesheet.snow&&null!=d.snow&&(n=d.snow),d.stylesheet.rain&&null!=d.rain&&(s=d.rain),null!=d.stylesheet.camera&&(c=d.stylesheet.camera),null!=d.stylesheet.projection&&(a=d.stylesheet.projection),null!=d.stylesheet.transition&&(l=d.stylesheet.transition),h[d.scope]=d._styleColorTheme;}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=n,this.rain=s,this._styleColorThemeForScope=h,null===o?delete this.terrain:this.terrain=o,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},da,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain);}),null===e?delete this.terrain:this.terrain=e,this._programPrecompiler&&this._programPrecompiler.reset();}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);}),this.projection=e||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset();}mergeSources(){const t={},i=Object.create(null),o=Object.create(null),r=Object.create(null),n=Object.create(null);this.forEachFragmentStyle(s=>{for(const i in s._sourceCaches){const o=e.ea(i,s.scope);t[o]=s._sourceCaches[i];}for(const t in s._otherSourceCaches){const o=e.ea(t,s.scope);i[o]=s._otherSourceCaches[t];}for(const t in s._symbolSourceCaches){const i=e.ea(t,s.scope);o[i]=s._symbolSourceCaches[t];}for(const t in s._fillExtrusionSourceCaches){const i=e.ea(t,s.scope);r[i]=s._fillExtrusionSourceCaches[t];}if(s._hdCoverage){const t=s._hdCoverage.coverageSourceCaches;for(const i in t)n[e.ea(i,s.scope)]=t[i];}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o,this._mergedFillExtrusionSourceCaches=r,this._mergedHdRoadCoverageSourceCaches=n,Object.keys(n).length>0&&!this._hdCoverage&&on.HdCoverageState&&(this._hdCoverage=new on.HdCoverageState);}mergeIndoor(){this._mergedIndoor={},this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const o=i,r=e.ea(o.sourceId,t.scope);this._mergedIndoor[r]=new Set(o.sourceLayers||[]);}}),this._updateIndoorEnabled();}_updateIndoorEnabled(){const t=this._indoorEnabled;if(this._indoorEnabled=!1,Object.keys(this._mergedIndoor).length>0)for(const t of this._mergedOrder){const i=this._mergedLayers[t];if("none"!==i.visibility&&this._mergedIndoor[e.ea(i.source,i.scope)]){this._indoorEnabled=!0;break}}!this._indoorEnabled||t||this.indoorManager||rn().then(()=>{this._initIndoorManager();});}_initIndoorManager(){if(!this.indoorManager&&on.IndoorManager&&this.isRootStyle()&&0!==Object.keys(this._mergedIndoor).length&&(this.indoorManager=new on.IndoorManager(this,this._loaded),this._loaded))for(const e of Object.keys(this._mergedIndoor)){const t=this._mergedSourceCaches[e]||this._mergedOtherSourceCaches[e];t&&t.reload();}}mergeLayers(){const t={},i=[],o=Object.create(null);this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(o=>{for(const r of o._order){const n=o._layers[r];if("slot"===n.type){const i=e.cY(r);if(t[i])continue;t[i]=[];}n.slot&&t[n.slot]?t[n.slot].push(n):i.push(n);}}),this._mergedOrder=[];let r=-1;const n=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.cY(s.id);t[i]&&n(t[i]),this._mergedSlots.push(i);}else {const t=e.ea(s.id,s.scope);this._mergedOrder.push(t),o[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0);}};if(n(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i]);}this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const r=Object.assign({},i);for(const e of Object.keys(ea))void 0===r[e]&&(r[e]=ea[e].default);const n=new e.b2(ta,t,new Map(o));return n.setTransitionOrValue(r,o),n.untransitioned().possiblyEvaluate(new e.w(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((o,r)=>{const n="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void o();let s=t;s.startsWith(n)||(s=n+s);const a=e.a1.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void o();this._styleColorTheme.lutLoading=!1;const{width:n,height:s,data:c}=e.co.getImageData(l);if(s>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(n!==s*s)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.ay({width:n,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const h=this.imageManager.getImage(a,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},o()):r(new Error("Missing LUT image."));};})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(t){this._spriteRequest=function(t,i,o){let r,n,s;const a=e.co.devicePixelRatio>1?"@2x":"";let l=e.cT(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.aH.SpriteJSON),(e,t)=>{l=null,s||(s=e,r=t,h());}),c=e.cQ(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.aH.SpriteImage),(e,t)=>{c=null,s||(s=e,n=t,h());});function h(){if(s)o(s);else if(r&&n){const t=e.co.getImageData(n),i={};for(const o in r){const{width:n,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:d,stretchY:u,content:_}=r[o],f=new e.ay({width:n,height:s});e.ay.copy(t,f,{x:a,y:l},{x:0,y:0},{width:n,height:s},null),i[o]={data:f,pixelRatio:void 0!==h?h:1,sdf:void 0!==c&&c,stretchX:d,stretchY:u,content:_,usvg:!1,version:0};}o(null,i);}}return {cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null);}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.v(t));else if(i){const t=new Map;for(const o in i)t.set(e.a1.from(o),i[o]);this.addImages(t);}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.x("data",{dataType:"style"}));});}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const o=this.getOwnSourceCache(i.source);if(!o)return void this.fire(new e.v(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=o.getSource();if("raster-array"!==r.type)return void this.fire(new e.v(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const n=new ra(t,this.scope,o);this.imageManager.addImageProvider(n,this.scope);}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope);}_loadIconset(t){if(!e.dL(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var o,r;this._spriteRequest=(r=(o,r)=>{if(this._spriteRequest=null,o)i?this._loadSprite(t):this.fire(new e.v(o));else if(r){const t=new Map;for(const i in r)t.set(e.a1.from(i),r[i]);this.addImages(t);}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.x("data",{dataType:"style"}));},e.cG((o=this.map._requestManager).transformRequest(o.normalizeIconsetURL(t),e.aH.Iconset),(t,i)=>{if(t)return void r(t);const o={},n=function(e){const t={icons:[]};let i;for(;i=e.nextField(void 0);)1===i&&t.icons.push(ce(e,e.readVarint()+e.pos));return t}(new e.as(i));for(const t of n.icons){const i={version:1,pixelRatio:e.co.devicePixelRatio,content:ia(t),stretchX:t.metadata?oa(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?oa(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};o[t.name]=i;}r(null,o);}));}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&("geojson"===i.type||i.vectorLayerIds&&!i.vectorLayerIds.includes(o))&&this.fire(new e.v(new Error(`Source layer "${o}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(this.imageManager.hasPatternsInFlight())return !1;if(!this.modelManager.isLoaded())return !1;if(this._styleColorTheme.lutLoading)return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return !!this.snow&&this.snow.hasTransition()}hasRainTransition(){return !!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;if(this.hasSnowTransition())return !0;if(this.hasRainTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_updateDataDrivenEmissiveStrength(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];if(t._transitionablePaint&&t._transitionablePaint._values){const e=t._transitionablePaint._values["line-emissive-strength"];if(e&&e.value&&e.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1;}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.v(new Error(`The layer '${t}' does not exist in the map's style.`)));}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.v(new Error(`The source '${t}' does not exist in the map's style.`)));}handleIdle(){const e=this.map.painter;e&&(e.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(e,this));}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset();}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const o=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&(this._updateWorkerLayers(t,i,o),r=!0);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset();}const n={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];n[e]=t.used,t.used=!1,t.tileCoverLift=0;}const s={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if(("none"!==o.visibility||o.hasTransition())&&o.recalculate(t,this._availableImages),!o.isHidden(t.zoom)){o.mayUse("HD")&&(o.prepare(),rn()),o.mayUse("Standard")&&(o.prepare(),jn());const e=this.getLayerSourceCache(o);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,o.tileCoverLift()));}if(o.source){const t=e.ea(o.source,o.scope),i=this._mergedHdRoadCoverageSourceCaches[t];i&&!i.used&&(i.used=!0);}if("fill-extrusion"===o.type){const t=e.ea(o.source,o.scope);if(t in this._mergedFillExtrusionSourceCaches){const e=o.layout&&o.layout.get("source-max-zoom");if(null!=e){const i=s[t];s[t]=null==i?e:Math.min(i,e);}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){const e=this._mergedOrder.map(e=>this._mergedLayers[e]);this._programPrecompiler.buildQueue(e,t,this);}for(const e in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[e].setMaxzoomOverride(null!=s[e]?s[e]:null);this.terrain&&r&&this.mergeLayers();const a=this.imageManager.getPendingImageProviders();for(const e of a)e.sourceCache.used=!0;for(const t in n){const i=this._mergedSourceCaches[t];n[t]!==i.used&&i.getSource().fire(new e.x("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}));}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),o&&this.fire(new e.x("data",{dataType:"style"}));}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e);}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i]);}for(const t in e)this._changes.resetUpdatedImages(t);}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast("updateLayers",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(t,i){if(this._checkLoaded(),na(this,It(t)))return !1;(t=e.bL(t)).layers=ns(t.layers);const o=function(t,i){if(!t)return [{command:ss.setStyle,args:[i]}];let o=[];try{if(!e.c2(t.version,i.version))return [{command:ss.setStyle,args:[i]}];if(e.c2(t.center,i.center)||o.push({command:ss.setCenter,args:[i.center]}),e.c2(t.zoom,i.zoom)||o.push({command:ss.setZoom,args:[i.zoom]}),e.c2(t.bearing,i.bearing)||o.push({command:ss.setBearing,args:[i.bearing]}),e.c2(t.pitch,i.pitch)||o.push({command:ss.setPitch,args:[i.pitch]}),e.c2(t.sprite,i.sprite)||o.push({command:ss.setSprite,args:[i.sprite]}),e.c2(t.glyphs,i.glyphs)||o.push({command:ss.setGlyphs,args:[i.glyphs]}),e.c2(t.imports,i.imports)||function(t=[],i=[],o){i=i||[];const r=(t=t||[]).map(us),n=i.map(us),s=t.reduce(_s,{}),a=i.reduce(_s,{}),l=r.slice();let c,h,d,u;for(c=0,h=0;c{e.source&&r[e.source]?o.push({command:ss.removeLayer,args:[e.id]}):s.push(e);});let a=t.terrain;a&&r[a.source]&&(o.push({command:ss.setTerrain,args:[void 0]}),a=void 0),o=o.concat(n),e.c2(a,i.terrain)||o.push({command:ss.setTerrain,args:[i.terrain]}),function(t,i,o){i=i||[];const r=(t=t||[]).map(us),n=i.map(us),s=t.reduce(_s,{}),a=i.reduce(_s,{}),l=r.slice(),c=Object.create(null);let h,d,u,_,f,p,m;for(h=0,d=0;h!(e.command in la));if(0===o.length)return !1;const r=o.filter(e=>!(e.command in aa));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const n=[];return o.forEach(e=>{n.push(this[e.command](...e.args));}),i&&Promise.all(n).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages});}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels});}addImages(t){if(0===t.size)return this;for(const[i,o]of t.entries()){if(this.getImage(i))return this.fire(new e.v(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,o),this._changes.updateImage(i,this.scope);}return this._updateWorkerImages(),this.fire(new e.x("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.v(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.x("data",{dataType:"style"})),this)}updateImage(t,i,o=!1){this.imageManager.updateImage(t,this.scope,i),o&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.x("data",{dataType:"style"})));}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.x("data",{dataType:"style"})),this):this.fire(new e.v(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new e.x("data",{dataType:"style"})),this}addModel(t,i,o={}){return this._checkLoaded(),this._validate(Bt,`models.${t}`,i,null,o)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new e.x("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new e.x("data",{dataType:"style"})),this):this.fire(new e.v(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,o={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);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"].includes(i.type)&&this._validate(Ct,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=$n(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const n=t=>{const i=(t===e.aC.Symbol?"symbol:":t===e.aC.FillExtrusion?"fill-extrusion:":"other:")+r.id,o=e.ea(i,this.scope),n=this._sourceCaches[i]=new Vr(o,r,t);t===e.aC.Symbol?this._symbolSourceCaches[r.id]=n:t===e.aC.FillExtrusion?this._fillExtrusionSourceCaches[r.id]=n:this._otherSourceCaches[r.id]=n,n.onAdd(this.map);};n(e.aC.Other),"vector"!==i.type&&"geojson"!==i.type||(n(e.aC.Symbol),"vector"===i.type&&n(e.aC.FillExtrusion)),r.onAdd&&r.onAdd(this.map),o.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.v(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.v(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.v(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.cY(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.x("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this._hdCoverage&&delete this._hdCoverage.coverageSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty();}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(Dt,"lights",e))return;switch(e.type){case "ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new ai(e,ci(),this.scope,this.options);break;case "directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new ai(e,di(),this.scope,this.options);}}const o=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.w(this.z||0,o);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),n=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.bB(s.x,s.y,s.z)[2]/90,l=o(r)*n*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),h=i.properties.get("intensity"),d=o(c)*h;return Number(((l+d)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.dx(t)){const i=e.cS(t),o=this.fragments.find(({id:e})=>e===i);if(!o)return;const r=e.cY(t);return o.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const o in t){const r={},n=this._featuresetSelectors[o]=[];for(const s of t[o].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.f_(`Layer is undefined for selector: ${s.layer}`);continue}const n=i(t.source,t.sourceLayer);if(n in r&&r[n]!==s.featureNamespace){e.f_(`"featureNamespace ${s.featureNamespace} of featureset ${o}'s selector is not associated to the same source, skip this selector`);continue}r[n]=s.featureNamespace;}let t;if(s.properties)for(const i in s.properties){const o=e.bY(s.properties[i]);"success"===o.result&&(t=t||{},t[i]=o.value);}n.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._uniqueFeatureID});}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return [];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const o=this.getFragmentStyle(i),r=o.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.v(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const n=[];for(const e of r[t].selectors){const t=o.getOwnLayer(e.layer);t&&n.push(t);}return n}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const r=e.ea(i,o.scope),n=o.options.get(r),s=n?n.value||n.default:null;return s?s.serialize():null}isIndoorEnabled(){return this._indoorEnabled}getIndoorSourceLayers(t,i){const o=e.ea(t,i);return this._mergedIndoor[o]}setIndoorData(e,t){this.indoorManager&&this.indoorManager.setIndoorData(t);}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint();}setConfigProperty(t,i,o){const r=this.getFragmentStyle(t);if(!r)return;const n=r.stylesheet.schema;if(!n||!n[i])return;const s=sa(n[i],o);if("success"!==s.result)return void na(this,s.value);const a=s.value.expression,l=e.ea(i,r.scope),c=r.options.get(l);if(!c)return;let h;const{minValue:d,maxValue:u,stepValue:_,type:f,values:p}=n[i],m=sa(n[i],n[i].default);"success"===m.result&&(h=m.value.expression),h?(this.options.set(l,Object.assign({},c,{value:a,default:h,minValue:d,maxValue:u,stepValue:_,type:f,values:p})),this.updateConfigDependencies(i)):this.fire(new e.v(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)));}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const o=i.stylesheet.schema;if(!o)return null;const r={};for(const t in o){const o=e.ea(t,i.scope),n=i.options.get(o),s=n?n.value||n.default:null;r[t]=s?s.serialize():null;}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies());}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies());}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const o in i){let r,n;const s=sa(i[o],i[o].default);if("success"===s.result&&(r=s.value.expression),t&&void 0!==t[o]){const e=sa(i[o],t[o]);"success"===e.result&&(n=e.value.expression);}const{minValue:a,maxValue:l,stepValue:c,type:h,values:d}=i[o];if(r){const t=e.ea(o,this.scope);this.options.set(t,{default:r,value:n,minValue:a,maxValue:l,stepValue:c,type:h,values:d});}else this.fire(new e.v(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.v(new Error("Attempting to set config for a style without schema.")));}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty());}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t);}}),this._updateIndoorEnabled(),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.v(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===t.type){if(na(this,e.fY(t)))return;n=e.c0(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.bL(t),t=Object.assign(t,{source:r})),this._validate(Mt,`layers.${r}`,t,{arrayIndex:-1},o))return;n=e.c0(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}});}const s=e.ea(n.source,n.scope);0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.v(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot&&n.slot!==this._layers[i].slot?e.f_(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):a=t;}this._order.splice(a,0,r),this._handleLayerOrderChange(),this._layers[r]=n;const l=this.getOwnLayerSourceCache(n),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&n.canCastShadows()&&c&&(l.castsShadows=!0);const h=this._changes.getRemovedLayer(n);if(h&&n.source&&l&&"custom"!==n.type){this._changes.discardLayerRemoval(n);const t=e.ea(n.source,n.scope);h.type!==n.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause());}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let n=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.v(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot&&o.slot!==this._layers[i].slot?e.f_(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):n=t;}this._order.splice(n,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(t,i,o={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.c2(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Ft,`layers.${r.id}.filter`,i,{layerType:r.type},o)||(r.filter=e.bL(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.bL(i.filter)}setLayoutProperty(t,i,o,r={}){this._checkLoaded();const n=this._checkLayer(t);if(n&&!e.c2(n.getLayoutProperty(i),o)){if(null!=o&&(!r||!1!==r.validate)&&na(n,kt.call(It,{key:`layers.${t}.layout.${i}`,layerType:n.type,objectKey:i,value:o,styleSpec:e.fs,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(i,o),0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(n.fqid),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(n.fqid),this._updateLayer(n);}}getLayerProperty(e,t){const i=this._checkLayer(e);if(i){switch(t){case "minzoom":return i.minzoom;case "maxzoom":return i.maxzoom;case "filter":return this.getFilter(e);case "slot":return i.slot;case "appearances":return i.getAppearances().map(e=>e.serialize())}return i.isPaintProperty(t)?this.getPaintProperty(e,t):this.getLayoutProperty(e,t)}}setLayerProperty(e,t,i,o={}){this._checkLoaded();const r=this._checkLayer(e);if(r){switch(t){case "appearances":return r.setAppearances(i),void this._updateLayer(r);case "minzoom":return this.setLayerZoomRange(e,i);case "maxzoom":return this.setLayerZoomRange(e,null,i);case "filter":return this.setFilter(e,i,o);case "slot":return this.setSlot(e,i)}r.isPaintProperty(t)?this.setPaintProperty(e,t,i,o):this.setLayoutProperty(e,t,i,o);}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,o,r={}){this._checkLoaded();const n=this._checkLayer(t);if(!n)return;if(e.c2(n.getPaintProperty(i),o))return;if(null!=o&&(!r||!1!==r.validate)&&na(n,zt.call(It,{key:`layers.${t}.paint.${i}`,layerType:n.type,objectKey:i,value:o,styleSpec:e.fs})))return;const s=n.setPaintProperty(i,o);0!==n.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(n.fqid),n.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(n.fqid),s&&this._updateLayer(n),this._changes.updatePaintProperties(n);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,r=this.getFragmentStyle(o),n=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of n)r.setFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);this.setFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,r=t.sourceLayer,n=this._checkSource(o);if(!n)return;const s=n.type;if("geojson"===s&&r)return void this.fire(new e.v(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.v(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.v(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,r=this.getFragmentStyle(o),n=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of n)r.removeFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);this.removeFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,r=this._checkSource(o);if(!r)return;const n=r.type,s="vector"===n?t.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new e.v(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.v(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.removeFeatureState(s,t.id,i);}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:o,importId:r}=t.target,n=this.getFragmentStyle(r),s=n.getFeaturesetLayers(o);for(const{source:o,sourceLayer:r}of s){const s=n.getFeatureState({id:t.id,source:o,sourceLayer:r});if(s&&!i)i=s;else if(!e.c2(i,s))return void this.fire(new e.v(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);i=this.getFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer});}return i}const i=t.source,o=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||o)return void 0===t.id&&this.fire(new e.v(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.v(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(e){e!==this._worldview&&(this._worldview=e,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources());}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.cr({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],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:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t);}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.ea(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[o]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(o,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,o={},r=[];for(let n=i.length-1;n>=0;n--){const s=i[n];if(t(s)){o[s]=n;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t);}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const n=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&o[t.layer.id]{if(ca.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=n[t.id]=n[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r});};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.v(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.v(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i);}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,n,o),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.cZ(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,o){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Ft,"queryRenderedFeatures.filter",i.filter,null,i),r=e.bZ(i.filter));const n="mock",s=[];if(i&&i.target)s.push(Object.assign({},i,{targetId:n,filter:r}));else {const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:n,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:n,filter:r,target:e});}}const a=this.queryRenderedTargets(t,s,o),l=[],c=new Set;for(const t of a)for(const i of t.variants[n])Yn(i,t,c)||l.push(new e.aZ(t,i));return l}queryRenderedTargets(t,i,o){const r={},n=(e,t,i,o)=>{const n=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(n.layers[e.fqid]=n.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(n.has3DLayers=!0),!o)return i.uniqueFeatureID=!1,void n.layers[e.fqid].targets.push(i);n.layers[e.fqid].targets.push(Object.assign({},i,{namespace:o.namespace,properties:o.properties,uniqueFeatureID:o.uniqueFeatureID}));};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:o}=t.target,r=this.getFragmentStyle(o);if(!r||!r._featuresetSelectors)continue;const s=r._featuresetSelectors[i];if(!s){this.fire(new e.v(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=r.getOwnLayer(e.layerId);i&&!ca.has(i.type)&&n(i,r.getOwnLayerSourceCache(i),t,e);}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||ca.has(i.type))continue;n(i,this.getLayerSourceCache(i),t);}const s=this._queryRenderedFeatures(t,r,o);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(t,i,o){const r=[],n=!!this.map._showQueryGeometry,s=Gn.createFromScreenPoints(t,o);for(const e in i){const t=Kn(s,i[e],this._availableImages,o,n,this.getActualScope());Object.keys(t).length&&r.push(t);}if(this.placement)for(const t in i){if(i[t].sourceCache._renderSourceType!==e.aC.Symbol)continue;const o=Qn(s.screenGeometry,i[t],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(o).length&&r.push(o);}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Ft,"querySourceFeatures.filter",i,null,t);let o=[];const r=this.getOwnSourceCaches(e);for(const e of r)o=o.concat(Jn(e,t));return o}addSourceType(e,t,i){return ua.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(ua.setSourceType(e,t),i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,o={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e.c2(t[i],r[i])){n=!0;break}if(!n)return;const s=this._getTransitionParameters();this.light.setLight(t,i,o),this.light.updateTransitions(s);}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.co.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.f_("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."));}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let o=t;const r=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in o&&"object"==typeof o.source){const t="terrain-dem-src";this.addSource(t,o.source),o=e.bL(o),o=Object.assign(o,{source:t});}const t=Object.assign({},o),i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(At,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!o)return;this._createTerrain(o,i),this.fire(new e.x("data",{dataType:"style"}));}else {const i=this.terrain,r=i.get();for(const t of Object.keys(e.fs.terrain))!Object.hasOwn(o,t)&&e.fs.terrain[t].default&&(o[t]=e.fs.terrain[t].default);for(const o in t)if(!e.c2(t[o],r[o])){i.set(t,this.options),this.stylesheet.terrain=t;const o=this._getTransitionParameters({duration:0});i.updateTransitions(o),this.fire(new e.x("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new Kt(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createSnow(e){const t=this.snow=new ei(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createRain(e){const t=this.rain=new ti(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity();});}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){const i=this.fog;if(!e.c2(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset();}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.c2(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createSnow(t);this._markersNeedUpdate=!0;}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.c2(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createRain(t);this._markersNeedUpdate=!0;}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const o=this._evaluateColorThemeData(i);this._loadColorTheme(o).then(()=>{this.fire(new e.x("colorthemeset")),t();}).catch(t=>{e.f_(`Couldn't set color theme: ${t}`);});}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.f_("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme();}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme());}_getTransitionParameters(t){return {now:e.co.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new Wt(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(t,i,o,r,n={}){if(n&&!1===n.validate)return !1;const s=Object.assign({},this.serialize());return na(this,t.call(It,Object.assign({key:i,style:s,value:o,styleSpec:e.fs},r)))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.ck.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];t.clearTiles(),t.setEventedParent(null);const i=t.getSource();i&&i.onRemove&&i.onRemove(this.map);}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager&&this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear();}}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope);});}updateSources(e){let t;this.directionalLight&&(t=ho(this.directionalLight));const i=new Set,o=new Set,r=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type?i.add(t.source):"raster"===t.type&&t.paint&&"ground"===t.paint.get("raster-elevation-reference")&&r.add(t.source),t.hasElevation()&&!o.has(t.source)&&o.add(t.source);}this.updateFrcCoverageFadeRange();for(const n in this._mergedSourceCaches){const s=this._mergedSourceCaches[n],a=o.has(s._source.id);s._isRasterElevatedOverTerrain=r.has(s._source.id),i.has(s._source.id)&&(s._source.reparseOverscaled=!1),s.update(e,void 0,void 0,t,a);}this.updateFrcCoverage();}_reloadSources(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}updateFrcCoverageFadeRange(){this.map.painter&&on.updateFrcCoverageFadeRange&&on.updateFrcCoverageFadeRange(this,this.map.painter);}updateFrcCoverage(){this._hdCoverage&&on.updateFrcCoverage&&on.updateFrcCoverage(this,this._hdCoverage);}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new e.x("neworder"));}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Vs),this.pauseablePlacement.requestFullPlacement();}_setLabelPlacementStale(){this.placement&&this.placement.setStale();}_updatePlacement(t,i,o,r,n,s){this.pauseablePlacement||(this.pauseablePlacement=new Vs);let a=!1,l=!1;const c={},h={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if("symbol"!==o.type)continue;const r=e.ea(o.source,o.scope);let n=c[r];if(!n){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[r]=t.slice(),n=c[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1));}const s=this.crossTileSymbolIndex.addLayer(o,n,t.center.lng,t.projection);a=a||s;}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const d=Boolean(this.placement&&!t.equals(this.placement.transform)),u=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!n||this.placement.lastReplacementSourceUpdateTime!==n.updateTime)),_=d||u||a,f=(_||this.pauseablePlacement.isStale())&&0===o,p=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.co.now(),t.zoom)&&0!==o;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||f||p)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,o,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex,s),this.map.painter)){const e=this.map.painter.maxFrontCutoffRawStart;if(e>0){const i=180*t.pitch/Math.PI;if(i>=15){const t=Math.min(1,Math.max(0,(i-15)/5)),o=t*t*(3-2*t);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-o)+e*o;}}}if(this.pauseablePlacement.isDone()?_&&0!==o&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,c,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.co.now()),l=!0),a&&this.pauseablePlacement.setStale()),l||a){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;te===t.id))return void this.fire(new e.v(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0);const r=o.findIndex(({id:e})=>e===i);return -1===r&&this.fire(new e.v(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=o.slice(0,r).concat(t).concat(o.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const o=this.stylesheet.imports||[],r=this.getImportIndex(t);return -1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==o[r].url&&this.setImportUrl(t,i.url),e.c2(i.config,o[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.c2(i.data,o[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const r=this.getImportIndex(t);if(-1===r)return this;const n=i[o],s=this.fragments[o];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(n).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(s).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const r=this.fragments[o];return r.style=this._createFragmentStyle(i[o]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t,i){this._checkLoaded();const o=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===o)return this;t?r[o].config=t:delete r[o].config;const n=this.fragments[o];i&&n.style.stylesheet&&(n.style.stylesheet.schema=i);const s=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports());}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return -1===i&&this.fire(new e.v(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const o=e.ea(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.ea(t.source,t.scope);return "symbol"===t.type?this._mergedSymbolSourceCaches[i]:"fill-extrusion"===t.type?this._mergedFillExtrusionSourceCaches[i]||this._mergedOtherSourceCaches[i]:"fill"===t.type&&t.sourceLayer===e.X&&this._mergedHdRoadCoverageSourceCaches[i]?this._mergedHdRoadCoverageSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),this._mergedFillExtrusionSourceCaches[e]&&t.push(this._mergedFillExtrusionSourceCaches[e]),this._mergedHdRoadCoverageSourceCaches[e]&&t.push(this._mergedHdRoadCoverageSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e);}getImages(t,i,o){this.imageManager.getImages(i.icons.concat(i.patterns),i.scope,o),this._updateTilesForChangedImages();const r=i.icons.map(t=>e.a1.toString(t)),n=i.patterns.map(t=>e.a1.toString(t)),s=e=>{e&&(e.setDependencies(i.tileID.key,"icons",r),e.setDependencies(i.tileID.key,"patterns",n));},a=e.ea(i.source,i.scope);s(this._mergedOtherSourceCaches[a]),s(this._mergedSymbolSourceCaches[a]),(i.icons.some(e=>e.iconsetId)||i.patterns.some(e=>e.iconsetId))&&this.fire(new e.x("data",{dataType:"style"}));}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i);}checkAtlasCache(e,t,i){const o=this.imageManager.imageAtlasCache.findCachedAtlas(t.descriptor);i(null,o&&o.contentDescriptor?{iconPositions:o.iconPositions,patternPositions:o.patternPositions,sourceHash:o.contentDescriptor.hash}:null);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i);}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:"fill-extrusion"===e.type&&this._fillExtrusionSourceCaches[e.source]||this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),this._fillExtrusionSourceCaches[e]&&t.push(this._fillExtrusionSourceCaches[e]),this._hdCoverage&&this._hdCoverage.coverageSourceCaches[e]&&t.push(this._hdCoverage.coverageSourceCaches[e]),t}_updateHdCoverageSourceCache(t){return on.HdCoverageState&&on.updateHdCoverageSourceCache?(this._hdCoverage||(this._hdCoverage=new on.HdCoverageState),on.updateHdCoverageSourceCache(this,this._hdCoverage,t),!1):"fill"===t.type&&t.sourceLayer===e.X}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.v(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return !1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),o="building"===e.type;if(e.is3D(!!this.terrain)){if(i||o||t&&"batched-model"===t.type)return !0;if("model"===e.type)return !0}else if("symbol"===e.type)return !0;return !1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(e=>{e.style._remove();}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}ua.getSourceType=function(e){return qn[e]},ua.setSourceType=function(e,t){qn[e]=t;},ua.registerForPluginStateChange=e.e_;class _a{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,r,n,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e{const n=o.paint.get("hillshade-shadow-color"),s="none"===o.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=o.paint.get("hillshade-highlight-color"),l="none"===o.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=o.paint.get("hillshade-accent-color"),h="none"===o.paint.get("hillshade-accent-color-use-theme").constantOr("default"),d=o.paint.get("hillshade-emissive-strength");let u=e.c4(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))u-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.bB(i.x,i.y,i.z);u=e.c4(o[1]);}const _=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),_),u_image:0,u_latrange:fa(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),u],u_shadow:n.toPremultipliedRenderColor(s?null:o.lut),u_highlight:a.toPremultipliedRenderColor(l?null:o.lut),u_emissive_strength:d,u_accent:c.toPremultipliedRenderColor(h?null:o.lut)}})(t,o,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,_,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(o);_.draw(t,c.TRIANGLES,n,s,a,gi.disabled,f,r.id,p,m,g);}function ma(t,i,o){if(!i.needsDEMTextureUpload)return;const r=t.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const s=o.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.a_(r,s,n.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function ga(t,i,o){const r=t.context,n=r.gl;if(!i.dem)return;const s=i.dem;if(r.activeTexture.set(n.TEXTURE1),ma(t,i,s),!i.demTexture)return;i.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);const a=s.dim;r.activeTexture.set(n.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.a_(r,{width:a,height:a,data:null},n.RGBA8);t.bind(n.LINEAR,n.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,1,"renderbuffer"),l.colorAttachment0.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers(),u=[];t.linearFloatFilteringSupported()&&u.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&u.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:u}).draw(t,n.TRIANGLES,vi.disabled,Wi.disabled,$i.unblended,gi.disabled,((t,i)=>{const o=i.stride,r=e.bT();return e.eB(r,0,e.r,-e.r,0,0,1),e.fQ(r,r,[0,-e.r,0]),{u_matrix:r,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,s),o.id,c,h,d),i.needsHillshadePrepare=!1;}class va{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class ya extends va{getDefault(){return e.i.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class xa extends va{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class ba extends va{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class wa extends va{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Ta extends va{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Ea extends va{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Sa extends va{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class Ia extends va{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class Ca extends va{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class Ra extends va{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class Da extends va{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class Aa extends va{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class La extends va{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class Oa extends va{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Pa extends va{getDefault(){return e.i.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Ma extends va{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class Fa extends va{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class za extends va{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class ka extends va{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let Ba=class extends va{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class Na extends va{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class Ua extends va{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class ja extends va{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class Ga extends va{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class Va extends va{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class Ha extends va{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Wa extends va{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Za extends va{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class qa extends va{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class $a extends va{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class Xa extends va{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class Ya extends va{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class Ka extends Ya{constructor(e,t,i=0){super(e,t),this.attachmentPoint=e.gl.COLOR_ATTACHMENT0+i;}setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachmentPoint,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class Qa extends Ya{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class Ja extends Ya{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class el extends Qa{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const tl=(e,t,i,o)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:o}),il=(e,t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:n,u_image0:0,u_image1:1,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:d,u_viewport:u,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:_,u_far_z_cutoff:f,u_emissive_texture_available:p});function ol(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const rl=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:o,phase:0,duration:r,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}};function nl(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function sl(e,t){const i=1<{if(i[o.key]="",!this._tiles[o.key]){const i=new e.b0(o,this._source.tileSize*o.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);i.state="loaded",this._tiles[o.key]=i;}return i},{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class hl extends e.ap{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class dl extends e.s{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,r,n]=function(){const t=new e.aQ,i=new e.aT,o=131;t.reserve(17161),i.reserve(33800);const r=e.r/128,n=e.r+r/2,s=n+r;for(let i=-r;in||i<0||i>n?24575:0,s=e.bG(Math.round(o),0,e.r),a=e.bG(Math.round(i),0,e.r);t.emplaceBack(s+r,a);}const a=(e,t)=>{const r=t*o+e;i.emplaceBack(r+1,r,r+o),i.emplaceBack(r+o,r+o+1,r+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);}),[t,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(o,e.eQ.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.aJ.simpleSegment(0,0,o.length,r.length),this.gridNoSkirtSegments=e.aJ.simpleSegment(0,0,o.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new cl(i.map),this.orthoMatrix=e.bT(),e.eB(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.r,0,e.r,0,1);const a=s.gl;this._overlapStencilMode=new Wi({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new ll(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null;}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache();});}update(t,i,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,n=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.co.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=n?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.f_(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.f_(`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 t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const r=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const n=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(n);let a=n-this._previousZoom;const l=this._previousUpdateTimestamp;let c=n;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(n-c)>.5&&(a=.5*(n-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const h=s.getExaggeration(c),d=h===s.getExaggeration(Math.max(0,c-.1));if(d&&Math.abs(h-this._exaggeration)<.01)return h;let u=Math.min(.1,.00375*(this._updateTimestamp-l));return (d||h<.1||Math.abs(a)<1e-4)&&(u=Math.min(.2,4*u)),e.dY(this._exaggeration,h,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.ag.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.au(o.x,o.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.au(t.canonical.x+(1<{this.proxyToSource[e.key]={};}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],n),i.usedForTerrain)continue;const o=t[e];(i.getSource().reparseOverscaled||i._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=r.map(e=>new hl(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);});}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const o=this.terrainTileForTile[i],r=o.dem;!r||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),ma(this.painter,o,r));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,n=Math.pow(2,t.tileID.canonical.z-r.z),s=o||"";return i[`u_dem_tl${s}`]=[r.x*n%1,r.y*n%1],i[`u_dem_scale${s}`]=n,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const o=i.dem.tree.minimums[0];return o>0&&e++,t+o},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),r=new e.L({width:1,height:1},new Float32Array([o]));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new e.a_(t,r,i.R32F,{premultiply:!1}),n}setupElevationDraw(t,i,o){const r=this.painter.context,n=r.gl,s={u_dem:2,u_dem_prev:4,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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?n.LINEAR:n.NEAREST;let d=null;var u;if(this.enabled?l&&a?(d=a.demTexture,r.activeTexture.set(n.TEXTURE4),l.demTexture.bind(h(l),n.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],d=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):d=this.emptyDEMTexture,r.activeTexture.set(n.TEXTURE2),d&&(s.u_dem_size=1===(u=d).size[0]?1:u.size[0]-2,d.bind(h(a),n.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(o&&o.useDepthForOcclusion,i,s),o&&o.useMeterToDem&&a){const t=(1<{if(c===i)return;const o=[];1===i&&o.push("TERRAIN_VERTEX_MORPHING"),o.push("PROJECTION_GLOBE_VIEW"),d&&o.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:r}),c=i;},_=t.colorModeForRenderPass(),f=new vi(a.LEQUAL,vi.ReadWrite,t.depthRangeFor3D);rl.update(n);const p=e.by(h),m=[e.ek(h.center.lng),e.el(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.co.devicePixelRatio,h.height*e.co.devicePixelRatio],y=Float32Array.from(h.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const h=t.transform,d=nl(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of r){const r=o.getTile(c),w=Wi.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];ol(T,E)&&rl.newMorphing(c.key,T,E,n,250),al(t,r.emissiveTexture),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=rl.getMorphValuesForProxy(c.key),I=S?1:0;S&&Object.assign(x,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.cb(S.phase)}});const C=e.fF(c.canonical),R=e.cU(C.getCenter().lat),D=e.cP(c.canonical,C,R,h.worldSize/h._pixelsPerMercatorPixel),A=e.dh(e.dk(c.canonical)),L="mrt-fallback"===t.emissiveMode?1:0,O=il(h.expandedFarZProjMatrix,y,p,A,e.dm(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,d,h._farZ,L,D);if(u(c,I),l&&(i.setupElevationDraw(r,l,x),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(R,0!==d);l.draw(t,b,f,w,_,gi.backCCW,O,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&n.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:n});for(const n of r){const{x:r,y:c,z:d}=n.canonical,u=0===c,p=c===(1<e.draw(t,a.TRIANGLES,f,Wi.disabled,_,gi.disabled,il(h.expandedFarZProjMatrix,g,g,E,0,m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ,S),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,x),t.uploadCommonUniforms(s,l,n.toUnwrapped()),u&&t.renderDefaultNorthPole&&I(l,y),p&&t.renderDefaultSouthPole&&(g=e.fc(e.bT(),g,[1,-1,1]),I(l,b));}}}}(t,i,o,r,n);else {const s=t.context,a=s.gl;let l,c;const h=t.shadowRenderer,d=Vi(t,t.longestCutoffRange),u=e=>{if(c===e)return;const i=[];1===e&&i.push("TERRAIN_VERTEX_MORPHING"),d.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),h&&(i.push("RENDER_SHADOWS"),h.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},_=t.colorModeForRenderPass(),f=new vi(a.LEQUAL,vi.ReadWrite,t.depthRangeFor3D);rl.update(n);const p=t.transform,m=nl(p.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=uo(t.style,e,i));}{c=-1;const v=a.TRIANGLES,[y,x]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=o.getTile(c),b=Wi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];ol(w,T)&&rl.newMorphing(c.key,w,T,n,250),al(t,r.emissiveTexture),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=rl.getMorphValuesForProxy(c.key),S=E?1:0;let I;E&&(I={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.cb(E.phase)}});const C="mrt-fallback"===t.emissiveMode?1:0,R=tl(c.projMatrix,sl(c.canonical,p.renderWorldCopies)?m/10:m,g,C);if(u(S),!l)continue;i.setupElevationDraw(r,l,I);const D=c.toUnwrapped();h&&h.setupShadows(D,l),t.uploadCommonUniforms(s,l,D,null,d),l.draw(t,v,f,b,_,gi.backCCW,R,"terrain_raster",i.gridBuffer,y,x);}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length));}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,o=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let c=0;for(const h of n){const n=r.getTileByID(h.proxyTileKey),d=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,u=void 0!==d?r.renderCache[d]:this.pool[c++],_=void 0!==d;if(n.texture=u.tex,n.emissiveTexture=u.emissiveTex,_&&!u.dirty){l.push(n.tileID);continue}o.bindFramebuffer.set(u.fb.framebuffer);const f=o.gl;let p;f.drawBuffers("mrt-fallback"===i.emissiveMode?[f.COLOR_ATTACHMENT0,f.COLOR_ATTACHMENT1]:[f.COLOR_ATTACHMENT0]),this.renderedToTile=!1,u.dirty&&(o.clear({color:e.i.transparent,stencil:0}),u.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),n=r?this.proxyToSource[h.key][r.id]:[h];if(!n)continue;const s=n;o.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(u,n,t,r),p=r?r.id:null),i.renderLayer(i,r,t,s);}if(f.drawBuffers([f.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),n=r?this.proxyToSource[h.key][r.id]:[h];if(!n)continue;const s=n;o.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(u,n,t,r),p=r?r.id:null),i.renderLayer(i,r,t,s);}this.renderedToTile?(u.dirty=!0,l.push(n.tileID)):_||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=t;for(let r=0;ri}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0]);}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter(e=>e.dem).map(o=>{const r=o.tileID,n=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of o){if(null==r.t)return null;const o=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.a_(t,{width:o[0],height:o[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const n=t.createFramebuffer(o[0],o[1],1,null);let s;return n.colorAttachment0.set(r.texture),this._emissiveTexture&&(s=new e.a_(t,{width:o[0],height:o[1],data:null},i.R8),s.bind(i.LINEAR,i.CLAMP_TO_EDGE),n.createColorAttachment(t,1),n.colorAttachment1.set(s.texture)),n.depthAttachment=new el(t,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:n,tex:r,emissiveTex:s,dirty:!1}}_updateFBOs(e){if(this._emissiveTexture!==e){for(const t of this.pool)this._updateFBO(t,e);for(const t of this.proxySourceCache.renderCache)this._updateFBO(t,e);this._emissiveTexture=e;}}_updateFBO(t,i){const o=t.fb,r=this.painter.context,n=r.gl,s=this.drapeBufferSize;if(i){const i=new e.a_(r,{width:s[0],height:s[1],data:null},n.R8);i.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.emissiveTex=i,o.createColorAttachment(r,1),o.colorAttachment1.set(i.texture);}else t.emissiveTex=void 0,o.removeColorAttachment(r,1);t.dirty=!0;}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof Zn){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end)||e.f_("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=o;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;r--){const n=i[r];if(t.getTileByID(n.key),void 0!==t.proxyCachedFBO[n.key]){const i=e[n.key],r=this.proxyToSource[n.key];let s=0;for(const e in r){const t=r[e],n=i[e];if(!n||n.length!==t.length||t.some((t,i)=>t!==n[i]||o[e]&&Object.hasOwn(o[e],t.key))){s=-1;break}++s;}for(const e in t.proxyCachedFBO[n.key])t.renderCache[t.proxyCachedFBO[n.key][e]].dirty=s<0||s!==Object.values(i).length;}}const r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const o of i){if(t.proxyCachedFBO[o.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,n=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:n.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t.at(-1).overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:n.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+s>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,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):Wi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,r=o.gl;i._tileClippingMaskIDs={},o.setColorMode($i.disabled),o.setDepthMode(vi.disabled);const n=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;n.draw(i,r.TRIANGLES,vi.disabled,new Wi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),$i.disabled,gi.disabled,Zr(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const o=[t.x,t.y,1,1];e.fM(o,o,i.pixelMatrixInverse),e.fb(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const r=i._camera.position,n=e.em(1,i.center.lat),s=[r[0],r[1],r[2]/n,0],a=e.fz([],o.slice(0,3),s);e.ex(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.fe(s,s,a,l),s[3]=s[2],s[2]*=n,s):null}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.a3)return this._setupProxiedCoordsForImageSource(t,i,o);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ);}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.au(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.au(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.au(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<s+c.max.x||r+na+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let n,s,a;r=e.bT();const l=i.tileID.wrap-t.wrap<0?(n=e.r>>o,s=n*((i.tileID.canonical.x<=r){const o=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.ap(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(a=r,s=new e.ap(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o));}s.key!==t.key&&(c.push(s.key),o=i.getTile(s));}const h=e=>{c.forEach(t=>{r[t]=e;}),c.length=0;};for(a-=1;a>=l&&(!o||!o.hasData());a--){o&&h(o.tileID.key);const e=s.calculateScaledKey(a);if(o=i.getTileByID(e),o&&o.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function ul(t,i,o){const r=function(t,i,o){const r=e.c7(i,t),n=e.c7(o,[.2126,.7152,.0722]),s=1-.3*Math.min(n,1),a=e.dY(s,1,Math.min(r+1,1));return e.dY(.92,1,Math.asin(e.bG(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),n=[0,0,0];e.fa(n,o.slice(0,3),r);const s=[0,0,0];e.fa(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.bj(a,n,s),e.e4(a)}const _l=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],fl=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class pl{static cacheKey(e,t,i,o){const r=[t];o&&r.push(o.cacheKey);for(const t of i)("string"==typeof t&&t.includes(" ")||e.usedDefines.has(t))&&r.push(t);return r.join("/")}constructor(e,t,i,o,r,n,s=!1){const a=e.gl;this.program=a.createProgram(),this._context=e,this._fixedUniformsFn=r,this._pending=!0,this._precompiled=s,this.attributes={},this.configuration=o,this.name=t,this.fixedDefines=[...n],s?e._compileStats.precompiled++:e._compileStats.onDemand++;const l=`#version 300 es\n${(o?o.defines():[]).concat(n.map(e=>`#define ${e}`)).join("\n")}`,c=[l,pr];for(const e of i.fragmentIncludes)c.push(cr[e]);c.push(i.fragmentSource);const h=c.join("\n"),d=[l,mr];for(const e of i.vertexIncludes)d.push(cr[e]);this.forceManualRenderingForInstanceIDShaders=e.forceManualRenderingForInstanceIDShaders&&i.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&d.push("uniform int u_instanceID;"),d.push(i.vertexSource);let u=d.join("\n");this.forceManualRenderingForInstanceIDShaders&&(u=u.replaceAll("gl_InstanceID","u_instanceID"));const _=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);a.shaderSource(_,h),a.compileShader(_),a.attachShader(this.program,_);const f=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);a.shaderSource(f,u),a.compileShader(f),a.attachShader(this.program,f),a.linkProgram(this.program),this._fragmentShader=_,this._vertexShader=f,e.extParallelShaderCompile?e._pendingPrograms.add(this):this._finalize();}_finalize(){if(!this._pending)return;this._pending=!1;const t=this._context,i=t.gl;t._pendingPrograms.delete(this);const o=e.co.now(),r=i.getProgramParameter(this.program,i.LINK_STATUS),n=e.co.now()-o,s=t._compileStats;if(s.totalStallMs+=n,n>s.maxStallMs&&(s.maxStallMs=n),n>1){s.framesMissed+=Math.floor(60*n/1e3);const e=this.fixedDefines.join(",");s.stalls.push({name:`${this.name}${e?"/":""}${e}`,ms:n,timestamp:o});}if(this._fragmentShader&&(r||e.f_(`Fragment shader '${this.name}': ${i.getShaderInfoLog(this._fragmentShader)}`),i.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(r||e.f_(`Vertex shader '${this.name}': ${i.getShaderInfoLog(this._vertexShader)}`),i.deleteShader(this._vertexShader),this._vertexShader=null),!r)return e.f_(`Failed to link program '${this.name}': ${i.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.b5(t)}))(t));const a=this.fixedDefines,l=this.name;(a.includes("TERRAIN")||a.includes("ELEVATED")||l.includes("symbol")||l.includes("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.b5(t),u_dem_prev:new e.b5(t),u_dem_tl:new e.b6(t),u_dem_scale:new e.b4(t),u_dem_tl_prev:new e.b6(t),u_dem_scale_prev:new e.b4(t),u_dem_size:new e.b4(t),u_dem_lerp:new e.b4(t),u_exaggeration:new e.b4(t),u_depth:new e.b5(t),u_depth_size_inv:new e.b6(t),u_depth_range_unpack:new e.b6(t),u_occluder_half_size:new e.b4(t),u_occlusion_depth_offset:new e.b4(t),u_meter_to_dem:new e.b4(t),u_label_plane_matrix_inv:new e.bb(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.b7(t),u_tile_tr_up:new e.b7(t),u_tile_br_up:new e.b7(t),u_tile_bl_up:new e.b7(t),u_tile_up_scale:new e.b4(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bb(t),u_fog_range:new e.b6(t),u_fog_color:new e.b8(t),u_fog_horizon_blend:new e.b4(t),u_fog_vertical_limit:new e.b6(t),u_fog_temporal_offset:new e.b4(t),u_frustum_tl:new e.b7(t),u_frustum_tr:new e.b7(t),u_frustum_br:new e.b7(t),u_frustum_bl:new e.b7(t),u_globe_pos:new e.b7(t),u_globe_radius:new e.b4(t),u_globe_transition:new e.b4(t),u_is_globe:new e.b5(t),u_viewport:new e.b6(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.b8(t)}))(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.b7(t),u_lighting_directional_dir:new e.b7(t),u_lighting_directional_color:new e.b7(t),u_ground_radiance:new e.b7(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bb(t),u_light_matrix_1:new e.bb(t),u_fade_range:new e.b6(t),u_shadow_normal_offset:new e.b7(t),u_shadow_intensity:new e.b4(t),u_shadow_texel_size:new e.b4(t),u_shadow_map_resolution:new e.b4(t),u_shadow_direction:new e.b7(t),u_shadow_bias:new e.b7(t),u_shadowmap_0:new e.b5(t),u_shadowmap_1:new e.b5(t)}))(t));}maybeFinalize(){if(!this._pending)return;const e=this._context.extParallelShaderCompile;e&&!this._context.gl.getProgramParameter(this.program,e.COMPLETION_STATUS_KHR)||this._finalize();}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms());}getAttributeLocation(e,t){this._ensureReady();let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(this._ensureReady(),!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(this._ensureReady(),!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(this._ensureReady(),!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(this._ensureReady(),!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(this._ensureReady(),!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(t,i,o,r,n,s,a,l,c,h){const d=t.options.wireframe;if(!1===d.terrain&&!1===d.layers2D&&!1===d.layers3D)return;const u=t.context;if(!(()=>!(!d.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!d.layers2D||t._terrain&&t._terrain.renderingToTexture||!_l.includes(this.name))||!(!d.layers3D||!fl.includes(this.name)))())return;const _=u.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,n,u);if(!f)return;const p=[...this.fixedDefines,"DEBUG_WIREFRAME"],m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:p});m._ensureReady(),u.program.set(m.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(m.program,u,m.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,m),g("terrainUniforms",this,m),g("globeUniforms",this,m),g("fogUniforms",this,m),g("lightsUniforms",this,m),g("shadowUniforms",this,m),f.bind(),u.setColorMode(new $i([_.ONE,_.ONE_MINUS_SRC_ALPHA,_.ZERO,_.ONE],e.i.transparent,[!0,!0,!0,!1])),u.setDepthMode(new vi(i.func===_.LESS?_.LEQUAL:i.func,vi.ReadOnly,i.range)),u.setStencilMode(Wi.disabled);const v=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=h||1;for(let t=0;t1?_.drawElementsInstanced(_.LINES,v,_.UNSIGNED_SHORT,y,h):_.drawElements(_.LINES,v,_.UNSIGNED_SHORT,y);n.bind(),u.program.set(this.program),u.setDepthMode(i),u.setStencilMode(o),u.setColorMode(r);}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const o of Object.keys(i))if(!i[o].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${o} not set but required by ${t} being defined`)}draw(e,t,i,o,r,n,s,a,l,c,h,d,u,_,f,p){const m=e.context,g=m.gl;if(this._ensureReady(),this.failedToCreate)return;m.program.set(this.program),m.setDepthMode(i),m.setStencilMode(o),m.setColorMode(r),m.setCullFace(n);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,s[e]);_&&_.setUniforms(this.program,m,this.binderUniforms,d,{zoom:u});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=f||[],x=_?_.getPaintVertexBuffers():[],b=t===g.TRIANGLES&&c,w=p&&p>0?1:void 0;for(const n of h.get()){const s=n.vaos||(n.vaos={});if((s[a]||(s[a]=new _a)).bind(m,this,l,x,c,n.vertexOffset,y,w),this.forceManualRenderingForInstanceIDShaders){const e=p||1;for(let i=0;i1?g.drawElementsInstanced(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2,p):c?g.drawElements(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2):g.drawArrays(t,n.vertexOffset,n.vertexLength);b&&this._drawDebugWireframe(e,i,o,r,c,n,d,u,_,p);}}}const ml=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i,u_opacity_multiplier:1}),gl=(e,t,i,o,r,n=0)=>Object.assign(ml(e,t,r),Xi(i,o,n)),vl=(e,t,i,o)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:o,u_opacity_multiplier:1}),yl=(e,t,i,o,r,n,s=0)=>Object.assign(gl(e,t,i,o,n,s),{u_world:r}),xl=(e,t,i)=>({u_image:e,u_texel_size:t,u_first_pass:i?1:0}),bl=(t,i,o,r,n,s,a,l)=>{const c=e.r/s.tileSize;return {u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:o.getCameraToCenterDistance(l),u_extrude_scale:[o.pixelsToGLUnits[0]/c,o.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:n}},wl=(e,t,i,o)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(o),u_viewport_size:[i.width,i.height]}),Tl=e.bT(),El=(t,i,o,r,n,s,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.di(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.eG(o,1,s),d={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:Tl,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){d.u_inv_rot_matrix=r,d.u_merc_center=n,d.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:i,u_normalize_matrix:o,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:s,u_tl_parent:a,u_scale_parent:d,u_fade_t:u.mix,u_opacity:u.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:e.f9(_.paint.get("raster-saturation")),u_contrast_factor:e.bP(_.paint.get("raster-contrast")),u_spin_weights:Cl(_.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:p,u_zoom_transition:l,u_merc_center:c,u_cutoff_params:h,u_colorization_mix:Po(e.e,g,y),u_colorization_offset:Mo(e.e,v,y),u_color_ramp:m,u_texture_offset:[b/(x+2*b),x/(x+2*b)],u_texture_res:[x+2*b,x+2*b],u_emissive_strength:w,u_zbias_factor:Sl(t)});function Cl(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Rl=e.bT(),Dl=(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y,x,b,w,T,E)=>{const S=n.transform,I={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:S.getCameraToCenterDistance(y),u_rotate_symbol:+o,u_aspect_ratio:S.width/S.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:+h,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:d,u_texsize_icon:u,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Rl,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Rl,u_up_vector:[0,-1,0],u_color_adj_mat:w,u_icon_transition:T||0,u_gamma_scale:r?n.transform.getCameraToCenterDistance(y)*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:e.co.devicePixelRatio,u_is_halo:1,u_scale_factor:E||1,u_ground_shadow_factor:x,u_inv_matrix:e.dr(e.bT(),a),u_normal_scale:b,u_lutTexture:10,u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0],u_spp_fill_color_zoom_factor:0,u_spp_halo_color_zoom_factor:0,u_spp_opacity_zoom_factor:0,u_spp_halo_width_zoom_factor:0,u_spp_halo_blur_zoom_factor:0,u_spp_emissive_strength_zoom_factor:0,u_spp_occlusion_opacity_zoom_factor:0,u_spp_z_offset_zoom_factor:0,u_spp_translate_zoom_factor:0,u_opacity_multiplier:1};return "globe"===y.name&&(I.u_tile_id=[f.canonical.x,f.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),Ll=(t,i,o,r,n,s,a,l,c)=>Object.assign(function(t,i,o,r,n,s){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),h=s.tileSize*Math.pow(2,r.transform.tileZoom)/c,d=h*(s.tileID.canonical.x+s.tileID.wrap*c),u=h*s.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[a,l],u_pattern_size:o.displaySize,u_pattern_units_to_pixels:n?[r.transform.width,-1*r.transform.height]:[1/e.eG(s,1,r.transform.tileZoom),1/e.eG(s,1,r.transform.tileZoom)],u_pixel_coord_upper:[d>>16,u>>16],u_pixel_coord_lower:[65535&d,65535&u]}}(0,s,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),Ol={fillExtrusion:t=>({u_matrix:new e.bb(t),u_lightpos:new e.b7(t),u_lightintensity:new e.b4(t),u_lightcolor:new e.b7(t),u_vertical_gradient:new e.b4(t),u_opacity:new e.b4(t),u_edge_radius:new e.b4(t),u_width_scale:new e.b4(t),u_ao:new e.b6(t),u_height_type:new e.b5(t),u_base_type:new e.b5(t),u_tile_id:new e.b7(t),u_zoom_transition:new e.b4(t),u_inv_rot_matrix:new e.bb(t),u_merc_center:new e.b6(t),u_up_dir:new e.b7(t),u_height_lift:new e.b4(t),u_flood_light_color:new e.b7(t),u_vertical_scale:new e.b4(t),u_flood_light_intensity:new e.b4(t),u_ground_shadow_factor:new e.b7(t),u_front_cutoff_params:new e.b7(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bb(t),u_edge_radius:new e.b4(t),u_width_scale:new e.b4(t),u_vertical_scale:new e.b4(t),u_height_type:new e.b5(t),u_base_type:new e.b5(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bb(t),u_lightpos:new e.b7(t),u_lightintensity:new e.b4(t),u_lightcolor:new e.b7(t),u_vertical_gradient:new e.b4(t),u_height_factor:new e.b4(t),u_edge_radius:new e.b4(t),u_width_scale:new e.b4(t),u_ao:new e.b6(t),u_height_type:new e.b5(t),u_base_type:new e.b5(t),u_tile_id:new e.b7(t),u_zoom_transition:new e.b4(t),u_inv_rot_matrix:new e.bb(t),u_merc_center:new e.b6(t),u_up_dir:new e.b7(t),u_height_lift:new e.b4(t),u_image:new e.b5(t),u_texsize:new e.b6(t),u_pixel_coord_upper:new e.b6(t),u_pixel_coord_lower:new e.b6(t),u_tile_units_to_pixels:new e.b4(t),u_opacity:new e.b4(t),u_pattern_transition:new e.b4(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bb(t),u_opacity:new e.b4(t),u_ao_pass:new e.b4(t),u_meter_to_tile:new e.b4(t),u_ao:new e.b6(t),u_flood_light_intensity:new e.b4(t),u_flood_light_color:new e.b7(t),u_attenuation:new e.b4(t),u_edge_radius:new e.b4(t),u_fb:new e.b5(t),u_fb_size:new e.b4(t),u_dynamic_offset:new e.b4(t)}),fill:t=>({u_matrix:new e.bb(t),u_emissive_strength:new e.b4(t),u_ground_shadow_factor:new e.b7(t),u_opacity_multiplier:new e.b4(t)}),fillPattern:t=>({u_matrix:new e.bb(t),u_emissive_strength:new e.b4(t),u_image:new e.b5(t),u_texsize:new e.b6(t),u_pixel_coord_upper:new e.b6(t),u_pixel_coord_lower:new e.b6(t),u_tile_units_to_pixels:new e.b4(t),u_ground_shadow_factor:new e.b7(t),u_pattern_transition:new e.b4(t),u_opacity_multiplier:new e.b4(t)}),fillOutline:t=>({u_matrix:new e.bb(t),u_emissive_strength:new e.b4(t),u_world:new e.b6(t),u_ground_shadow_factor:new e.b7(t),u_opacity_multiplier:new e.b4(t)}),fillOutlinePattern:t=>({u_matrix:new e.bb(t),u_emissive_strength:new e.b4(t),u_world:new e.b6(t),u_image:new e.b5(t),u_texsize:new e.b6(t),u_pixel_coord_upper:new e.b6(t),u_pixel_coord_lower:new e.b6(t),u_tile_units_to_pixels:new e.b4(t),u_ground_shadow_factor:new e.b7(t),u_pattern_transition:new e.b4(t),u_opacity_multiplier:new e.b4(t)}),lineBlendComposite:t=>({u_image:new e.b5(t),u_opacity:new e.b4(t),u_blend_mode:new e.b5(t),u_max_density:new e.b4(t)}),lineBlendReduce:t=>({u_image:new e.b5(t),u_texel_size:new e.b6(t),u_first_pass:new e.b5(t)}),circle:e.bE,collisionBox:t=>({u_matrix:new e.bb(t),u_inv_rot_matrix:new e.bb(t),u_camera_to_center_distance:new e.b4(t),u_extrude_scale:new e.b6(t),u_zoom_transition:new e.b4(t),u_merc_center:new e.b6(t),u_tile_id:new e.b7(t)}),collisionCircle:t=>({u_matrix:new e.bb(t),u_inv_matrix:new e.bb(t),u_camera_to_center_distance:new e.b4(t),u_viewport_size:new e.b6(t)}),debug:t=>({u_color:new e.b9(t),u_matrix:new e.bb(t),u_overlay:new e.b5(t),u_overlay_scale:new e.b4(t)}),clippingMask:t=>({u_matrix:new e.bb(t)}),heatmap:t=>({u_extrude_scale:new e.b4(t),u_intensity:new e.b4(t),u_matrix:new e.bb(t),u_inv_rot_matrix:new e.bb(t),u_merc_center:new e.b6(t),u_tile_id:new e.b7(t),u_zoom_transition:new e.b4(t),u_up_dir:new e.b7(t)}),heatmapTexture:t=>({u_image:new e.b5(t),u_color_ramp:new e.b5(t),u_opacity:new e.b4(t)}),hillshade:t=>({u_matrix:new e.bb(t),u_image:new e.b5(t),u_latrange:new e.b6(t),u_light:new e.b6(t),u_shadow:new e.b9(t),u_highlight:new e.b9(t),u_emissive_strength:new e.b4(t),u_accent:new e.b9(t)}),hillshadePrepare:t=>({u_matrix:new e.bb(t),u_image:new e.b5(t),u_dimension:new e.b6(t),u_zoom:new e.b4(t)}),line:e.e3,linePattern:e.e1,raster:t=>({u_matrix:new e.bb(t),u_normalize_matrix:new e.bb(t),u_globe_matrix:new e.bb(t),u_merc_matrix:new e.bb(t),u_grid_matrix:new e.ba(t),u_tl_parent:new e.b6(t),u_scale_parent:new e.b4(t),u_fade_t:new e.b4(t),u_opacity:new e.b4(t),u_image0:new e.b5(t),u_image1:new e.b5(t),u_brightness_low:new e.b4(t),u_brightness_high:new e.b4(t),u_saturation_factor:new e.b4(t),u_contrast_factor:new e.b4(t),u_spin_weights:new e.b7(t),u_perspective_transform:new e.b6(t),u_raster_elevation:new e.b4(t),u_zoom_transition:new e.b4(t),u_merc_center:new e.b6(t),u_cutoff_params:new e.b8(t),u_colorization_mix:new e.b8(t),u_colorization_offset:new e.b4(t),u_color_ramp:new e.b5(t),u_texture_offset:new e.b6(t),u_texture_res:new e.b6(t),u_emissive_strength:new e.b4(t),u_zbias_factor:new e.b4(t)}),symbol:t=>({u_is_size_zoom_constant:new e.b5(t),u_is_size_feature_constant:new e.b5(t),u_size_t:new e.b4(t),u_size:new e.b4(t),u_camera_to_center_distance:new e.b4(t),u_rotate_symbol:new e.b5(t),u_aspect_ratio:new e.b4(t),u_fade_change:new e.b4(t),u_matrix:new e.bb(t),u_label_plane_matrix:new e.bb(t),u_coord_matrix:new e.bb(t),u_is_text:new e.b5(t),u_elevation_from_sea:new e.b5(t),u_pitch_with_map:new e.b5(t),u_texsize:new e.b6(t),u_texsize_icon:new e.b6(t),u_texture:new e.b5(t),u_texture_icon:new e.b5(t),u_gamma_scale:new e.b4(t),u_device_pixel_ratio:new e.b4(t),u_tile_id:new e.b7(t),u_zoom_transition:new e.b4(t),u_inv_rot_matrix:new e.bb(t),u_merc_center:new e.b6(t),u_camera_forward:new e.b7(t),u_tile_matrix:new e.bb(t),u_up_vector:new e.b7(t),u_ecef_origin:new e.b7(t),u_is_halo:new e.b5(t),u_icon_transition:new e.b4(t),u_color_adj_mat:new e.bb(t),u_scale_factor:new e.b4(t),u_ground_shadow_factor:new e.b7(t),u_inv_matrix:new e.bb(t),u_normal_scale:new e.b4(t),u_lutTexture:new e.b5(t),u_spp_fill_np_color:new e.b8(t),u_spp_halo_np_color:new e.b8(t),u_spp_opacity:new e.b4(t),u_spp_halo_width:new e.b4(t),u_spp_halo_blur:new e.b4(t),u_spp_emissive_strength:new e.b4(t),u_spp_occlusion_opacity:new e.b4(t),u_spp_z_offset:new e.b4(t),u_spp_translate_rotation:new e.b6(t),u_spp_fill_color_zoom_factor:new e.b4(t),u_spp_halo_color_zoom_factor:new e.b4(t),u_spp_opacity_zoom_factor:new e.b4(t),u_spp_halo_width_zoom_factor:new e.b4(t),u_spp_halo_blur_zoom_factor:new e.b4(t),u_spp_emissive_strength_zoom_factor:new e.b4(t),u_spp_occlusion_opacity_zoom_factor:new e.b4(t),u_spp_z_offset_zoom_factor:new e.b4(t),u_spp_translate_zoom_factor:new e.b4(t),u_opacity_multiplier:new e.b4(t)}),background:t=>({u_matrix:new e.bb(t),u_emissive_strength:new e.b4(t),u_opacity:new e.b4(t),u_color:new e.b9(t)}),backgroundPattern:t=>({u_matrix:new e.bb(t),u_emissive_strength:new e.b4(t),u_opacity:new e.b4(t),u_image:new e.b5(t),u_pattern_tl:new e.b6(t),u_pattern_br:new e.b6(t),u_texsize:new e.b6(t),u_pattern_size:new e.b6(t),u_pixel_coord_upper:new e.b6(t),u_pixel_coord_lower:new e.b6(t),u_pattern_units_to_pixels:new e.b6(t)}),terrainRaster:t=>({u_matrix:new e.bb(t),u_image0:new e.b5(t),u_image1:new e.b5(t),u_skirt_height:new e.b4(t),u_ground_shadow_factor:new e.b7(t),u_emissive_texture_available:new e.b4(t)}),skybox:t=>({u_matrix:new e.bb(t),u_sun_direction:new e.b7(t),u_cubemap:new e.b5(t),u_opacity:new e.b4(t),u_temporal_offset:new e.b4(t)}),skyboxGradient:t=>({u_matrix:new e.bb(t),u_color_ramp:new e.b5(t),u_center_direction:new e.b7(t),u_radius:new e.b4(t),u_opacity:new e.b4(t),u_temporal_offset:new e.b4(t)}),skyboxCapture:t=>({u_matrix_3f:new e.ba(t),u_sun_direction:new e.b7(t),u_sun_intensity:new e.b4(t),u_color_tint_r:new e.b8(t),u_color_tint_m:new e.b8(t),u_luminance:new e.b4(t)}),globeRaster:t=>({u_proj_matrix:new e.bb(t),u_globe_matrix:new e.bb(t),u_normalize_matrix:new e.bb(t),u_merc_matrix:new e.bb(t),u_zoom_transition:new e.b4(t),u_merc_center:new e.b6(t),u_image0:new e.b5(t),u_image1:new e.b5(t),u_grid_matrix:new e.ba(t),u_skirt_height:new e.b4(t),u_far_z_cutoff:new e.b4(t),u_frustum_tl:new e.b7(t),u_frustum_tr:new e.b7(t),u_frustum_br:new e.b7(t),u_frustum_bl:new e.b7(t),u_globe_pos:new e.b7(t),u_globe_radius:new e.b4(t),u_viewport:new e.b6(t),u_emissive_texture_available:new e.b4(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.b7(t),u_frustum_tr:new e.b7(t),u_frustum_br:new e.b7(t),u_frustum_bl:new e.b7(t),u_horizon:new e.b4(t),u_transition:new e.b4(t),u_fadeout_range:new e.b4(t),u_atmosphere_fog_color:new e.b8(t),u_high_color:new e.b8(t),u_space_color:new e.b8(t),u_temporal_offset:new e.b4(t),u_horizon_angle:new e.b4(t)}),groundShadow:t=>({u_matrix:new e.bb(t),u_ground_shadow_factor:new e.b7(t)}),stars:t=>({u_matrix:new e.bb(t),u_up:new e.b7(t),u_right:new e.b7(t),u_intensity_multiplier:new e.b4(t)}),occlusion:t=>({u_matrix:new e.bb(t),u_anchorPos:new e.b7(t),u_screenSizePx:new e.b6(t),u_occluderSizePx:new e.b6(t),u_color:new e.b8(t)})};class Pl{constructor(e,t,i,o){this.id=Pl.uniqueIdxCounter,Pl.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||o||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=Pl.uniqueIdxCounter,Pl.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}Pl.uniqueIdxCounter=0;const Ml={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Fl{constructor(e,t,i,o,r,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=n,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||r||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(const i of this.attributes){const o=t.getAttributeLocation(e,i.name);-1!==o&&e.enableVertexAttribArray(o);}}setVertexAttribPointers(e,t,i){for(const o of this.attributes){const r=t.getAttributeLocation(e,o.name);if(-1!==r){const t=o.offset+this.itemSize*(i||0);"Float32"===o.type?e.vertexAttribPointer(r,o.components,e.FLOAT,!1,this.itemSize,t):e.vertexAttribIPointer(r,o.components,e[Ml[o.type]],this.itemSize,t);}}}setVertexAttribDivisor(e,t,i){for(let o=0;o0&&e.vertexAttribDivisor(r,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class zl{constructor(e,t,i,o,r){this.context=e,this.width=t,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();o>0&&(this.colorAttachment0=new Ka(e,n,0)),o>1&&(this.colorAttachment1=new Ka(e,n,1)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new Qa(e,n):new Ja(e,n));}static createWithTexture(t,i,o,r,n){const s=t.gl;if(t.activeTexture.set(s.TEXTURE1),t.viewport.set([0,0,o,r]),i&&i.width===o&&i.height===r)return s.bindTexture(s.TEXTURE_2D,i.colorAttachment0.get()),t.bindFramebuffer.set(i.framebuffer),i;i&&i.destroy();const a=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,l=new e.a_(t,{width:o,height:r,data:null},a);l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const c=t.createFramebuffer(o,r,1,null);if(c.format=a,c.colorAttachment0.set(l.texture),n){const e=t.createRenderbuffer(s.DEPTH24_STENCIL8,o,r);t.bindFramebuffer.set(c.framebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e),c._stencilRbo=e;}return c}createColorAttachment(e,t){0===t?this.colorAttachment0=new Ka(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new Ka(e,this.framebuffer,1));}removeColorAttachment(e,t){const i=this.context.gl;let o;0===t?(o=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(o=this.colorAttachment1.get(),this.colorAttachment1=void 0),o&&i.deleteTexture(o);}destroy(){const e=this.context.gl;if(this.colorAttachment0){const t=this.colorAttachment0.get();t&&e.deleteTexture(t);}if(this.colorAttachment1){const t=this.colorAttachment1.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}this._stencilRbo&&(e.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),e.deleteFramebuffer(this.framebuffer);}}class kl{constructor(e,t){this.gl=e,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new ya(this),this.clearDepth=new xa(this),this.clearStencil=new ba(this),this.colorMask=new wa(this),this.depthMask=new Ta(this),this.stencilMask=new Ea(this),this.stencilFunc=new Sa(this),this.stencilOp=new Ia(this),this.stencilTest=new Ca(this),this.depthRange=new Ra(this),this.depthTest=new Da(this),this.depthFunc=new Aa(this),this.blend=new La(this),this.blendFunc=new Oa(this),this.blendColor=new Pa(this),this.blendEquation=new Ma(this),this.cullFace=new Fa(this),this.cullFaceSide=new za(this),this.frontFace=new ka(this),this.program=new Ba(this),this.activeTexture=new Na(this),this.viewport=new Ua(this),this.bindFramebuffer=new ja(this),this.bindRenderbuffer=new Ga(this),this.bindTexture=new Va(this),this.bindVertexBuffer=new Ha(this),this.bindElementBuffer=new Wa(this),this.bindVertexArrayOES=new Za(this),this.pixelStoreUnpack=new qa(this),this.pixelStoreUnpackPremultiplyAlpha=new $a(this),this.pixelStoreUnpackFlipY=new Xa(this),this.options=t?Object.assign({},t):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.disableSymbolUBO=t&&!!t.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=e.getExtension("EXT_color_buffer_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=e.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=e.getExtension("KHR_parallel_shader_compile");}sweepPendingPrograms(){if(0!==this._pendingPrograms.size)for(const e of this._pendingPrograms)e.maybeFinalize();}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault();}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new Pl(this,e,t,i)}createVertexBuffer(e,t,i,o,r){return new Fl(this,e,t,i,o,r)}createRenderbuffer(e,t,i){const o=this.gl,r=o.createRenderbuffer();return this.bindRenderbuffer.set(r),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,o){return new zl(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(t){e.c2(t.blendFunction,$i.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}let Bl;function Nl(t,i,o,r,n,s,a){const l=t.context,c=l.gl,h=t.transform,d=[e.ek(h.center.lng),e.el(h.center.lat)],u=o.layout.get("symbol-placement"),_=o.layout.get("text-variable-anchor"),f="map"===o.layout.get("icon-rotation-alignment"),p="map"===o.layout.get("text-rotation-alignment"),m="point"!==u,g=[];let v=0,y=0;for(let l=0;l0){const t=e.bT(),i=P;e.eo(t,b.placementInvProjMatrix,h.glCoordMatrix),e.eo(t,t,b.placementViewportMatrix),g.push({circleArray:F,circleOffset:y,transform:i,invTransform:t,projection:b.getProjection()}),v+=F.length/4,y=v;}if(!M)continue;t.terrain&&t.terrain.setupElevationDraw(x,O);const z=A?[u.canonical.x,u.canonical.y,1<=0&&(f[y.associatedIconIndex]={x:I,y:C,z:R,angle:P});}else Ni(w,u);}if(h){_.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,o=t.style.ambientLight;e&&o&&(i=uo(t.style,e,o));}return i},W=e=>{if(t.context.disableSymbolUBO)return;e.push("USE_PAINT_PROPERTIES_UBO");const i=Math.floor(t.context.maxUniformBlockSize/4),o=Math.floor(i/4);e.push(`MAX_UBO_SIZE_VEC4 ${o}u`);},Z=e=>{I.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},q=i=>{o.lut&&!T&&(o.lut.texture||(o.lut.texture=new e.a$(t.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],E.gl.RGBA8)),E.activeTexture.set(E.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(E.gl.LINEAR,E.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"));},$=()=>{const i=C&&"point"!==o.layout.get("symbol-placement"),a=[];Z(a),q(a);const c=i||j,d="road"===s.elevationType,g=t.shadowRenderer,T=d&&D&&!!g&&g.enabled,R=H(T),A=d&&D&&!t.terrain?M:P,L=o.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&D&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),L>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||d&&t.terrain||a.push("Z_OFFSET"),0===v&&0===y&&0===x&&1===b||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF"),T&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),d&&D&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),W(a);const O=E.disableSymbolUBO?s.icon.programConfigurations.get(o.id):null,z=t.getOrCreateProgram("symbol",{config:O,defines:a}),B=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],U=s.iconSizeData,$=e.ci(U,I.zoom),X=D||!I.isOrthographic,Y=Ii(f,r.tileID.canonical,D,C,I,s.getProjection(),p),K=Ri(f,r.tileID.canonical,D,C,I,s.getProjection(),p),Q=s.icon.uboBinder&&s.icon.uboBinder.hasPerFeatureTranslate()?[0,0]:l,J=t.translatePosMatrix(K,r,Q,h,!0),ee=t.translatePosMatrix(f,r,Q,h),te=c?Ul:Y,ie=C&&!D&&!i;let oe=N;!k&&!I.mercatorFromTransition||C||(oe=jl(I));const re=u?oe:N,ne=o.getColorAdjustmentMatrix(v,y,x,b),se=Dl(U.kind,$,ie,D,t,ee,te,J,w,!1,B,[0,0],0,n,_,F,G,re,s.getProjection(),R,V,ne,L,null),ae=r.imageAtlasTexture?r.imageAtlasTexture:null,le=1!==o.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,ce=s.sdfIcons||t.options.rotating||t.options.zooming||le||X?S.LINEAR:S.NEAREST,he=s.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),de=t.terrain&&D&&i?e.dr(e.bT(),Y):Ul;if(i&&s.icon){const i=e.s.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,s.getProjection()),a=Ci(f,r.tileID.canonical,D,C,I,s.getProjection(),p),l=o.layout.get("icon-size-scale-range"),c=e.bG(t.scaleFactor,l[0],l[1]);Oi(s,f,t,!1,a,K,D,m,i,n,c);}return {program:z,buffers:s.icon,uniformValues:se,atlasTexture:ae,atlasTextureIcon:null,atlasInterpolation:ce,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:he,depthMode:A,tile:r,renderWithShadows:T,labelPlaneMatrixInv:de}},X=()=>{const i=R&&"point"!==o.layout.get("symbol-placement"),a=[],l=i||z||j,h="road"===s.elevationType,m=t.shadowRenderer,v=h&&A&&!!m&&m.enabled,y=H(v),x=h&&A&&!t.terrain?M:P;t.terrainRenderModeElevated()&&A&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),v&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),h&&A&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Z(a),W(a);const b=E.disableSymbolUBO?s.text.programConfigurations.get(o.id):null,T=t.getOrCreateProgram("symbol",{config:b,defines:a});let C,D=[0,0],L=null;const O=s.textSizeData;s.iconsInText&&(D=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],L=r.imageAtlasTexture?r.imageAtlasTexture:null,C=A||!I.isOrthographic||t.options.rotating||t.options.zooming||"composite"===O.kind||"camera"===O.kind?S.LINEAR:S.NEAREST);const B=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],U=o.layout.get("text-size-scale-range"),q=e.bG(t.scaleFactor,U[0],U[1]),$=e.ci(O,I.zoom,q),X=Ii(f,r.tileID.canonical,A,R,I,s.getProjection(),p),Y=Ri(f,r.tileID.canonical,A,R,I,s.getProjection(),p),K=s.text.uboBinder&&s.text.uboBinder.hasPerFeatureTranslate()?[0,0]:c,Q=t.translatePosMatrix(Y,r,K,d,!0),J=t.translatePosMatrix(f,r,K,d),ee=l?Ul:X,te=R&&!A&&!i;let ie=N;!k&&!I.mercatorFromTransition||R||(ie=jl(I));const oe=Dl(O.kind,$,te,A,t,J,ee,Q,w,!0,B,D,0,n,_,F,G,u?ie:N,s.getProjection(),y,V,null,null,q),re=r.glyphAtlasTexture?r.glyphAtlasTexture:null,ne=S.LINEAR,se=0!==o.paint.get("text-halo-width").constantOr(1),ae=t.terrain&&A&&i?e.dr(e.bT(),X):Ul;if(i&&s.text){const i=e.s.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,s.getProjection()),o=Ci(f,r.tileID.canonical,A,R,I,s.getProjection(),p);Oi(s,f,t,!0,o,Y,A,g,i,n,q);}return {program:T,buffers:s.text,uniformValues:oe,atlasTexture:re,atlasTextureIcon:L,atlasInterpolation:ne,atlasInterpolationIcon:C,isSDF:!0,hasHalo:se,depthMode:x,tile:r,renderWithShadows:v,labelPlaneMatrixInv:ae}},Y=s.icon.segments.get().length,K=s.text.segments.get().length,Q=Y&&!a.onlyText?$():null,J=K&&!a.onlyIcons?X():null,ee=o.paint.get("icon-opacity").constantOr(1),te=o.paint.get("text-opacity").constantOr(1);if(L&&s.canOverlap){O=!0;const t=ee&&!a.onlyText?s.icon.segments.get():[],i=te&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)B.push({segments:new e.aJ([i]),sortKey:i.sortKey,state:Q});for(const t of i)B.push({segments:new e.aJ([t]),sortKey:t.sortKey,state:J});}else a.onlyText||B.push({segments:ee?s.icon.segments:new e.aJ([]),sortKey:0,state:Q}),a.onlyIcons||B.push({segments:te?s.text.segments:new e.aJ([]),sortKey:0,state:J});}O&&B.sort((e,t)=>e.sortKey-t.sortKey);for(const e of B){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:I.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(I.depthOcclusionForSymbolsAndCircles,i.program),E.activeTexture.set(S.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,S.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(S.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,Wl(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Wl(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,r,1)),r.u_is_halo=0;}Wl(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,i.uniformValues,1);}}}function Wl(e,t,i,o,r,n,s,a,l,c){const h=o.context,d=h.gl,u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];e.featureIdBuffer&&u.push(e.featureIdBuffer);const _=e.uboBinder?null:e.programConfigurations.get(i.id);if(e.uboBinder){e.uboBinder.layer=i;const t=o.transform.zoom,r=o.style.getBrightness?o.style.getBrightness():null,n=e.uboBinder.getConstantUniformValues(t,r);l.u_spp_fill_np_color=n.fill_np_color,l.u_spp_halo_np_color=n.halo_np_color,l.u_spp_opacity=n.opacity,l.u_spp_halo_width=n.halo_width,l.u_spp_halo_blur=n.halo_blur,l.u_spp_emissive_strength=n.emissive_strength,l.u_spp_occlusion_opacity=n.occlusion_opacity,l.u_spp_z_offset=n.z_offset;const s=n.zoomFactors;l.u_spp_fill_color_zoom_factor=s[0],l.u_spp_halo_color_zoom_factor=s[1],l.u_spp_opacity_zoom_factor=s[2],l.u_spp_halo_width_zoom_factor=s[3],l.u_spp_halo_blur_zoom_factor=s[4],l.u_spp_emissive_strength_zoom_factor=s[5],l.u_spp_occlusion_opacity_zoom_factor=s[6],l.u_spp_z_offset_zoom_factor=s[7],l.u_spp_translate_zoom_factor=s[8];const a=i.paint.get(e.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),c=e.uboBinder.hasPerFeatureTranslate()&&"map"===a?o.transform.angle:0;l.u_spp_translate_rotation=[Math.cos(c),Math.sin(c)];}const{batchIndices:f,batchSegments:p}=e.getBatchGrouping(t);for(const t of f){const f=p.get(t);e.uboBinder&&e.uboBinder.bind(h,r.program,t),r.draw(o,d.TRIANGLES,n,s,a,gi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,f,i.paint,o.transform.zoom,_,u,c);}}function Zl(t,i,o,r,n,s){const a=o.paint.get("line-width"),l=o.paint.get("line-emissive-strength").isConstant(),c=o.paint.get("line-emissive-strength").constantOr(0),h=o.paint.get("line-occlusion-opacity"),d=o.layout.get("line-elevation-reference"),u="meters"===o.layout.get("line-width-unit"),_="sea"===d,f=!(!t.terrain||!t.terrain.enabled),p=t.context,m=p.gl;if(o.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const g=o.layout.get("line-cross-slope"),v=void 0!==g,y=g<1,x=n||t.colorModeForDrapableLayerRenderPass(l?c:null),b=t.terrain&&t.terrain.renderingToTexture||s,w=b?1:e.co.devicePixelRatio,T=o.paint.get("line-dasharray"),E=T.constantOr(1),S=o.layout.get("line-cap"),I=T.constantOr(null),C=S.constantOr(null),R=o.paint.get("line-pattern"),D=R.constantOr(1),A=o.paint.get("line-pattern-cross-fade"),L=R.constantOr(null),O=o.paint.get("line-opacity").constantOr(1);let P=!D&&1!==O||t.depthOcclusion&&h>0&&h<1;const M=o.paint.get("line-gradient"),F=D?"linePattern":"line",z=e.d$(o);let k;if(b&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==h&&t.depthOcclusion){const t=o.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?k=t.value:e.f_(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}"constant"!==a.value.kind&&!1===a.value.isLineProgressConstant&&z.push("VARIABLE_LINE_WIDTH");const B=o.paint.get("line-emissive-strength");D||"constant"===B.value.kind||!1!==B.value.isLineProgressConstant||z.push("VARIABLE_LINE_EMISSIVE_STRENGTH"),t._debugParams.showElevationIdDebug&&z.push("DEBUG_ELEVATION_ID"),b&&("dual-source-blending"!==t.emissiveMode||l?"mrt-fallback"===t.emissiveMode&&z.push("USE_MRT1"):z.push("DUAL_SOURCE_BLENDING"));const N={},U=[],j=(r,n,s,a,l,c)=>{for(const d of r){const r=i.getTile(d);if(D&&!r.patternsLoaded())continue;const _=r.getBucket(o);if(!_)continue;if("none"!==_.elevationType&&!l||"none"===_.elevationType&&l)continue;t.prepareDrawTile();const f=[...n],g=t.shadowRenderer,v="road"===_.elevationType&&!!g&&g.enabled;let y=[0,0,0];if(v){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(y=uo(t.style,e,i)),f.push("RENDER_SHADOWS","NORMAL_OFFSET");}const T=_.programConfigurations.get(o.id);let S=!1;if(L&&r.imageAtlas){const t=e.aG.from(L),i=t.getPrimary().scaleSelf(w).toString(),o=r.imageAtlas.patternPositions.get(i),n=t.getSecondary(),s=n?r.imageAtlas.patternPositions.get(n.scaleSelf(w).toString()):null;S=!!o&&!!s,o&&T.setConstantPatternPositions(o,s);}A>0&&(S||T.getPatternTransitionVertexBuffer("line-pattern"))&&f.push("LINE_PATTERN_TRANSITION"),_.elevationGroundScaleVertexBuffer&&f.push("ELEVATION_GROUND_SCALE");const R=t.isTileAffectedByFog(d),z=t.getOrCreateProgram(F,{config:T,defines:f,overrideFog:R});if(!D&&I&&C&&r.lineAtlas){const e=r.lineAtlas.getDash(I,C);e&&T.setConstantPatternPositions(e);}v&&g.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile");let[B,j]=o.paint.get("line-trim-offset");if("round"===C||"square"===C){const e=1;B!==j&&(0===B&&(B-=e),1===j&&(j+=e));}const G=b?d.projMatrix:null,V=u?1/_.tileToMeter/e.eG(r,1,t.transform.zoom):1,H=u?1/_.tileToMeter/e.eG(r,1,Math.floor(t.transform.zoom)):1,W=E?o.paint._values["line-floorwidth"]:null;let Z;if(W&&"constant"===W.value.kind){const e=_.zoom;e in N||(N[e]=Math.max(.01,o.widthExpression().evaluate({zoom:e}))),Z=W.value.value;const i=Math.floor(t.transform.zoom);W.value.value=N[e]*Math.pow(2,i-r.tileID.overscaledZ);}const q=D?e.e0(t,r,o,G,w,V,H,[B,j],y,A):e.e2(t,r,o,G,_.lineClipsArray.length,w,V,H,[B,j],y);if(M){const r=_.gradients[o.id];let n=r.texture;if(o.gradientVersion!==r.version){let s=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,r=d.canonical.z===o?Math.ceil(1<{i&&0!==i.get().length&&(null!=k&&(k.value=O*h),void 0!==r&&(q.u_opacity_multiplier=r),z.draw(t,m.TRIANGLES,s,e,x,gi.disabled,q,o.id,_.layoutVertexBuffer,_.indexBuffer,i,o.paint,t.transform.zoom,T,[_.layoutVertexBuffer2,_.patternVertexBuffer,_.zOffsetVertexBuffer,_.elevationIdColVertexBuffer,_.elevationGroundScaleVertexBuffer]),void 0!==r&&(q.u_opacity_multiplier=1),null!=k&&(k.value=O));},Y=e=>{$&&$.active&&on.drawLineFrcRenderLine?on.drawLineFrcRenderLine(_,$,e,X):X(e,_.segments);};if(P&&!l){const e=t.stencilModeForClipping(d).ref;0===e&&b&&p.clear({stencil:0});const i={func:m.EQUAL,mask:255};q.u_alpha_discard_threshold=.8,Y(new Wi(i,e,255,m.KEEP,m.KEEP,m.INVERT)),q.u_alpha_discard_threshold=0,Y(new Wi(i,e,255,m.KEEP,m.KEEP,m.KEEP));}else q.u_alpha_discard_threshold=P&&l&&c?.8:0,Y(l?a:t.stencilModeForClipping(d));$&&on.drawLineFrcFadePass&&on.drawLineFrcFadePass(t,_,d,$,l,a,X),void 0!==Z&&(W.value.value=Z);}};let G=t.depthModeForSublayer(0,vi.ReadOnly);const V=new vi(t.depthOcclusion?m.GREATER:m.LEQUAL,vi.ReadOnly,t.depthRangeFor3D);if(o.hasNonElevatedBuckets){const i=!b&&t.terrain;0!==h&&i?e.f_(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.f_(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):j(r,z,G,Wi.disabled,!1,!0);}if(o.hasElevatedBuckets){"hd-road-markup"===d?f||(G=V,z.push("ELEVATED_ROADS")):(z.push("ELEVATED"),G=V,v&&z.push(y?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),_&&z.push("ELEVATION_REFERENCE_SEA"));const e=P?t.stencilModeFor3D():Wi.disabled;t.forceTerrainMode=!0,j(r,z,G,e,!0,!0),P&&j(r,z,G,e,!0,!1),t.forceTerrainMode=!1;}on.drawLineFrcCoverageSecondPass&&on.drawLineFrcCoverageSecondPass(t,o,U),P&&(t.resetStencilClippingMasks(),b&&p.clear({stencil:0})),0===h||t.depthOcclusion||b||t.layersWithOcclusionOpacity.push(t.currentLayer);}class ql{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null);}}class $l{constructor(e){this.pbo=e.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0;}destroy(e){this.sync&&(e.deleteSync(this.sync),this.sync=null),e.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null);}}const Xl={additive:{clearColor:new e.i(0,0,0,0),colorMode:$i.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new e.i(1,1,1,1),colorMode:$i.multiply,compositeUniformValue:0}};function Yl(e){return !(!e.extRenderToTextureHalfFloat&&!e.extColorBufferFloat)}function Kl(e,t){return "additive"===e&&Yl(t)?$i.additiveAlphaWeightedUnboundedAlpha:Xl[e].colorMode}function Ql(e,t,i){const o=e.context,r=o.gl;let n=i.width,s=i.height,a=i.colorAttachment0.get();t.lineBlendDensityReadback||(t.lineBlendDensityReadback=new $l(r));const l=t.lineBlendDensityReadback;let c=0,h=!0;for(;n>1||s>1;){const i=Math.max(1,Math.floor(n/2)),d=Math.max(1,Math.floor(s/2)),u=0===c?"fboA":"fboB";l[u]=zl.createWithTexture(o,l[u],i,d,!1);const _=l[u];o.bindFramebuffer.set(_.framebuffer),o.viewport.set([0,0,i,d]),o.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a),e.getOrCreateProgram("lineBlendReduce").draw(e,r.TRIANGLES,vi.disabled,Wi.disabled,$i.unblended,gi.disabled,xl(0,[1/n,1/s],h),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom),n=i,s=d,a=_.colorAttachment0.get(),c=1-c,h=!1;}const d=Yl(o),u=d?16:4;l.sync&&(r.deleteSync(l.sync),l.sync=null),r.bindBuffer(r.PIXEL_PACK_BUFFER,l.pbo),r.bufferData(r.PIXEL_PACK_BUFFER,u,r.STREAM_READ),r.readPixels(0,0,1,1,r.RGBA,d?r.FLOAT:r.UNSIGNED_BYTE,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),l.sync=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0),o.viewport.set([0,0,e.width,e.height]);}function Jl(e,t,i){if(!Yl(e.context))return;const o=t.lineBlendDensityReadback;o&&o.sync?(function(e,t,i){if(e.sync&&t.getSyncParameter(e.sync,t.SYNC_STATUS)===t.SIGNALED){if(t.deleteSync(e.sync),e.sync=null,t.bindBuffer(t.PIXEL_PACK_BUFFER,e.pbo),Yl(i)){const i=new Float32Array(4);t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,i);const o=i[1];e.maxDensity=Math.max(2*(o>0?i[0]/o:0),1);}else e.maxDensity=1;t.bindBuffer(t.PIXEL_PACK_BUFFER,null);}}(o,e.context.gl,e.context),o.sync||(Ql(e,t,i),e.style.map.triggerRepaint())):(Ql(e,t,i),e.style.map.triggerRepaint());}function ec(e,t,i,o,r,n){const s=e.context,a=s.gl,l="additive"===i?1:t.paint.get("line-opacity").constantOr(1),c="additive"===i?function(e,t){const i=t.paint.get("line-blend-additive-clamp");if(i>0)return i;const o=t.lineBlendDensityReadback;return o&&0!==o.maxDensity?o.maxDensity:null}(0,t):1;if(null===c)return;s.bindFramebuffer.set(r),n&&s.viewport.set([0,0,n[0],n[1]]),s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,o.colorAttachment0.get());const h=Kl(i,e.context);e.getOrCreateProgram("lineBlendComposite").draw(e,a.TRIANGLES,vi.disabled,Wi.disabled,h,gi.disabled,((e,t,i,o)=>({u_image:0,u_opacity:t,u_blend_mode:i,u_max_density:o}))(0,l,Xl[i].compositeUniformValue,c),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom);}function tc(t,i,o,r){const{painter:n,sourceCache:s,layer:a,coords:l,colorMode:c,elevationType:h,terrainEnabled:d,pass:u}=t,_=n.context.gl,f=a.paint.get("fill-pattern"),p=a.paint.get("fill-pattern-cross-fade"),m=f.constantOr(null);let g=h;"road"!==h||i&&!d||(g="none");const v="road"===g,y=t.painter.shadowRenderer,x=v&&!!y&&y.enabled,b=new vi(n.context.gl.LEQUAL,vi.ReadOnly,n.depthRangeFor3D);let w=[0,0,0];if(x){const e=n.style.directionalLight,t=n.style.ambientLight;e&&t&&(w=uo(n.style,e,t));}const T=f&&f.constantOr(1),E=n.terrain&&n.terrain.renderingToTexture,S=(t,u)=>{let f,g,S,I,C;u?(f=T&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",S=_.LINES):(f=T?"fillPattern":"fill",S=_.TRIANGLES);const R=[];for(const D of l){const l=s.getTile(D);if(T&&!l.patternsLoaded())continue;const A=l.getBucket(a);if(!A)continue;const L=i?A.hdExt&&A.hdExt.elevationBufferData:A.bufferData;if(!L||L.isEmpty())continue;n.prepareDrawTile();const O=L.programConfigurations.get(a.id),P=n.isTileAffectedByFog(D),M=[],F=[];v&&(M.push("ELEVATED_ROADS"),F.push(L.elevatedLayoutVertexBuffer)),x&&M.push("RENDER_SHADOWS","NORMAL_OFFSET"),E&&o&&M.push("USE_MRT1"),T&&(n.context.activeTexture.set(_.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),O.updatePaintBuffers());let z=!1;if(m&&l.imageAtlas){const t=l.imageAtlas,i=e.aG.from(m),o=i.getPrimary().scaleSelf(e.co.devicePixelRatio).toString(),r=i.getSecondary(),n=t.patternPositions.get(o),s=r?t.patternPositions.get(r.scaleSelf(e.co.devicePixelRatio).toString()):null;z=!!n&&!!s,n&&O.setConstantPatternPositions(n,s);}p>0&&(z||O.getPatternTransitionVertexBuffer("fill-pattern"))&&M.push("FILL_PATTERN_TRANSITION");const k=n.getOrCreateProgram(f,{config:O,overrideFog:P,defines:M}),B=n.translatePosMatrix(D.projMatrix,l,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));x&&y.setupShadows(l.tileID.toUnwrapped(),k,"vector-tile");const N=a.paint.get("fill-emissive-strength");if(u){I=L.lineIndexBuffer,C=L.lineSegments;const e=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[_.drawingBufferWidth,_.drawingBufferHeight];g="fillOutlinePattern"===f&&T?yl(B,N,n,l,e,w,p):vl(B,N,e,w);}else I=L.indexBuffer,C=L.triangleSegments,g=T?gl(B,N,n,l,w,p):ml(B,N,w);n.uploadCommonUniforms(n.context,k,D.toUnwrapped());let U=t;if(("road"===h&&!d||"offset"===h)&&(U=b),!C||C.get&&0===C.get().length)continue;const j=r||n.stencilModeForClipping(D);let G="fallthrough";!u&&on.drawFillFrcCoverageFirstPass&&(G=on.drawFillFrcCoverageFirstPass({painter:n,layer:a,bucket:A,coord:D,elevatedGeometry:i,program:k,programConfiguration:O,uniformValues:g,drawMode:S,depthMode:U,stencilMode:j,colorMode:c,bufferData:L,indexBuffer:I,segments:C,dynamicBuffers:F,polygonCoverageTiles:R})),"fallthrough"===G&&k.draw(n,S,U,j,c,gi.disabled,g,a.id,L.layoutVertexBuffer,I,C,a.paint,n.transform.zoom,O,F);}!u&&on.drawFillFrcCoverageSecondPass&&on.drawFillFrcCoverageSecondPass(n,a,R,S,c);};n.renderPass===u&&S(n.depthModeForSublayer(1,"opaque"===n.renderPass?vi.ReadWrite:vi.ReadOnly),!1),"none"===g&&"translucent"===n.renderPass&&a.paint.get("fill-antialias")&&S(n.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,vi.ReadOnly),!0);}function ic(t){return [t[0]*e.C,t[1]*e.C,t[2]*e.C,0]}function oc(t,i,o,r,n,s,a,l,c){const h=r.getSource(),d=o.globeSharedBuffers;if(!d)return;let u,_,f;if(i&&(u=r.getTile(i)),h instanceof e.a3?(_=h.texture,f=e.dj(0,0,o.transform)):u&&i&&(_=u.texture,f=e.dj(i.canonical.z,i.canonical.x,o.transform)),!_||!f)return;t||(f=e.fc(e.bT(),f,[1,-1,1]));const p=o.context,m=p.gl,g="nearest"===n.paint.get("raster-resampling")?m.NEAREST:m.LINEAR,v=o.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const x=new vi(m.LEQUAL,vi.ReadWrite,o.depthRangeFor3D),b=o.transform.expandedFarZProjMatrix,w=Float32Array.from(e.dh(e.dk(new e.f(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),p.activeTexture.set(m.TEXTURE0),_.bind(g,m.CLAMP_TO_EDGE),p.activeTexture.set(m.TEXTURE1),_.bind(g,m.CLAMP_TO_EDGE),"useMipmap"in _&&p.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);const[T,E,S,I]=i?d.getPoleBuffers(i.canonical.z,!1):d.getPoleBuffers(0,!0),C=n.paint.get("raster-elevation");let R;t?(R=T,o.renderDefaultNorthPole=0!==C):(R=E,o.renderDefaultSouthPole=0!==C);const D=ic(a.mix),A=((e,t,i,o,r,n,s,a,l,c,h,d,u,_)=>Il(e,t,i,o,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},s,[0,0]||[0,0],l,2,h,d,u,1,0,_))(o,b,w,f,e.dm(o.transform.zoom),0,n,0,C,0,D,a.offset,a.range,s),L=o.getOrCreateProgram("raster",{defines:y});o.uploadCommonUniforms(p,L,null),L.draw(o,m.TRIANGLES,x,c,v,l,A,n.id,R,S,I);}function rc(e){if(e.isOrthographic)return [0,0,0,0];const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,n=t+r;return [t,i,(n-r-t)/o,(n-t)/o]}function nc(e,t,i,o){if(e)return t instanceof Uo&&e instanceof Fo?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:ic(o.mix),offset:o.offset,buffer:0,tileSize:1}}const sc=e.dq(new Float32Array(16)),ac=new e.i(1,0,0,1),lc=new e.i(0,1,0,1),cc=new e.i(0,0,1,1),hc=new e.i(1,0,1,1),dc=new e.i(0,1,1,1);function uc(t,i,o,r,n,s,a){const l=t.context,c=t.transform,h=l.gl,d="globe"===c.projection.name,u=d?["PROJECTION_GLOBE_VIEW"]:[];let _=e.bJ(o.projMatrix);if(d&&e.dm(c.zoom)>0){const t=e.fP(o.canonical,c),i=e.de(t);_=e.er(new Float32Array(16),c.globeMatrix,i),e.er(_,c.projMatrix,_);}const f=e.bT();f[12]+=2*n/(e.co.devicePixelRatio*c.width),f[13]+=2*s/(e.co.devicePixelRatio*c.height),e.er(_,f,_);const p=t.getOrCreateProgram("debug",{defines:u}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,p);const g=vi.disabled,v=Wi.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),d?m._makeGlobeTileDebugBuffers(t.context,c):m._makeDebugTileBoundsBuffers(t.context,c.projection);const b=m._tileDebugBuffer||t.debugBuffer,w=m._tileDebugIndexBuffer||t.debugIndexBuffer,T=m._tileDebugSegments||t.debugSegments;if(p.draw(t,h.LINE_STRIP,g,v,y,gi.disabled,ln(_,r.toPremultipliedRenderColor(null)),x,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),a){const e=m.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(r+=` => ${o.overscaledZ}`),r+=` ${m.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}(t,r);}const E=i.getTile(o).tileSize,S=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,I=m._tileDebugTextBuffer||t.debugBuffer,C=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,R=m._tileDebugTextSegments||t.debugSegments;p.draw(t,h.TRIANGLES,g,v,$i.alphaBlended,gi.disabled,ln(_,e.i.transparent.toPremultipliedRenderColor(null),S),x,I,C,R,null,null,null,[m._globeTileDebugTextBuffer]);}function _c(e,t,i,o){pc(e,0,t+i/2,e.transform.width,i,o);}function fc(e,t,i,o){pc(e,t-i/2,0,i,e.transform.height,o);}function pc(t,i,o,r,n,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.co.devicePixelRatio,o*e.co.devicePixelRatio,r*e.co.devicePixelRatio,n*e.co.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST);}const mc=e.b_([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:gc}=mc;function vc(e,t,i,o){e.emplaceBack(t,i,o);}class yc{constructor(t){this.vertexArray=new e.aS,this.indices=new e.aT,vc(this.vertexArray,-1,-1,1),vc(this.vertexArray,1,-1,1),vc(this.vertexArray,-1,1,1),vc(this.vertexArray,1,1,1),vc(this.vertexArray,-1,-1,-1),vc(this.vertexArray,1,-1,-1),vc(this.vertexArray,-1,1,-1),vc(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=t.createVertexBuffer(this.vertexArray,gc),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.aJ.simpleSegment(0,0,36,12);}}function xc(t,i,o,r,n,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),d=((e,t,i,o,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.cs(e.bV(),r),n,h,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),o.draw(t,a.TRIANGLES,vi.disabled,Wi.disabled,$i.unblended,gi.frontCW,d,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const bc=e.b_([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class wc{constructor(t){const i=new e.aU;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 o=new e.aT;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,bc.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.aJ.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const Tc=e.b_([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class Ec{constructor(){this.colorModeAlphaBlendedWriteRGB=new $i([1,qi,1,qi],e.i.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new $i([1,0,1,0],e.i.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null;}update(t){this._painter=t;const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new wc(i);let t=this.params;const o=t.sizeRange,r=t.intensityRange,n=function(t){const i=e.eq(30),o=[];for(let r=0;r{const i="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,o,r,n,s,a,l,c,h,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:r,u_transition:n,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:h,u_horizon_angle:d}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,a,m,h,u,f,v,b);t.uploadCommonUniforms(o,l);const d=this.atmosphereBuffer;d&&l.draw(t,r.TRIANGLES,s,Wi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,gi.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",d.vertexBuffer,d.indexBuffer,d.segments);};w(!1),w(!0);}drawStars(t,i){const o=e.bG(i.properties.get("star-intensity"),0,1);if(0===o)return;const r=t.context,n=r.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.dp([]);e.f2(l,l,-s._pitch),e.f5(l,l,-s.angle),e.f2(l,l,e.c4(s._center.lat)),e.f4(l,l,-e.c4(s._center.lng));const c=e.ct(new Float32Array(16),l),h=e.er([],s.starsProjMatrix,c),d=e.cs([],c),u=e.dt([],d);let _=this.params.sizeMultiplier;const f=[0,1,0];e.fK(f,f,u),e.fa(f,f,_);const p=[1,0,0];e.fK(p,p,u),e.fa(p,p,_);const m=(g=f,v=p,y=o,{u_matrix:Float32Array.from(h),u_up:g,u_right:v,u_intensity_multiplier:y});var g,v,y;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,n.TRIANGLES,vi.disabled,Wi.disabled,this.colorModeAlphaBlendedWriteRGB,gi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}class Sc{constructor(){this.visibleTiles=[];}updateBorders(t,i){const o=[],r=[],n=t._getRenderableCoordinates(!1,!0);for(const e of n){const n=t.getTile(e);if(!n.hasData())continue;const s=n.getBucket(i);s&&(s.isEmpty()||(o.push(e.key),r.push({bucket:s,tileID:e.canonical})));}let s=o.length!==this.visibleTiles.length;if(!s){o.sort();for(let e=0;ee.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,o=new Array,r=t.bucket;for(const e of r.featuresOnBorder)a.has(e.featureId)?o.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));r.updateFootprintHiddenFlags(i,e.B,!1),r.updateFootprintHiddenFlags(o,e.B,!0);}}}class Ic{}class Cc{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,o){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=o.gl,n=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),s=new ArrayBuffer(n),a=new Int16Array(s);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.aR;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class Rc{constructor(){this.occluderSize=30,this.depthOffset=-1e-4;}}const Dc={symbol:function(t,i,o,r,n){if("translucent"!==t.renderPass)return;const s=Wi.disabled,a=t.colorModeForRenderPass(),l=o.layout.get("text-variable-anchor"),c=o.layout.get("text-size-scale-range"),h=e.bG(t.scaleFactor,c[0],c[1]);l&&function(t,i,o,r,n,s,a,l){const c=i.transform,h="map"===n,d="map"===s;for(const i of t){const t=r.getTile(i),n=t.getBucket(o);if(!n||!n.text||!n.text.segments.get().length)continue;const s=e.ci(n.textSizeData,c.zoom,l),u=ms(i,n.getProjection(),c),_=c.calculatePixelsToTileUnitsMatrix(t),f=Ii(u,t.tileID.canonical,d,h,c,n.getProjection(),_),p=n.hasIconTextFit()&&n.hasIconData();s&&Vl(n,h,d,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,p);}}(r,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),n,h);const d=0!==o.paint.get("icon-opacity").constantOr(1),u=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(d||u)?Hl(t,i,o,r,s,a):(d&&Hl(t,i,o,r,s,a,{onlyIcons:!0}),u&&Hl(t,i,o,r,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Nl(t,i,o,r,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Nl(t,i,o,r,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,o,r){if("translucent"!==t.renderPass)return;const n=o.paint.get("circle-opacity"),s=o.paint.get("circle-stroke-width"),a=o.paint.get("circle-stroke-opacity"),l=void 0!==o.layout.get("circle-sort-key").constantOr(1),c=o.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,d=h.gl,u=t.transform,_=!(!t.terrain||!t.terrain.enabled),f=o.layout.get("circle-elevation-reference"),p=t.depthModeForSublayer(0,vi.ReadOnly),m=new vi(t.context.gl.LEQUAL,vi.ReadOnly,t.depthRangeFor3D),g="none"===f||_?p:m,v=Wi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),x="globe"===u.projection.name,b=[e.ek(u.center.lng),e.el(u.center.lat)],w=[];for(let n=0;ne.sortKey-t.sortKey);const T={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const e of w){const{programConfiguration:i,program:r,layoutVertexBuffer:n,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,_=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,T),t.uploadCommonUniforms(h,r,c.tileID.toUnwrapped()),r.draw(t,d.TRIANGLES,g,v,y,gi.disabled,l,o.id,n,a,_,o.paint,u.zoom,i,s);}},heatmap:function(t,i,o,r){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const n=t.context,s=n.gl,a=Wi.disabled,l=new $i([s.ONE,s.ONE,s.ONE,s.ONE],e.i.transparent,[!0,!0,!0,!0]),c="globe"===t.transform.projection.name?.5:.25;o.heatmapFbo=zl.createWithTexture(n,o.heatmapFbo,t.width*c,t.height*c),n.clear({color:e.i.transparent});const h=t.transform,d="globe"===h.projection.name,u=d?["PROJECTION_GLOBE_VIEW"]:[],_=d?gi.frontCCW:gi.disabled,f=[e.ek(h.center.lng),e.el(h.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}(t,o));},line:function(e,t,i,o){const r=i.paint.get("line-opacity"),n=i.paint.get("line-width");if(0===r.constantOr(1)||0===n.constantOr(1))return;const s=i.paint.get("line-blend-mode"),a=e.terrain&&e.terrain.renderingToTexture;if("default"===s||"globe"===e.transform.projection.name)"translucent"===e.renderPass&&Zl(e,t,i,o);else {if(a)return void function(e,t,i,o,r){if("translucent"!==e.renderPass)return;const n=e.context,s=n.gl,a=e.terrain;if(!a)return;const l=n.bindFramebuffer.current,c="mrt-fallback"===e.emissiveMode,h=a.drapeBufferSize[0],d=a.drapeBufferSize[1];i.lineBlendFbos||(i.lineBlendFbos=new ql),i.lineBlendFbos.drapeFbo=zl.createWithTexture(n,i.lineBlendFbos.drapeFbo,h,d,!0),c&&s.drawBuffers([s.COLOR_ATTACHMENT0]),n.clear({color:Xl[r].clearColor,depth:1,stencil:0});const u=e.currentStencilSource,_=e._tileClippingMaskIDs,f=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1;const p=e._terrain;e._terrain=null,e._renderTileClippingMasks(i,t,o),Zl(e,t,i,o,Kl(r,e.context),!0),e._terrain=p,e.currentStencilSource=u,e._tileClippingMaskIDs=_,e.nextStencilID=f,c&&s.drawBuffers([s.COLOR_ATTACHMENT0,s.COLOR_ATTACHMENT1]);const m=a.drapeBufferSize,g=i.lineBlendFbos&&i.lineBlendFbos.drapeFbo;g&&("additive"===r&&Jl(e,i,g),ec(e,i,r,g,l,m));}(e,t,i,o,s);if("offscreen"===e.renderPass)return void function(e,t,i,o,r){const n=e.context,s=Math.ceil(e.width),a=Math.ceil(e.height);i.lineBlendFbos||(i.lineBlendFbos=new ql),i.lineBlendFbos.fbo=zl.createWithTexture(n,i.lineBlendFbos.fbo,s,a,!0),n.clear({color:Xl[r].clearColor,depth:1,stencil:0});const l=e.currentStencilSource,c=e._tileClippingMaskIDs,h=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1,e._renderTileClippingMasks(i,t,o);const d=e.renderPass;e.renderPass="translucent",Zl(e,t,i,o,Kl(r,e.context)),e.renderPass=d,e.currentStencilSource=l,e._tileClippingMaskIDs=c,e.nextStencilID=h,n.viewport.set([0,0,e.width,e.height]),"additive"===r&&Jl(e,i,i.lineBlendFbos.fbo);}(e,t,i,o,s);if("translucent"===e.renderPass){const t=i.lineBlendFbos&&i.lineBlendFbos.fbo;return void(t&&ec(e,i,s,t,null))}}},fill:function(t,i,o,r){const n=o.paint.get("fill-color"),s=o.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=o.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=o.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===n.constantOr(e.i.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let d="none";"none"!==o.layout.get("fill-elevation-reference")?d="road":0!==o.paint.get("fill-z-offset").constantOr(1)&&(d="offset");const u=!(!t.terrain||!t.terrain.enabled),_={painter:t,sourceCache:i,layer:o,coords:r,colorMode:l,elevationType:d,terrainEnabled:u,pass:h};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===d&&!u&&on.drawElevatedFillShadows&&on.drawElevatedFillShadows(_));const f="mrt-fallback"===t.emissiveMode;if("offset"!==d){if(tc(_,!1,f),"road"===d){const e=!u&&"translucent"===t.renderPass;e&&on.drawDepthPrepass&&on.drawDepthPrepass(t,i,o,r,"geometry"),tc(_,!0,f,Wi.disabled),e&&on.drawElevatedStructures&&on.drawElevatedStructures(_);}}else tc(_,!1,f,t.stencilModeFor3D());},"fill-extrusion":function(t,i,o,r){const n=o.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===n)return;const h="mrt-fallback"===t.emissiveMode,d=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),u=t.style.order.indexOf(o.fqid);if(d&&function(e,t,i,o,r){for(const n of o){const o=t.getTile(n).getBucket(i);o&&(o.updateReplacement(n,e.replacementSource,r),o.uploadCentroid(e.context));}}(t,i,o,r,u),l||d)for(const e of r){const r=i.getTile(e).getBucket(o);r&&yo(t.context,i,e,r,o,l,d);}if("shadow"===t.renderPass&&t.shadowRenderer){if(l&&n<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.bh)return;const s=t.shadowRenderer.getShadowPassDepthMode();po(t,i,o,r,s,Wi.disabled,$i.disabled,d);}else if("translucent"===t.renderPass){const u=!o.paint.get("fill-extrusion-pattern").constantOr(1),_=o.paint.get("fill-extrusion-color").constantOr(e.i.white);if(!c&&0!==_.a){const e=new vi(t.context.gl.LEQUAL,vi.ReadWrite,t.depthRangeFor3D);1===n&&u?po(t,i,o,r,e,Wi.disabled,$i.unblended,d):(po(t,i,o,r,e,Wi.disabled,$i.disabled,d),po(t,i,o,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),d),t.resetStencilClippingMasks());}if(t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c)){const n=o.paint.get("fill-extrusion-opacity"),u=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),_=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=o.paint.get("fill-extrusion-flood-light-intensity"),p="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(p?null:o.lut).toArray01().slice(0,3),g=u>0&&_>0,v=f>0,y=new mo;y.translate=o.paint.get("fill-extrusion-translate"),y.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),y.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),y.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");const x=s=>{const l=t.depthModeForSublayer(1,vi.ReadOnly,a.LEQUAL,!0),c=o.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),h=e.dY(.1,3,c),p=t._showOverdrawInspector;if(!p){const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),p=new $i([a.ONE,a.ONE,a.ONE,a.ONE],e.i.transparent,[!1,!1,!1,!0],a.MIN);vo(y,t,i,o,r,l,c,p,gi.disabled,s,"sdf",n,u,_,f,m,h,d,!1);}{const c=p?Wi.disabled:new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=p?t.colorModeForRenderPass():new $i([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.i.transparent,[!0,!0,!0,!0]);vo(y,t,i,o,r,l,c,g,gi.disabled,s,"color",n,u,_,f,m,h,d,!1);}};if(c){const c=()=>{const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];let o=l.framebufferCopyTexture;return o&&(!o||o.size[0]===t&&o.size[1]===i)||(o&&o.destroy(),o=l.framebufferCopyTexture=new e.a_(s,new e.ay({width:t,height:i}),a.RGBA8)),o.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,i),o},p=(s,l,p)=>{const g=t.depthModeForSublayer(1,vi.ReadOnly,a.LEQUAL,!1),v=o.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),x=e.dY(.1,3,v);{const c=new $i([a.ONE,a.ONE,a.ONE,a.ONE],e.i.transparent,[!1,!1,!1,!0]);vo(y,t,i,o,r,g,Wi.disabled,c,gi.disabled,s,"clear",n,u,_,f,m,x,d,l);}{const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),h=new $i([a.ONE,a.ONE,a.ONE,a.ONE],e.i.transparent,[!1,!1,!1,!0],a.MIN);vo(y,t,i,o,r,g,c,h,gi.disabled,s,"sdf",n,u,_,f,m,x,d,l);}h&&!s&&(p=c());{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,h=new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),p=new $i([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.i.transparent,[!0,!0,!0,!0]);vo(y,t,i,o,r,g,h,p,gi.disabled,s,"color",n,u,_,f,m,x,d,l);}if(!h||s){const c=new $i([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.i.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);vo(y,t,i,o,r,g,Wi.disabled,c,gi.disabled,s,"clear",n,u,_,f,m,x,d,l,p);}else {a.drawBuffers([a.NONE,a.COLOR_ATTACHMENT1]);const c=new Wi({func:a.EQUAL,mask:255},254,255,a.KEEP,a.DECR,a.DECR),h=new $i([a.ONE,a.ONE,a.ONE,a.ONE],e.i.transparent,[!0,!1,!1,!1],a.MAX);vo(y,t,i,o,r,g,c,h,gi.disabled,s,"emissive",n,u,_,f,m,x,d,l,p),a.drawBuffers([a.COLOR_ATTACHMENT0]);}};if(g||v){let e;t.prepareDrawTile(),h&&!g||(e=c()),g&&p(!0,!1,e),v&&p(!1,!0,e);}}else g&&x(!0),v&&x(!1),(g||v)&&t.resetStencilClippingMasks();}}},hillshade:function(e,t,i,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,n=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||n?[{},o]:e.stencilConfigForOverlap(o);for(const o of a){const r=t.getTile(o);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)ga(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,vi.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=n&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):s[o.overscaledZ];pa(e,o,r,i,t,c,l);}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(t,i,o,r,n,s){if("translucent"!==t.renderPass)return;const a=o.paint.get("raster-opacity");if(0===a)return;const l="globe"===t.transform.projection.name,c=0!==o.paint.get("raster-elevation"),h=c&&l,d=t.terrain&&t.terrain.exaggeration()>0&&c&&"ground"===o.paint.get("raster-elevation-reference"),u=!l&&d;if(t.renderElevatedRasterBackface&&!h)return;const _=t.context,f=_.gl,p=i.getSource(),m=function(t,i,o,r,n){const s=i.paint.get("raster-color"),a="raster-array"===t.type,l=[],c=i.paint.get("raster-resampling"),h=i.paint.get("raster-color-mix");let d=i.paint.get("raster-color-range");const u=[h[0],h[1],h[2],0],_=h[3];let f="nearest"===c?r.NEAREST:r.LINEAR;if(a&&(l.push("RASTER_ARRAY"),s||l.push("RASTER_COLOR"),"linear"===c&&l.push("RASTER_ARRAY_LINEAR"),f=r.NEAREST,!d&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(d=e.fields.range);}if(d=d||[0,1],s){l.push("RASTER_COLOR"),o.activeTexture.set(r.TEXTURE2),i.updateColorRamp(d);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.a_(o,i.colorRamp,r.RGBA8)),t.bind(f,r.CLAMP_TO_EDGE);}return n&&l.push("USE_MRT1"),{mix:u,range:d,offset:_,defines:l,resampling:f}}(p,o,_,f,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(p instanceof e.a3&&!r.length&&!l)return;const g=o.paint.get("raster-emissive-strength"),v=t.colorModeForDrapableLayerRenderPass(g),y=t.terrain&&t.terrain.renderingToTexture,x=!t.options.moving,b="nearest"===o.paint.get("raster-resampling")?f.NEAREST:f.LINEAR;if(p instanceof e.a3&&!r.length&&(p.onNorthPole||p.onSouthPole)){const e=c?t.stencilModeFor3D():Wi.disabled;return void oc(!!p.onNorthPole,null,t,i,o,g,m,gi.disabled,e)}if(!r.length)return;const[w,T]=p instanceof e.a3||y?[{},r]:t.stencilConfigForOverlap(r),E=T.at(-1).overscaledZ;h&&m.defines.push("PROJECTION_GLOBE_VIEW"),c&&m.defines.push("RENDER_CUTOFF","ELEVATED"),d&&m.defines.push("ELEVATION_REFERENCE_GROUND");const S=(r,n,T)=>{for(const S of r){const r=S.toUnwrapped(),I=i.getTile(S);if(y&&(!I||!I.hasData()))continue;_.activeTexture.set(f.TEXTURE0);const C=nc(I,p,o,m);if(!C||!C.texture)continue;const{texture:R,mix:D,offset:A,tileSize:L,buffer:O}=C;let P,M;y?(P=vi.disabled,M=S.projMatrix):c?(P=new vi(f.LEQUAL,vi.ReadWrite,t.depthRangeFor3D),M=l?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(r,x)):(P=t.depthModeForSublayer(S.overscaledZ-E,1===a?vi.ReadWrite:vi.ReadOnly,f.LESS),M=t.transform.calculateProjMatrix(r,x));const F=t.terrain&&y?t.terrain.stencilModeForRTTOverlap(S):w[S.overscaledZ],z=s?0:o.paint.get("raster-fade-duration");I.registerFadeDuration(z);const k=i.findLoadedParent(S,0),B=Vo(I,k,i,t.transform,z);let N,U;!B.isFading&&I.refreshedUponExpiration&&(I.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),_.activeTexture.set(f.TEXTURE0),R.bind(b,f.CLAMP_TO_EDGE),_.activeTexture.set(f.TEXTURE1),k?(k.texture&&k.texture.bind(b,f.CLAMP_TO_EDGE),N=Math.pow(2,k.tileID.overscaledZ-I.tileID.overscaledZ),U=[I.tileID.canonical.x*N%1,I.tileID.canonical.y*N%1]):R.bind(b,f.CLAMP_TO_EDGE),"useMipmap"in R&&_.extTextureFilterAnisotropic&&t.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax);const j=t.transform;let G;const V=c?rc(j):[0,0,0,0];let H,W,Z,q,$,X=0;if(h&&p instanceof e.a3&&p.coordinates.length>3)H=Float32Array.from(e.dh(e.dk(new e.f(0,0,0)))),W=Float32Array.from(j.globeMatrix),Z=Float32Array.from(e.by(j)),q=[e.ek(j.center.lng),e.el(j.center.lat)],G=p.elevatedGlobePerspectiveTransform,$=p.elevatedGlobeGridMatrix||new Float32Array(9);else if(h){const t=e.fF(S.canonical);X=e.cU(t.getCenter().lat),H=Float32Array.from(e.dh(e.dk(S.canonical))),W=Float32Array.from(j.globeMatrix),Z=Float32Array.from(e.by(j)),q=[e.ek(j.center.lng),e.el(j.center.lat)],G=[0,0],$=Float32Array.from(e.cP(S.canonical,t,X,j.worldSize/j._pixelsPerMercatorPixel));}else G=p instanceof e.a3?p.perspectiveTransform:[0,0],H=new Float32Array(16),W=new Float32Array(9),Z=new Float32Array(16),q=[0,0],$=new Float32Array(9);const Y=Il(t,M,H,W,Z,$,U||[0,0],e.dm(t.transform.zoom),q,V,N||1,B,o,G,c?o.paint.get("raster-elevation"):0,2,D,A,m.range,L,O,g),K=t.isTileAffectedByFog(S),Q=t.getOrCreateProgram("raster",{defines:m.defines,overrideFog:K});if(t.uploadCommonUniforms(_,Q,r),p instanceof e.a3){const i=p.elevatedGlobeVertexBuffer,r=p.elevatedGlobeIndexBuffer;if(y||!l)p.boundsBuffer&&p.boundsSegments&&Q.draw(t,f.TRIANGLES,P,Wi.disabled,v,gi.disabled,Y,o.id,p.boundsBuffer,t.quadTriangleIndexBuffer,p.boundsSegments);else if(i&&r){const s=j.zoom<=e.S?p.elevatedGlobeSegments:p.getSegmentsForLongitude(j.center.lng);s&&Q.draw(t,f.TRIANGLES,P,Wi.disabled,v,n,Y,o.id,i,r,s);}}else if(h){P=new vi(f.LEQUAL,vi.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){d&&(t.terrain.setupElevationDraw(I,Q),t.uploadCommonUniforms(_,Q,I.tileID.toUnwrapped()));const[i,r,s]=e.getGridBuffers(X,!1),a=Q.getAttributeLocation(f,"a_texture_pos");-1!==a&&f.vertexAttribI4ui(a,0,0,0,0),Q.draw(t,f.TRIANGLES,P,T||F,t.colorModeForRenderPass(),n,Y,o.id,i,r,s);}}else if(u)P=new vi(f.LEQUAL,vi.ReadWrite,t.depthRangeFor3D),t.terrain.setupElevationDraw(I,Q),t.uploadCommonUniforms(_,Q,I.tileID.toUnwrapped()),j.pitch>20&&Q.draw(t,f.TRIANGLES,P,Wi.disabled,$i.disabled,gi.frontCCW,Y,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),Q.draw(t,f.TRIANGLES,P,F,v,gi.backCCW,Y,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(I);Q.draw(t,f.TRIANGLES,P,F,v,gi.disabled,Y,o.id,e,i,r);}}if(!(p instanceof e.a3)&&h)for(const e of r){const r=e.canonical.y===(1<e.tileID)),f&&(h.activeTexture.set(d.TEXTURE0),t.imageManager.bind(t.context,o.scope));const T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),c){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0,defines:T}),r=sc,h=new e.ap(0,0,0,0,0),u=f?Ll(r,l,a,t,0,o.scope,p,c,{tileID:h,tileSize:_}):Al(r,l,a,n.toPremultipliedRenderColor(s?null:o.lut));return void i.draw(t,d.TRIANGLES,v,g,y,gi.disabled,u,o.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(const m of w){const w=t.isTileAffectedByFog(m),E=t.getOrCreateProgram(x,{overrideFog:w,defines:T}),S=m.toUnwrapped(),I=r?m.projMatrix:t.transform.calculateProjMatrix(S);t.prepareDrawTile();const C=i?i.getTile(m):b?b[m.key]:new e.b0(m,_,u.zoom,t),R=f?Ll(I,l,a,t,0,o.scope,p,c,{tileID:m,tileSize:_}):Al(I,l,a,n.toPremultipliedRenderColor(s?null:o.lut));t.uploadCommonUniforms(h,E,S);const{tileBoundsBuffer:D,tileBoundsIndexBuffer:A,tileBoundsSegments:L}=t.getTileBoundsBuffers(C);E.draw(t,d.TRIANGLES,v,g,y,gi.disabled,R,o.id,D,A,L);}},sky:function(t,i,o){const r=t._atmosphere?e.dm(t.transform.zoom):1,n=o.paint.get("sky-opacity")*r;if(0===n)return;const s=t.context,a=o.paint.get("sky-type"),l=new vi(s.gl.LEQUAL,vi.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i){const o=t.context,r=o.gl;let n=i.skyboxFbo;if(!n){n=i.skyboxFbo=o.createFramebuffer(32,32,1,null),i.skyboxGeometry=new yc(o),i.skyboxTexture=o.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null);}o.bindFramebuffer.set(n.framebuffer),o.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.cB(l,.5*-Math.PI),xc(t,i,a,l,s,0),e.cB(l,.5*Math.PI),xc(t,i,a,l,s,1),e.cA(l,.5*-Math.PI),xc(t,i,a,l,s,2),e.cA(l,.5*Math.PI),xc(t,i,a,l,s,3),e.dq(l),xc(t,i,a,l,s,4),e.cB(l,Math.PI),xc(t,i,a,l,s,5),o.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,o,r){const n=e.context,s=n.gl,a=e.transform,l=e.getOrCreateProgram("skybox");n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,o,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,o,r);e.uploadCommonUniforms(n,l),l.draw(e,s.TRIANGLES,i,Wi.disabled,e.colorModeForRenderPass(),gi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,n,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,o,r,n){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new yc(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.a_(s,i.colorRamp,a.RGBA8)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const d=((t,i,o,r,n)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.c4(o),u_opacity:r,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,n);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,o,Wi.disabled,t.colorModeForRenderPass(),gi.backCW,d,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,n,c);},custom:function(t,i,o,r){const n=t.context,s=o.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&o.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const o=t.transform.pointMerc;i.call(s,n.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.dm(t.transform.zoom),[o.x,o.y],t.transform.pixelsPerMeterRatio);}else i.call(s,n.gl,t.transform.customLayerMatrix());n.setDirty(),t.setBaseState();}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=r[0].canonical,o={x:i.x+r[0].wrap*(s.wrapTileId?0:1<t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,n)&&o.prepareTile(t,r,e.id,n);}};class Lc{constructor(t,i,o,r,n){this.context=new kl(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.frcCoverageSnapshot=null,this.frcCoverageFadeRange=null,this.frcCoverageSourceLayers=[],this.frcCoverageRenderer=on.FrcCoverageRenderer?new on.FrcCoverageRenderer:null,this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,dt:0,timeStamp:e.co.now(),continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParamsOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:5e3,lodSwitchFadeDuration:.5},this.occlusionParams=new Rc,this.setup(),this.numSublayers=Vr.maxUnderzooming+Vr.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.aF,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new lo(this),this._wireframeDebugCache=new Cc,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const s=new e.ay({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.a_(this.context,s,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.maxFrontCutoffRawStart=0,this.worldview=n,this._forceEmissiveMode=!1,this.emissiveMode="constant";}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new dl(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,o]=t.getRangeForProjection();if(i>o)return void(this.transform.fogCullDistSq=null);const r=i+.78*(o-i);this.transform.fogCullDistSq=r*r;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new dl(this,this.style)),this._forceTerrainMode=e;}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.co.devicePixelRatio,this.height=i*e.co.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const t=this.context,i=new e.aQ;i.emplaceBack(0,0),i.emplaceBack(e.r,0),i.emplaceBack(0,e.r),i.emplaceBack(e.r,e.r),this.tileExtentBuffer=t.createVertexBuffer(i,e.eQ.members),this.tileExtentSegments=e.aJ.simpleSegment(0,0,4,2);const o=new e.aQ;o.emplaceBack(0,0),o.emplaceBack(e.r,0),o.emplaceBack(0,e.r),o.emplaceBack(e.r,e.r),this.debugBuffer=t.createVertexBuffer(o,e.eQ.members),this.debugSegments=e.aJ.simpleSegment(0,0,4,5);const r=new e.aQ;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.eQ.members),this.viewportSegments=e.aJ.simpleSegment(0,0,4,2);const n=new e.aP;n.emplaceBack(0,0,0,0),n.emplaceBack(e.r,0,e.r,0),n.emplaceBack(0,e.r,0,e.r),n.emplaceBack(e.r,e.r,e.r,e.r),this.mercatorBoundsBuffer=t.createVertexBuffer(n,e.bt.members),this.mercatorBoundsSegments=e.aJ.simpleSegment(0,0,4,2);const s=new e.aT;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.aM;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.a_(t,new e.ay({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bT();const l=this.context.gl;this.stencilClearMode=new Wi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,vi.disabled,this.stencilClearMode,$i.disabled,gi.disabled,Zr(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const o=this.context,r=o.gl;this.nextStencilID+i.length>256&&this.clearStencil(),o.setColorMode($i.disabled),o.setDepthMode(vi.disabled);const n=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),o=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);n.draw(this,r.TRIANGLES,vi.disabled,new Wi({func:r.ALWAYS,mask:0},o,255,r.KEEP,r.KEEP,r.REPLACE),$i.disabled,gi.disabled,Zr(e.projMatrix),"$clipping",s,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Wi({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Wi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),o=i.at(-1).overscaledZ,r=i[0].overscaledZ-o+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new $i([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.i(0,0,0,null!=t?t:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new $i([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],e.i.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(this.depthOcclusion)return new vi(this.context.gl.GREATER,vi.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!o)return vi.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new vi(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayerthis.style._getOrder(r);let s=n(),a=!1,l=!1,c=null,h=0,d=!1;for(const e of s){const t=o[e];"none"!==t.visibility&&("circle"===t.type?a=!0:"building"===t.type?(c=t,++h):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?l=!0:a=!0));}this.updateEmissiveMode();let u=s.map(e=>o[e]);const _=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.co.now()),this.imageManager.beginFrame();for(const e in _){const t=_[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++h);}let f=!1;for(const e of u)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const p={},m={},g={},v={},y={};for(const e in _){const t=_[e];p[e]=t.getVisibleCoordinates(),m[e]=p[e].slice().reverse(),g[e]=t.getVisibleCoordinates(!0).reverse(),v[e]=t.getShadowCasterCoordinates(),y[e]=t.sortCoordinatesByDistance(p[e]);}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(h||f||this._clippingActiveLastFrame){const t=[],i=[];let o=0;for(const e of u)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(o)),o++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;const o=[];for(let r=0;r0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D(r)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(g),this.opaquePassCutoff=0,s=n(),u=s.map(e=>o[e]));const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in _)for(const t of p[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.T(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Ec),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let T=!(!this.style||!this.style.snow),E=!(!this.style||!this.style.rain);if(T&&!this._snow&&on.Snow&&(this._snow=new on.Snow),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&on.Rain&&(this._rain=new on.Rain),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),c){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Sc);const e=this.style.getLayerSourceCache(c);this.buildingTileBorderManager.updateBorders(e,c);}if(!oe.has(this.context.gl))return;this.renderPass="offscreen";for(const e of u){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?m[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||o&&o.length)&&this.renderLayer(this,i,e,o);}this.depthRangeFor3D=[0,1-(u.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,v)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const S="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),I=(()=>{if(i.showOverdrawInspector)return e.i.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!S){const o="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.i(...r)}if(S){const o="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.i(...r)}}return e.i.transparent})();if(this.context.clear({color:I,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D(r)?y:m)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.dm(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=u[this.currentLayer],o=t.getLayerSourceCache(i),r=o?m[o.id]:void 0;this.terrain||this._renderTileClippingMasks(i,o,o?p[o.id]:void 0),this.renderLayer(this,o,i,r);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;u.forEach(e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i,o,r){const n=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,s=void 0===o?this.terrainRenderModeElevated():o,a=void 0===r?"globe"===this.transform.projection.name:r,l=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(l.push("LIGHTING_3D_MODE"),l.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):n||l.push("LIGHTING_3D_MODE")),s&&(l.push("TERRAIN"),this.linearFloatFilteringSupported()&&l.push("TERRAIN_DEM_FLOAT_FORMAT")),a&&l.push("GLOBE"),!this._fogVisible||n||void 0!==t&&!t||l.push("FOG"),n&&l.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&l.push("OVERDRAW_INSPECTOR"),l}getOrCreateProgram(e,t){this.cache=this.cache||{};const{defines:i,config:o,overrideFog:r,overrideRtt:n,overrideTerrain:s,overrideGlobe:a,precompiled:l}=t||{},c=this.currentGlobalDefines(e,r,n,s,a).concat(i||[]),h=this.getShaderSource(e),d=on.programUniforms,u=Un.programUniforms,_=Ol[e]||d&&d[e]||u&&u[e],f=pl.cacheKey(h,e,c,o);return this.cache[f]||(this.cache[f]=new pl(this.context,e,h,o,_,c,l)),this.cache[f]}getShaderSource(e){const t=on.shaders,i=Un.shaders;return gr[e]||t&&t[e]||i&&i[e]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.a_(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const o=this.style.directionalLight,r=this.style.ambientLight;if(o&&r){const n=((t,i,o)=>{const r=t.properties.get("direction"),n="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(n?null:o.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:o.getLut(i.scope)).toArray01(),h=i.properties.get("intensity"),d=[r.x,r.y,r.z],u=e.f8(c,h),_=e.f8(s,a);return {u_lighting_ambient_color:u,u_lighting_directional_dir:d,u_lighting_directional_color:_,u_ground_radiance:ul(d,_,u)}})(o,r,this.style);i.setLightsUniformValues(t,n);}}}uploadCommonUniforms(t,i,o,r,n){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const n=s.getOpacity(this.transform.pitch),a=((t,i,o,r,n,s,a,l,c,h,d,u)=>{const _=t.transform,f="none"===i.properties.get("color-use-theme"),p=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();p[3]=r;const m=t.frameCounter/1e3%1,[g,v]=i.properties.get("vertical-range");return {u_fog_matrix:o?_.calculateFogTileMatrix(o):u||t.identityMat,u_fog_range:i.getRangeForProjection(),u_fog_color:p,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,v),v],u_fog_temporal_offset:m,u_frustum_tl:n,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_globe_transition:e.dm(_.zoom),u_is_globe:+("globe"===_.projection.name)}})(this,s,o,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*e.co.devicePixelRatio,this.transform.height*e.co.devicePixelRatio],r);i.setFogUniformValues(t,a);}n&&i.setCutoffUniformValues(t,n.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,i=this._backgroundTiles={},o=this.transform.coveringTiles({tileSize:512});for(const r of o)i[r.key]=t[r.key]||new e.b0(r,512,this.transform.tileZoom,this,void 0,this.worldview);return i}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==e.sourceLayer)&&(!t||"batched-model"!==t.type)))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=Zt||t[1]>=Zt}setupDepthForOcclusion(e,t,i){const o=this.context,r=o.gl,n=!!i;var s;i||(i={u_dem:2,u_dem_prev:4,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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),o.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),o.activeTexture.set(r.TEXTURE0),n||t.setTerrainUniformValues(o,i);}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant";}}function Oc(e,t){let i=!1,o=null;const r=()=>{o=null,i&&(e(),o=setTimeout(r,t),i=!1);};return ()=>(i=!0,o||r(),o)}const Pc=/(#.+)?$/;class Mc{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bs(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Oc(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const t=Fc(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split("&").map(o=>{const r=o.split("=")[0];return r===e?(i=!0,`${r}=${t}`):o}).filter(e=>e);return i||o.push(`${e}=${t}`),`#${o.join("&")}`}return `#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e);}),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(Number(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(Pc,this.getHashString()));}}function Fc(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,r=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),s=Math.round(i.lng*n)/n,a=Math.round(i.lat*n)/n,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${o}`:`${o}/${a}/${s}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const zc={linearity:.3,easing:e.fV(0,0,.3,1)},kc=Object.assign({deceleration:2500,maxSpeed:1400},zc),Bc=Object.assign({deceleration:20,maxSpeed:1400},zc),Nc=Object.assign({deceleration:1e3,maxSpeed:360},zc),Uc=Object.assign({deceleration:1e3,maxSpeed:90},zc);class jc{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.co.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.co.now();for(;t.length>0&&i-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.au(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const o=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=Vc(i.pan.mag(),o,Object.assign({},kc,t||{}));r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,Gc(r,e);}if(i.zoom){const e=Vc(i.zoom,o,Bc);r.zoom=this._map.transform.zoom+e.amount,Gc(r,e);}if(i.bearing){const t=Vc(i.bearing,o,Nc);r.bearing=this._map.transform.bearing+e.bG(t.amount,-179,179),Gc(r,t);}if(i.pitch){const e=Vc(i.pitch,o,Uc);r.pitch=this._map.transform.pitch+e.amount,Gc(r,e);}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function Gc(e,t){(!e.duration||e.durationi.unproject(e)),a=n.reduce((e,t,i,o)=>e.add(t.div(o.length)),new e.au(0,0));super(t,{points:n,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:o}),this._defaultPrevented=!1;}}class Zc extends e.x{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class qc{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new Zc(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Hc(e.type,this._map,e))}mouseup(e){this._map.fire(new Hc(e.type,this._map,e));}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Hc(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Hc(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new Hc(e.type,this._map,e))}mouseover(e){this._map.fire(new Hc(e.type,this._map,e));}mouseout(e){this._map.fire(new Hc(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Wc(e.type,this._map,e))}touchmove(e){this._map.fire(new Wc(e.type,this._map,e));}touchend(e){this._map.fire(new Wc(e.type,this._map,e));}touchcancel(e){this._map.fire(new Wc(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class $c{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new Hc(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Hc("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Hc(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Xc{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(m(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,r=this._lastPos;if(!o||!r||r.equals(i)||!this._box&&i.dist(o){this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=s-n+"px",this._box.style.height=l-a+"px");});}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,r=i;if(o&&0===t.button){if(this.reset(),y(),o.x!==r.x||o.y!==r.y)return this._map.fire(new e.x("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),g(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.x(t,{originalEvent:i}))}}function Yc(e,t){const i={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=function(t){const i=new e.au(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Yc(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=Yc(i,t);for(const e in this.touches){const t=o[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Qc{constructor(e){this.singleTap=new Kc(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Jc{constructor(){this._zoomIn=new Qc({numTouches:1,numTaps:2}),this._zoomOut=new Qc({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const o=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const eh=0,th=2,ih={[eh]:1,[th]:2},oh={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class rh{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=w(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=ih[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=Yc(o,i),n=new e.au(0,0),s=new e.au(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),s._add(t.sub(i)),a++,r[e]=t);}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");},500);}}class ch{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[r,n]=o,s=hh(i,t,r),a=hh(i,t,n);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,r]=this._firstTwoTouches,n=hh(i,t,o),s=hh(i,t,r);n&&s||(this._active&&y(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}function hh(e,t,i){for(let o=0;oMath.abs(e.x)}class mh extends ch{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,ph(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const r=this._lastPoints;if(!r)return;const n=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.dA()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(n,s,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,r=t.mag()>=2;if(!o&&!r)return;if(!o||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=e.y>0==t.y>0;return ph(e)&&ph(t)&&n}}const gh={panStep:100,bearingStep:15,pitchStep:10};class vh{constructor(){const e=gh;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1,this._panDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,o=0,r=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),this._panDisabled&&(r=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:yh,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+o*this._pitchStep,offset:[-r*this._panStep,-n*this._panStep],center:s.getCenter()},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}disablePan(){this._panDisabled=!0;}enablePan(){this._panDisabled=!1;}}function yh(e){return e*(2-e)}const xh=4.000244140625,bh=1/450,wh=/(Mac|iPad)/i;class Th{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=bh,e.bs(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.dA()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=e.co.now(),r=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%xh===0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=x(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,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 t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>xh?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const r=i(),n=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):n;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*o))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,n=this._easing;let s,a=!1;if("wheel"===this._type&&r&&n){const t=Math.min((e.co.now()-this._lastWheelEventTime)/200,1),i=n(t);s=e.dY(r,o,i),t<1?this._frameId||(this._frameId=!0):a=!0;}else s=o,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;},200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ca;if(this._prevEase){const t=this._prevEase,o=(e.co.now()-t.start)/t.duration,r=t.easing(o+.01)-t.easing(o),n=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-n*n);i=e.fV(n,s,.25,1);}return this._prevEase={start:e.co.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=d("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=wh.test(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`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role");},200);}}class Eh{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Sh{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ih{constructor(){this._tap=new Qc({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const o=t[0],r=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Ch{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("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 Rh{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i,this._pitchDisabled=!1;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&!this._pitchDisabled&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._pitchDisabled||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}disablePitch(){this._pitchDisabled=!0,this._mousePitch.disable();}enablePitch(){this._pitchDisabled=!1,this._pitchWithRotate&&this._mouseRotate.isEnabled()&&this._mousePitch.enable();}}class Dh{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,this._rotationDisabled=!1,this._tapDragZoomDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoomDisabled||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._tapDragZoomDisabled||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();}disableTapDragZoom(){this._tapDragZoomDisabled=!0,this._tapDragZoom.disable();}enableTapDragZoom(){this._tapDragZoomDisabled=!1,this._touchZoom.isEnabled()&&this._tapDragZoom.enable();}}const Ah=e=>e.zoom||e.drag||e.pitch||e.rotate;class Lh extends e.x{}class Oh{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.fx([],i,t);this.radius=e.dW(o[2]<0?e.c6([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.c6(t,t,this.constants),e.ex(t,t),e.ep(t,t,this.constants);const i=e.fa([],t,this.radius);if(i[2]>0){const t=e.fa([],[0,0,1],e.c7(i,[0,0,1])),o=e.fa([],e.ex([],[i[0],i[1],0]),this.radius),r=e.bj([],i,e.fa([],e.fx([],e.bj([],o,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function Ph(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Mh{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new jc(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Oh,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.bs(["handleEvent","handleWindowEvent"],this);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new qc(t,e));const o=t.boxZoom=new Xc(t,e);this._add("boxZoom",o);const r=new Jc,n=new Sh;t.doubleClickZoom=new Eh(n,r),this._add("tapZoom",r),this._add("clickZoom",n);const s=new Ih;this._add("tapDragZoom",s);const a=t.touchPitch=new mh(t);this._add("touchPitch",a);const l=new sh(e),c=new ah(e);t.dragRotate=new Rh(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new nh(e),d=new lh(t,e);t.dragPan=new Ch(i,h,d),this._add("mousePan",h),this._add("touchPan",d,["touchZoom","touchRotate"]);const u=new fh,_=new uh;t.touchZoomRotate=new Dh(i,_,u,s),this._add("touchRotate",u,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),this._add("blockableMapEvent",new $c(t));const f=t.scrollZoom=new Th(t,this);this._add("scrollZoom",f,["mousePan"]);const p=t.keyboard=new vh;this._add("keyboard",p);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0;}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return !!Ah(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(!(o===i||t&&t.includes(o)))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,o=i?void 0:e,r={needsRenderFrame:!1},n={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?b(this._el,a):i?void 0:x(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let d;this._blockedByActive(s,h,i)?c.reset():c[t||e.type]&&(d=c[t||e.type](e,l,a),this.mergeHandlerResult(r,n,d,i,o),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||c.isActive())&&(s[i]=c);}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=o);this._previousActiveHandlers=s,(Object.keys(c).length||Ph(r))&&(this._changes.push([r,n,c]),this._triggerRenderFrame()),(Object.keys(s).length||Ph(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,o,r){if(!i)return;Object.assign(e,i);const n={handlerName:o,originalEvent:i.originalEvent||r};void 0!==i.zoomDelta&&(t.zoom=n),void 0!==i.panDelta&&(t.drag=n),void 0!==i.pitchDelta&&(t.pitch=n),void 0!==i.bearingDelta&&(t.rotate=n);}_applyChanges(){const t={},i={},o={};for(const[r,n,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.au(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,n),Object.assign(o,s);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const r=this._map,n=r.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!Ph(t)){const e=n.zoom;n.cameraElevationReference="sea",null!=this._originalZoom&&n._orthographicProjectionAtLowPitch&&"globe"!==n.projection.name&&0===n.pitch?(n.cameraElevationReference="ground",n.zoom=this._originalZoom):(n.recenterOnTerrain(),n.cameraElevationReference="ground"),e!==n.zoom&&this._map._update(!0);}if(n._isCameraConstrained&&r._stop(!0),!Ph(t))return void this._fireEvents(i,o,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:d,aroundCoord:u,pinchAround:_}=t;n._isCameraConstrained&&(l>0&&(l=0),n._isCameraConstrained=!1),void 0!==_&&(d=_),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&d&&(this._dragOrigin=s(n.pointCoordinate3D(d)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),d=d||r.transform.centerPoint,c&&(n.bearing+=c),h&&(n.pitch+=h),n._updateCameraState();const f=[0,0,0];if(a)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(d).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(d.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1];}else {const t=n.pointCoordinate(d);if("globe"===n.projection.name){a=a.rotate(-n.angle);const i=n._pixelsPerMercatorPixel/n.worldSize;f[0]=-a.x*e.ej(e.dT(t.y))*i,f[1]=-a.y*e.ej(n.center.lat)*i;}else {const e=n.pointCoordinate(d.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y);}}const p=n.zoom,m=[0,0,0];if(l){const t=s(u||n.pointCoordinate3D(d)),i={dir:e.ex([],e.fx([],t,n._camera.position))};if(i.dir[2]<0){const o=n.zoomDeltaToMovement(t,l);e.fa(m,i.dir,o);}}const g=e.bj(f,f,m);n._translateCameraConstrained(g),l&&Math.abs(n.zoom-p)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const r=Ah(this._eventsInProgress),n=Ah(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in s)this._fireEvent(e,s[e]);n&&this._fireEvent("move",n.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,a[`${e}end`]=l);}for(const e in a)this._fireEvent(e,a[e]);const c=Ah(this._eventsInProgress);if(o&&(r||n)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Lh("renderFrame",{timeStamp:e})),this._applyChanges();})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Fh="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class zh extends e.y{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.bs(["_renderFrameCallback"],this);}getCenter(){return new e.ab(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.au.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),o)}panTo(e,t,i){return this.easeTo(Object.assign({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(Object.assign({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,r,n,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=n;const c=e.ab.convert(i),h=e.ab.convert(o),d=.5*(c.lat+h.lat),u=.5*(c.lng+h.lng),_=e.dU(d,u),f=e.ex([],_),p=e.ex([],e.c1([],f,[0,1,0])),m=e.c1([],p,f),g=[p[0],p[1],p[2],0,m[0],m[1],m[2],0,f[0],f[1],f[2],0,0,0,0,1],v=[_,e.dU(c.lat,c.lng),e.dU(h.lat,c.lng),e.dU(h.lat,h.lng),e.dU(c.lat,h.lng),e.dU(d,c.lng),e.dU(d,h.lng),e.dU(c.lat,u),e.dU(h.lat,u)];let y=e.A.fromPoints(v.map(t=>[e.c7(p,t),e.c7(m,t),e.c7(f,t)]));const x=e.fL([],y.center,g);0===e.fu(x)&&e.ff(x,0,0,1),e.ex(x,x),e.fa(x,x,e.P),a.center=e.cd(x);const b=a.getWorldToCameraMatrix(),w=e.dr(new Float64Array(16),b);y=e.A.applyTransform(y,e.er([],b,g));const T=this._extendAABB(y,a,l,r);if(!T)return void e.f_("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=T,e.fL(x,x,b);const E=.5*(y.max[2]-y.min[2]),S=this._minimumAABBFrustumDistance(a,y),I=e.fa([],[0,0,1],E),C=e.bj(I,x,I),R=S+(0===a.pitch?0:e.c5(x,C)),D=a.globeCenterInViewSpace,A=e.fx([],x,[D[0],D[1],D[2]]);e.ex(A,A),e.fa(A,A,R);const L=e.bj([],x,A);e.fL(L,L,w);const O=e.c9/e.P,P=e.dW(L),M=e.em(Math.max(P*O-e.c9,Number.EPSILON),0),F=Math.min(a.zoomFromMercatorZAdjusted(M),l.maxZoom);return F>.5*(e.S+e.R)?(a.setProjection({name:"mercator"}),a.zoom=F,this._cameraForBounds(a,i,o,r,n,s)):{center:a.center,zoom:F,bearing:r,pitch:n}}_extendAABB(t,i,o,r){const n=.5*((o.padding.left||0)+(o.padding.right||0)),s=.5*((o.padding.top||0)+(o.padding.bottom||0)),a=s,l=n,c=n,h=s,d=i.width-(l+c),u=i.height-(a+h),_=e.fx([],t.max,t.min),f=Math.min(d/_[0],u/_[1]),p=Math.min(i.scaleZoom(i.scale*f),o.maxZoom);if(isNaN(p))return null;const m=i.scale/i.zoomScale(p),g=new e.A([t.min[0]-l*m,t.min[1]-h*m,t.min[2]],[t.max[0]+c*m,t.max[1]+a*m,t.max[2]]),v=("number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.au(o.offset.x,o.offset.y):e.au.convert(o.offset)).rotate(-e.c4(r));return g.center[0]-=v.x*m,g.center[1]+=v.y*m,g}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i=Object.assign({},{exaggerated:!0},i),o.getAtPoint(e.ag.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,r,n,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,r,n,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=n;const c=e.ab.convert(i),h=e.ab.convert(o),d=new e.ab(c.lng,h.lat),u=new e.ab(h.lng,c.lat),_=a.project(c),f=a.project(h),p=this.queryTerrainElevation(c),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(d),v=this.queryTerrainElevation(u),y=[[_.x,_.y,Math.min(p||0,m||0,g||0,v||0)],[f.x,f.y,Math.max(p||0,m||0,g||0,v||0)]];let x=e.A.fromPoints(y);const b=a.getWorldToCameraMatrix(),w=e.dr(new Float64Array(16),b);x=e.A.applyTransform(x,b);const T=this._extendAABB(x,a,l,r);if(!T)return void e.f_("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T;const E=.5*e.fx([],x.max,x.min)[2],S=this._minimumAABBFrustumDistance(a,x),I=[0,0,1,0];e.fM(I,I,b),e.ez(I,I);const C=e.fa([],I,S+E),R=e.bj([],x.center,C);e.fL(x.center,x.center,w),e.fL(R,R,w);const D=a.unproject(new e.au(x.center[0],x.center[1])),A=e.dc(a.projection,D),L=Math.pow(2,A),O=Math.min(a._zoomFromMercatorZ(R[2]*a.pixelsPerMeter*L/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&O<.5*(e.S+e.R)?(a.setProjection({name:"globe"}),a.zoom=O,this._cameraForBounds(a,i,o,r,n,s)):{center:D,zoom:O,bearing:r,pitch:n}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,r,n){const s=e.au.convert(t),a=e.au.convert(i),l=new e.au(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.au(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const h=this.transform.pointLocation3D(l),d=this.transform.pointLocation3D(c),u=this.transform.pointLocation3D(new e.au(l.x,c.y)),_=this.transform.pointLocation3D(new e.au(c.x,l.y)),f=[Math.min(h.lng,d.lng,u.lng,_.lng),Math.min(h.lat,d.lat,u.lat,_.lat)],p=[Math.max(h.lng,d.lng,u.lng,_.lng),Math.max(h.lat,d.lat,u.lat,_.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,p,o,m,r);return this._fitInternal(g,r,n)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,s=!1;"zoom"in t&&o.zoom!==+t.zoom&&(r=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.ab.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(n=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(s=!0,o.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!o.isPaddingEqual(a))if(!1===t.retainPadding){const e=o.clone();e.padding=a,o.setLocationAtPoint(o.center,e.centerPoint);}else o.padding=a;return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.x("movestart",i)).fire(new e.x("move",i)),r&&this.fire(new e.x("zoomstart",i)).fire(new e.x("zoom",i)).fire(new e.x("zoomend",i)),n&&this.fire(new e.x("rotatestart",i)).fire(new e.x("rotate",i)).fire(new e.x("rotateend",i)),s&&this.fire(new e.x("pitchstart",i)).fire(new e.x("pitch",i)).fire(new e.x("pitchend",i)),this.fire(new e.x("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.f_(Fh),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.f_(Fh),this;this.stop();const r=o.zoom,n=o.pitch,s=o.bearing;o.setFreeCameraOptions(t);const a=r!==o.zoom,l=n!==o.pitch,c=s!==o.bearing;return this.fire(new e.x("movestart",i)).fire(new e.x("move",i)),a&&this.fire(new e.x("zoomstart",i)).fire(new e.x("zoom",i)).fire(new e.x("zoomend",i)),c&&this.fire(new e.x("rotatestart",i)).fire(new e.x("rotate",i)).fire(new e.x("rotateend",i)),l&&this.fire(new e.x("pitchstart",i)).fire(new e.x("pitch",i)).fire(new e.x("pitchend",i)),this.fire(new e.x("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.ca},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,d=this._extendPadding(t.padding),u=e.au.convert(t.offset);let _,f,p;if("globe"===o.projection.name){const i=e.ag.fromLngLat(o.center),r=u.rotate(-o.angle);i.x+=r.x/o.worldSize,i.y+=r.y/o.worldSize;const n=i.toLngLat(),s=e.ab.convert(t.center||n);this._normalizeCenter(s),_=o.centerPoint.add(r),f=new e.au(i.x,i.y).mult(o.worldSize),p=new e.au(e.ek(s.lng),e.el(s.lat)).mult(o.worldSize).sub(f);}else {_=o.centerPoint.add(u);const i=o.pointLocation(_),r=e.ab.convert(t.center||i);this._normalizeCenter(r),f=o.project(i),p=o.project(r).sub(f);}const m=o.zoomScale(l-r);let g,v;t.around&&(g=e.ab.convert(t.around),v=o.locationPoint(g));const y=this._zooming||l!==r,x=this._rotating||n!==c,b=this._pitching||h!==s,w=!o.isPaddingEqual(d),T=!1===t.retainPadding?o.clone():o,E=o=>E=>{if(y&&(o.zoom=e.dY(r,l,E)),x&&(o.bearing=e.dY(n,c,E)),b&&(o.pitch=e.dY(s,h,E)),w&&(T.interpolatePadding(a,d,E),_=T.centerPoint.add(u)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-r),t=l>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-E),n=o.unproject(f.add(p.mult(E*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?n.wrap():n,_);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(E,t.duration,o);return this._preloadTiles(e),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,S),this._ease(E(o),e=>{"sea"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);},t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||o.moving||this.fire(new e.x("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.x("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.x("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.x("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.x("move",t)),this._zooming&&this.fire(new e.x("zoom",t)),this._rotating&&this.fire(new e.x("rotate",t)),this._pitching&&this.fire(new e.x("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const o=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new e.x("zoomend",t)),r&&this.fire(new e.x("rotateend",t)),n&&this.fire(new e.x("pitchend",t)),this.fire(new e.x("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.eF(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(o,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.ca},t);const o=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.bG(+t.zoom,o.minZoom,o.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,d=this._extendPadding(t.padding),u=o.zoomScale(l-r),_=e.au.convert(t.offset);let f=o.centerPoint.add(_);const p=o.pointLocation(f),m=e.ab.convert(t.center||p);this._normalizeCenter(m);const g=o.project(p),v=o.project(m).sub(g);let y=t.curve;const x=Math.max(o.width,o.height),b=x/u,w=v.mag();if("minZoom"in t){const i=e.bG(Math.min(t.minZoom,r,l),o.minZoom,o.maxZoom),n=x/o.zoomScale(i-r);y=Math.sqrt(n/w*2);}const T=y*y;function E(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return (Math.exp(e)-Math.exp(-e))/2}function I(e){return (Math.exp(e)+Math.exp(-e))/2}const C=E(0);let R=function(e){return I(C)/I(C+y*e)},D=function(e){return x*((I(C)*(S(t=C+y*e)/I(t))-S(C))/T)/w;var t;},A=(E(1)-C)/y;if(Math.abs(w)<1e-6||!isFinite(A)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const L=n!==c,O=h!==s,P=!o.isPaddingEqual(d),M=!1===t.retainPadding?o.clone():o,F=o=>u=>{const p=u*A,y=1/R(p);o.zoom=1===u?l:r+o.scaleZoom(y),L&&(o.bearing=e.dY(n,c,u)),O&&(o.pitch=e.dY(s,h,u)),P&&(M.interpolatePadding(a,d,u),f=M.centerPoint.add(_));const x=1===u?m:o.unproject(g.add(v.mult(D(p))).mult(y));return o.setLocationAtPoint(o.renderWorldCopies?x.wrap():x,f),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(F,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=O,this._padding=P,this._prepareEase(i,!1),this._ease(F(o),()=>this._afterEase(i),t),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t);}if(!e){const e=this.handlers;e&&e.stop(!1);}return this}_ease(t,i,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.co.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.co.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(t,i){t=e.f$(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.co.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),r=[],n=e(i.clone());for(let e=0;e<=o;e++){const t=n(e/o);r.push(t.clone());}return r}_preloadTiles(e,t){}}const kh=/^(https?:|mailto:)/i;class Bh{constructor(t={}){this.options=t,e.bs(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=d("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const o=d("span","mapboxgl-ctrl-icon",this._compactButton);return o.setAttribute("aria-hidden","true"),o.setAttribute("title",i),this._innerContainer=d("div","mapboxgl-ctrl-attrib-inner",this._container),t&&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===t&&(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;}_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 t=this._editLink;t||(t=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||e.bN.ACCESS_TOKEN}];if(t){const o=i.reduce((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${oe.length-t.length),e=e.filter((t,i)=>{for(let o=i+1;ofunction(e){const t=(new DOMParser).parseFromString(e,"text/html");return Array.from(t.body.querySelectorAll("*")).reverse().forEach(e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(...e.childNodes);const o=e.getAttribute("href");if(!o||!kh.test(o))return void e.replaceWith(t.createTextNode(i));const r=t.createElement("a");r.href=o,r.textContent=i,r.rel="noopener nofollow";const n=e.getAttribute("class");n&&(r.className=n),e.replaceWith(r);}),t.body.innerHTML}(e)).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.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 Nh{constructor(){e.bs(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=d("div","mapboxgl-ctrl");const t=d("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(Object.hasOwn(i,"mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class Uh{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}class jh{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.cb((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const Gh={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","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"};class Vh extends e.x{constructor(e,t,i,o){const{point:r,lngLat:n,originalEvent:s,target:a}=e;super(e.type,{point:r,lngLat:n,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault();},this.id=t,this.interaction=i,this.feature=o;}}class Hh{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map;}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const o=i.filter;let r=i.type;o&&this.filters.set(t,e.bZ(o)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const n=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===n.size&&this.map.on(r,this.handleType),0===n.size&&this.interactionsByType.set(r,n),n.set(t,i),this.typeById.set(t,r);}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType));}queryTargets(e,t){const i=[];for(const[e,o]of t)o.target&&i.push({targetId:e,target:o.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())));}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear();}handleType(t,i){const o="mouseenter"===t.type;if(o&&!this.interactionsByType.has(t.type))return void e.f_("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),n=!!i;i=i||this.queryTargets(t.point,r);let s=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const h of r){if(Yn(h,l,a,i))continue;const r=new e.aZ(l,h),d=Xn(h,l,i);n&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const u=o?this.prevHoveredFeatures.get(d):null,_=new Vh(t,i,c,r),f=u?u.stop:c.handler(_);if(o&&this.hoveredFeatures.set(d,{feature:l,stop:f}),!1!==f){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of r){const{handler:o,target:r}=i;if(!r&&!1!==o(new Vh(t,e,i,null)))break}}}function Wh(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),o=new Set(i);return e.size===o.size&&t.every(e=>o.has(e))}return e.c2(t,i)}const Zh=/matrix.*\((.+)\)/,qh={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,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},$h={showCompass:!0,showZoom:!0,visualizePitch:!1};class Xh{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new sh({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new ah({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bs(["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(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),m();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),r=o&&o.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),r=o&&o.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){g(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down(Object.assign({},e,{button:e.button,type:e.type,ctrlKey:!0,preventDefault:()=>e.preventDefault()}),x(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,x(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=b(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=b(this.element,e.targetTouches)[0],this.move({buttons:1,preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)o.width||i.y>o.height;o.locationPoint3D(r).distSqr(i)180;){const e=o.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const Kh={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%)"},Qh=/\s+/,Jh={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class ed extends e.y{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.bs(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:o="center",color:r="#3FB1CE",scale:n=1,draggable:s=!1,clickTolerance:a=0,rotation:l=Jh.rotation,rotationAlignment:c=Jh.rotationAlignment,pitchAlignment:h=Jh.pitchAlignment,occludedOpacity:d=Jh.occludedOpacity,altitude:u=Jh.altitude}=t||{};this._anchor=o,this._color=r,this._scale=n,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=h,this._occludedOpacity=d,this._altitude=u,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.au.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.au.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault();}),this._element.addEventListener("mousedown",e=>{e.preventDefault();});const _=this._element.classList;for(const e in Kh)_.remove(`mapboxgl-marker-anchor-${e}`);_.add(`mapboxgl-marker-anchor-${this._anchor}`),t&&t.className&&_.add(...t.className.trim().split(Qh)),this._popup=null;}_createDefaultMarker(){const e=d("div"),t=u("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);this._svgElement=t;const i=u("radialGradient",{id:"shadowGradient"},u("defs",{},t));u("stop",{offset:"10%","stop-opacity":.4},i),u("stop",{offset:"100%","stop-opacity":.05},i);const o=u("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"});return this._shadowElement=o,0===this._altitude&&t.insertBefore(o,t.firstChild),u("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"},t),u("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"},t),u("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.ab.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){if(e===this._altitude)return this;const t=this._altitude;return this._altitude=e||Jh.altitude,this._defaultMarker&&0===t!=(0===this._altitude)&&(0===this._altitude?this._svgElement.insertBefore(this._shadowElement,this._svgElement.firstChild):this._shadowElement.remove()),this._update(),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,o=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,e._altitude=this._altitude,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(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t,this._altitude),o=e.getFreeCameraOptions();if(!o.position)return !1;const r=o.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const o=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.dE(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(o),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${Kh[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||"map"!==o)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.eX(e.dl(i.transform,this._lngLat)),n=t.sub(e.dd(i.transform)),s=Math.abs(n.x)+Math.abs(n.y);if(0===s)return "";const a=r/s;return `rotateX(${-n.y*a}deg) rotateY(${n.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let o=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.ab(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.ab(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);o=e.eX(Math.atan2(r.y,r.x))-90;}else o=-i.getBearing();else if("horizon"===r){const r=e.fq(4,6,i.getZoom()),n=e.dd(i.transform);n.y+=r*i.transform.height;const s=t.sub(n),a=e.eX(Math.atan2(s.y,s.x));o=(a>90?a-270:a+90)*(1-r);}return o+=this._rotation,o?`rotateZ(${o}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Yh(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)));}));}getOffset(){return this._offset}setOffset(t){return this._offset=e.au.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const o=this._pointerdownPos,r=this._positionDelta;if(o&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)64||!N.test(t)?e.f_(`Invalid SDK info "${t}"; expected a "Name/version" string. Ignoring.`):B=t;},addTileProvider:e.bm,Map:class extends zh{constructor(t){o.mark(i.create);const r=t;if(null!=(t=Object.assign({},qh,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");t.antialias&&e.dO(window)&&(t.antialias=!1,e.f_("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Gi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._placementAlgorithm=t.placementAlgorithm||"default",this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Uh,this._domRenderTaskQueue=new Uh,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.fU(),this._locale=Object.assign({},Gh,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new jh(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new L(t.transformRequest,t.accessToken,t.testMode);const n=z(t.accessToken||e.bN.ACCESS_TOKEN);if(n&&"atlas"in n&&"number"==typeof n.atlas&&(this._tokenExpiration=n.atlas),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.f_("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat="auto",e.bs(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Mh(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,this._fontstackCompositing=t.fontstackCompositing,(t.style||!t.testMode)&&this.setStyle(t.style||e.bN.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Mc("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new Bh({customAttribution:t.customAttribution})),this._logoControl=new Nh,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent();}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.x(`${t.dataType}data`,t));}),this.on("dataloading",t=>{this.fire(new e.x(`${t.dataType}dataloading`,t));}),this._interactions=new Hh(this);}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.v(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return i.includes("bottom")?r.insertBefore(o,r.firstChild):r.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.v(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.includes(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 e.x("movestart",t)).fire(new e.x("move",t)),this.fire(new e.x("resize",t)),i&&this.fire(new e.x("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ac.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.x("zoomstart")).fire(new e.x("zoom")).fire(new e.x("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.x("pitchstart")).fire(new e.x("pitch")).fire(new e.x("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?navigator.language:e):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this._styleDirty=!0,this.style.setWorldview(e),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let o;"globe"===i&&t.zoom>=e.R?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom=e.R?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&o!==this.transform.mercatorFromTransition;return (i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.ab.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.au.convert(t),i)}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}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){const o=e=>{let i=[];if(Array.isArray(t)){const o=t.filter(e=>this.getLayer(e));i=o.length?this.queryRenderedFeatures(e,{layers:o}):[];}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const n=t=>{const n=o(t.point);n.length?r||(r=!0,i.call(this,new Hc(e,this,t.originalEvent,{features:n}))):r=!1;};return {listener:i,targets:t,delegates:{mousemove:n,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=t=>{o(t.point).length?r=!0:r&&(r=!1,i.call(this,new Hc(e,this,t.originalEvent)));},s=t=>{r&&(r=!1,i.call(this,new Hc(e,this,t.originalEvent)));};return {listener:i,targets:t,delegates:{mousemove:n,mouseout:s}}}{const r=e=>{const t=o(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features);};return {listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._delegatedListeners?this._delegatedListeners[e]:void 0;return o&&(e=>{for(let o=0;o{if(o){const r="string"==typeof o?o:o instanceof Error?o.message:o.error;e.f_(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}else r&&this._update(!0);},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._fontstackCompositing=i.fontstackCompositing,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new ua(this,i).load(e),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new ua(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.f_("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.v(new Error("IDs can't be empty."))),!1):!e.dx(t)||(this.fire(new e.v(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return "featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return !1;return !0}return this._isTargetValid(e)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:o=1,sdf:r=!1,stretchX:n,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.a1.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:h}=e.co.getImageData(i);this.style.addImage(l,{data:new e.ay({width:t,height:c},h),pixelRatio:o,stretchX:n,stretchY:s,content:a,sdf:r,version:0,usvg:!1});}else if(void 0===i.width||void 0===i.height)this.fire(new e.v(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:c,height:h}=i,d=i;this.style.addImage(l,{data:new e.ay({width:c,height:h},new Uint8Array(d.data)),pixelRatio:o,stretchX:n,stretchY:s,content:a,sdf:r,usvg:!1,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=e.a1.from(t),r=this.style.getImage(o);if(!r)return void this.fire(new e.v(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.co.getImageData(i):i,{width:s,height:a,data:l}=n;if(void 0===s||void 0===a)return void this.fire(new e.v(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.v(new Error(`The width and height of the updated image (${s}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let h=!1;r.usvg?(r.data=new e.ay({width:s,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,h=!0):r.data.replace(l,c),this.style.updateImage(o,r,h);}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.a1.from(t)):(this.fire(new e.v(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.a1.from(t));}loadImage(t,i){e.cQ(this._requestManager.transformRequest(t,e.aH.Image),(e,t)=>{i(e,t);});}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.v(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new e.v(new Error("Failed to add import",t)))),this}updateImport(e,t){return "string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getLayerProperty(e,t){return this._isValidId(e)?this.style.getLayerProperty(e,t):null}setLayerProperty(e,t,i,o={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,o),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(e){const t=this.transform.nearClipOffset!==e;return this.transform.nearClipOffset=e,this._update(t)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.ab.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.style.indoorManager&&this.style.indoorManager.selectFloor(e);}_setIndoorActiveFloorsVisibility(e){this.style.indoorManager&&this.style.indoorManager.setActiveFloorsVisibility(e);}getIndoorTileOptions(e,t){return this.style&&this.style.isIndoorEnabled()&&this.style.indoorManager?this.style.indoorManager.getIndoorTileOptions(e,t):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,r,n=this._container;for(;n&&(!o||!r);){const e=window.getComputedStyle(n).transform;e&&"none"!==e&&(i=e.match(Zh)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(o=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),n=n.parentElement;}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=r?Math.abs(t/r):t;}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.f_("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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=d("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=d("div","mapboxgl-canvas-container",e);this._canvas=d("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),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=d("div","mapboxgl-control-container",e),o=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{o[e]=d("div",`mapboxgl-ctrl-${e}`,i);}),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.co.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const t=Object.assign({},n,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(re(i,!0),this.painter=new Lc(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",e=>{if("source"===e.dataType){const t=this.transform.elevation?this.transform.elevation._source():null;t&&e.sourceCacheId===t.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0);}}),e.cn.testSupport(i)):this.fire(new e.v(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new e.x("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.x("webglcontextrestored",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return !this.isMoving()&&this.loaded()}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(t){let r;this.fire(new e.x("renderstart")),++this._frameId;const n=this.painter.context.extTimerQuery,s=e.co.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=a.createQuery(),a.beginQuery(n.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,o=e.co.now(),r=new e.w(t,{now:o,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._placementAlgorithm)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,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 e.x("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.mark(i.load),this.fire(new e.x("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.co.now()-s;a.endQuery(n.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(r,a.QUERY_RESULT)/1e6;a.deleteQuery(r),this.fire(new e.x("gpu-timing-frame",{cpuTime:t,gpuTime:i}));},50);}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.x("gpu-timing-layer",{layerTimes:i}));},50);}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.x("gpu-timing-deferred-render",{gpuTime:i}));},50);}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else {if(this._triggerFrame(!1),t&&(this.fire(new e.x("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.x("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}t&&this.style&&this.style.handleIdle();}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,o.mark(i.fullLoad),this._performanceMetricsCollection&&ee(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const n=Math.abs(t-r);if(n>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_isTokenExpired(){return null!=this._tokenExpiration&&Date.now()>this._tokenExpiration}_revokeAuth(){const t=this.painter.context.gl;re(t,!1),this._logoControl instanceof Nh&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.v(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/")));}_authenticate(){ie(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{e&&(e.message!==A&&401!==e.status||this._revokeAuth());}),this._isTokenExpired()&&this._revokeAuth(),Z(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{});}_postStyleLoadEvent(){this.style.globalId&&$(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Y(this._requestManager._customAccessToken);}_postAddingAppearancesToStyleEvent(){Q(this._requestManager._customAccessToken);}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,o=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,o),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const r=e.length/4;for(let n=0;n{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);}));}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.bp(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint();}),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get showElevationIdDebug(){return !!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(e){this.painter&&this.painter._debugParams.showElevationIdDebug!==e&&(this.painter._debugParams.showElevationIdDebug=e,this.style&&e?this.style._reloadSources():this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this.style&&e?this.style._reloadSources():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(t,i){e.fj(t,i);}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},$h,t),this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.bs(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e});}),d("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e});}),d("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bs(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));}),this._compassIcon=d("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t);});}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Xh(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=d("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends e.y{constructor(t={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},td,t),e.bs(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Oc(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),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){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t();}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return !!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("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(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.x("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this._lastKnownPosition=t,this.options.trackUserLocation)switch(this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));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(t),this.options.followUserLocation&&(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.x("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish();}}_updateCamera(t){const i=new e.ab(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,r=this._map.getBearing(),n=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),n,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.ab(t.coords.longitude,t.coords.latitude);this.options.showAccuracyCircle?this._accuracyCircleMarker.setLngLat(i).addTo(this._map):this._accuracyCircleMarker.remove(),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const t=this._map.transform,i=e.em(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(t){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===t.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.x("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_startRequestTimeout(){this._clearRequestTimeout();const e=this.options.positionOptions.timeout;e&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"});},e));}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0);}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=d("button","mapboxgl-ctrl-geolocate",this._container),d("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.f_("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._createUserLocationMarkers(),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.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.x("trackuserlocationend")));}),this.fire(new e.x("ready"));}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return e.f_("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.x("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 e.x("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 e.x("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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return !0}setFollowUserLocation(t){return this.options.followUserLocation=null!=t?t:td.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.x("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new e.x("trackuserlocationend")))),this}setShowAccuracyCircle(t){if(this.options.showAccuracyCircle=null!=t?t:td.showAccuracyCircle,!this._accuracyCircleMarker)return this;if(this.options.showAccuracyCircle){if(this.options.showUserLocation&&this._lastKnownPosition){const{longitude:t,latitude:i,accuracy:o}=this._lastKnownPosition.coords;this._accuracy=o,this._accuracyCircleMarker.setLngLat(new e.ab(t,i)).addTo(this._map),this._updateCircleRadius();}}else this._accuracyCircleMarker.remove();return this}setShowUserHeading(e){return this.options.showUserHeading=null!=e?e:td.showUserHeading,this._setup?(this.options.showUserHeading?void 0!==this._geolocationWatchID&&this._addDeviceOrientationListener():(this._removeDeviceOrientationListener(),this._heading=void 0,this._userLocationDotMarker&&this._updateMarkerRotation()),this):this}setFitBoundsOptions(e){return this.options.fitBoundsOptions=null!=e?e:td.fitBoundsOptions,this}setShowUserLocation(e){return this.options.showUserLocation=null!=e?e:td.showUserLocation,this._setup?(this.options.showUserLocation?(this._userLocationDotMarker||(this._createUserLocationMarkers(),this._map.on("zoom",this._onZoom)),!this._lastKnownPosition||void 0!==this._watchState&&"OFF"===this._watchState||this._updateMarker(this._lastKnownPosition)):(this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this._accuracyCircleMarker&&this._accuracyCircleMarker.remove()),this):this}_addDeviceOrientationListener(){const e=()=>{const e="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(e,this._onDeviceOrientation);};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e();}).catch(console.error):e();}_removeDeviceOrientationListener(){window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation);}_createUserLocationMarkers(){this._dotElement=d("div","mapboxgl-user-location"),this._dotElement.appendChild(d("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(d("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new ed({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=d("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ed({element:this._circleElement,pitchAlignment:"map"});}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),this._removeDeviceOrientationListener(),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:Bh,ScaleControl:class{constructor(t={}){this.options=Object.assign({},id,t),e.bs(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,r=t.unproject([o,i]),n=t.unproject([o+e,i]),s=r.distanceTo(n);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter");}_setScale(e,t,i){this._map._requestDomTask(()=>{const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),r=o/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o} ${od[i]}`,this._container.style.width=e*r+"px";});}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.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(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.f_("Full screen control 'container' must be a DOM element.")),e.bs(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.f_("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=d("button","mapboxgl-ctrl-fullscreen",this._controlContainer);d("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},IndoorControl:class{constructor(){e.bs(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null;}onAdd(e){return this._map=e,this._container=d("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._map.on("idle",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection();}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const e=this._map.style.indoorManager;e.off("selector-update",this._onIndoorUpdate),e.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(e.getControlState()),this._map.off("idle",this._onStyleData);}}_createButton(e,t){const i=d("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){e.setAttribute("aria-label",t),e.textContent=t;}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.off("idle",this._onStyleData),this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null);}getDefaultPosition(){return "top-right"}_onIndoorUpdate(e){if(!e||!e.floors||0===e.floors.length)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block";const i=!t||t.floors.length!==e.floors.length||t.floors.some((t,i)=>t.id!==e.floors[i].id);if(i&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),e.selectedFloorId){if(e.selectedFloorId!==this._lastSelectedFloorId||i){const t=e.floors.findIndex(t=>t.id===e.selectedFloorId);if(-1!==t){const i=e.floors.length;let o,r;i<=5?(o=0,r=i-1):0===this._visibleFloorStart?(o=0,r=3):this._visibleFloorStart>=i-3?(o=i-3-1,r=i-1):(o=this._visibleFloorStart,r=this._visibleFloorStart+3-1),tr&&(this._visibleFloorStart=t-2);}}this._lastSelectedFloorId=e.selectedFloorId;}this._render();}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const e=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);d("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(e);const t=this._model.floors,i=t.length;if(i<=5)return void t.forEach(e=>this._createFloorButton(e));const o=0===this._visibleFloorStart,r=this._visibleFloorStart>=i-3;if(o)this._createFloorButton(t[0]);else {const e=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);d("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}let n=[];if(n=o?t.slice(1,4):r?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),n.forEach(e=>this._createFloorButton(e)),r)this._createFloorButton(t[i-1]);else {const e=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);d("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}}_createFloorButton(e){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const t=e.id;this._model&&this._model.selectedFloorId===t&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(t));}),i=(e.name||"").trim(),o=e.zIndex.toString(),r=i?Array.from(i).slice(0,3).join(""):o;this._setButtonTitle(t,r),this._model&&this._model.activeFloorsVisible&&e.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t);}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1);}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);const e=this._model&&this._model.floors||[];if(e.length>3){const t=e.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2);}this._render();}}_scrollDown(){if(this._model&&this._model.floors){const e=this._model.floors.length-3;this._visibleFloorStarte&&(this._visibleFloorStart=e),this._render());}}},Popup:class extends e.y{constructor(t){super(),this.options=Object.assign(Object.create(nd),t),this._altitude=this.options.altitude,e.bs(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(rd):[]);}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.x("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.x("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.ab.convert(t),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}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=d("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=d("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,o=this._pos;if(!t||!i||!o)return "bottom";const r=i.offsetWidth,n=i.offsetHeight,s=o.xt.transform.width-r/2;if(o.y+et.transform.height-n){if(s)return "bottom-left";if(a)return "bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(t){const i=this._map,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let r=this._container;if(r||(r=this._container=d("div","mapboxgl-popup",i.getContainer()),this._tip=d("div","mapboxgl-popup-tip",r),r.appendChild(o)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Yh(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.au?t:i.project(this._lngLat,this._altitude),r=ad(this.options.offset),n=this._anchor=this._getAnchor(r.y),s=ad(this.options.offset,n),a=o.add(s).round();i._requestDomTask(()=>{this._container&&n&&(this._container.style.transform=`${Kh[n]} translate(${a.x}px,${a.y}px)`);});}if(!this._marker&&i._showingGlobe()){const t=e.dE(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(sd);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:ed,Style:ua,LngLat:e.ab,LngLatBounds:e.ac,Point:e.au,MercatorCoordinate:e.ag,FreeCameraOptions:Ti,Evented:e.y,config:e.bN,prewarm:function(){os().acquire(ri);},clearPrewarmedResources:function(){const e=is;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(ri),is=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 e.bN.ACCESS_TOKEN},set accessToken(t){e.fg(t);},get baseApiUrl(){return e.bN.API_URL},set baseApiUrl(t){e.fh(t);},get workerCount(){return ni.workerCount},set workerCount(e){!function(e){ni.workerCount=e;}(e);},get maxParallelImageRequests(){return e.bN.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.fm(t);},clearStorage(t){e.bH(t);},get workerUrl(){return ii.workerUrl},set workerUrl(e){ii.workerUrl=e;},get workerClass(){return ii.workerClass},set workerClass(e){ii.workerClass=e;},get dracoUrl(){return e.cN()},set dracoUrl(t){e.fl(t);},get meshoptUrl(){return e.cW()},set meshoptUrl(t){e.fn(t);},get buildingGenUrl(){return e.cK()},set buildingGenUrl(t){e.fi(t);},setNow:e.co.setNow,restoreNow:e.co.restoreNow};return hd}); +define(["./shared"],function(e){const t={antialias:!1,alpha:!0,stencil:!0,depth:!0};let i,o;function r(e){const i=document.createElement("canvas"),o=Object.create(t);o.failIfMajorPerformanceCaveat=e;const r=i.getContext("webgl2",o);if(!r)return !1;let n;try{n=r.createShader(r.VERTEX_SHADER);}catch(e){return !1}return !(!n||r.isContextLost())&&(r.shaderSource(n,"void main() {}"),r.compileShader(n),!0===r.getShaderParameter(n,r.COMPILE_STATUS))}var n="3.27.0";const s=/firefox/i,a=/macintosh/i;function l(e,t,i){const o=document.createElement(e);return null!=t&&(o.className=t),i&&i.appendChild(o),o}function c(e,t,i){const o=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))o.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(o),o}const h="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,d=h&&void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let u;function _(){h&&d&&(u=h[d],h[d]="none");}function f(){h&&d&&(h[d]=u);}function p(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",p,!0);}function m(){window.addEventListener("click",p,!0),window.setTimeout(()=>{window.removeEventListener("click",p,!0);},0);}function g(e,t){const i=e.getBoundingClientRect();return x(e,i,t)}function v(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;rthis._skuTokenExpiresAt}async transformRequest(e,t,i){if(!this._transformRequestFn)return {url:e};const o=i?{signal:i}:{};return await this._transformRequestFn(e,t,o)||{url:e}}normalizeStyleURL(t,i){if(!e.e(t))return t;const o=O(t);return o.params.push(`sdk=js-${n}`),o.path=`/styles/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeGlyphsURL(t,i){if(!e.e(t))return t;const o=O(t);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.e(t))return t;const o=O(t);return o.path=`/models/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeSourceURL(t,i,o,r){if(!e.e(t))return t;const n=O(t);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),o&&n.params.push(`language=${o}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||i)}normalizeIconsetURL(t,i){const o=O(t);return e.e(t)?(o.path=`/styles/v1${o.path}/iconset.pbf`,this._makeAPIURL(o,this._customAccessToken||i)):M(o)}normalizeSpriteURL(t,i,o,r){const n=O(t);return e.e(t)?(n.path=`/styles/v1${n.path}/sprite${i}${o}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${i}${o}`,M(n))}normalizeTileURL(t,i,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.e(t))return t;const r=O(t);r.path=r.path.replace(S,`${i||o&&"raster"!==r.authority&&512===o?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.g.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.g.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.g.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(I,"/"),r.path=`/${e.g.TILE_URL_VERSION}${r.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(D);if(e)return e[1]}return null}(r.params)||e.g.ACCESS_TOKEN;return e.g.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,n)}canonicalizeTileURL(t,i){const o=O(t);if(!R.test(o.path)||!C.test(o.path))return t;let r="mapbox://";o.path.startsWith("/raster/v1/")?r+=`raster/${o.path.replace(`/${e.g.RASTER_URL_PREFIX}/`,"")}`:o.path.startsWith("/rasterarrays/v1/")?r+=`rasterarrays/${o.path.replace(`/${e.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${o.path.replace(`/${e.g.TILE_URL_VERSION}/`,"")}`;let n=o.params;return i&&(n=n.filter(e=>!e.match(D))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(t,i){const o=!!i&&e.e(i),r=[];for(const i of t.tiles||[])e.f(i)?r.push(this.canonicalizeTileURL(i,o)):r.push(i);return r}_makeAPIURL(t,i){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=O(e.g.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}`),!e.g.REQUIRE_ACCESS_TOKEN)return M(t);if(i=i||e.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return t.params=t.params.filter(e=>!e.includes("access_token")),t.params.push(`access_token=${i||""}`),M(t)}}const P=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function O(e){const t=e.match(P);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function M(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const F="mapbox.eventData";function z(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}function B(t){return !(!e.g.EVENTS_URL||!t&&!e.g.ACCESS_TOKEN)}let k;const N=/^[\w.+-]+(\/[\w.+-]+)?$/;let U="other";class j{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=!1;}getStorageKey(t){const i=z(e.g.ACCESS_TOKEN);let o="";return o=i&&i.u?e.j(i.u):e.g.ACCESS_TOKEN||"",t?`${F}.${t}:${o}`:`${F}:${o}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(o);t&&(this.anonId=t);const n=localStorage.getItem(r);n&&(this.anonIdTimestamp=Number(n));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(r,s.toString());}catch(t){e.w("Unable to write to LocalStorage");}}processRequests(){}postEvent(t,i,o,r){if(!e.g.EVENTS_URL)return;const n=O(e.g.EVENTS_URL);n.params.push(`access_token=${r||e.g.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:M(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=!0,e.p(l).then(()=>{this.pendingRequest=!1,o(null),this.saveEventData(),this.processRequests();}).catch(e=>{this.pendingRequest=!1,o(e),this.saveEventData(),this.processRequests();});}queueRequest(e,t){this.queue.push({...e,customAccessToken:t}),this.processRequests();}}class G extends j{constructor(e){super("metrics"),e&&(this.data=e);}postMetricsEvent(t){if(!B(t))return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i={...this.data,sessionId:this.anonId};this.queueRequest({timestamp:Date.now(),payload:i},t);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:t,customAccessToken:i}=this.queue.shift();this.postEvent(e,t,()=>{},i);}}const V=new class extends j{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(t,i){B(i)&&Array.isArray(t)&&t.some(t=>e.e(t)||e.f(t))&&this.queueRequest({timestamp:Date.now()},i);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=z(e.g.ACCESS_TOKEN),i=t?t.u:e.g.ACCESS_TOKEN;let o=i!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),o=!0);const{timestamp:r,customAccessToken:s}=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(r),i=(r-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate();}else o=!0;if(!o)return void this.processRequests();const a={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:b,"enabled.telemetry":!1,userId:this.anonId,bundleFormat:"umd",bundleDistribution:U};k&&(a.sdkInfo=k),this.postEvent(r,a,e=>{e||(this.eventData.lastSuccess=r,this.eventData.tokenU=i);},s);}},q=V.postTurnstileEvent.bind(V),H=new class extends j{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(t,i,o,r){this.skuToken=i,this.errorCb=r,e.g.EVENTS_URL&&(o||e.g.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(A)));}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i,customAccessToken:o}=this.queue.shift();if(t&&this.success[t])return;this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const r={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:n,skuId:b,skuToken:this.skuToken,userId:this.anonId,bundleFormat:"umd",bundleDistribution:U};k&&(r.sdkInfo=k),this.postEvent(i,r,e=>{e?this.errorCb(e):t&&(this.success[t]=!0);},o);}remove(){this.errorCb=null;}},Z=H.postMapLoadEvent.bind(H),W=new class extends j{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap;}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:o,importedStyles:r}=t;if(!B(e))return;const n=this.getMapInstanceId(i),s={mapInstanceId:n,eventId:this.getEventId(n),style:o};r.length&&(s.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:s},e);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:t,customAccessToken:i}=this.queue.shift();this.postEvent(e,t,()=>{},i);}},$=W.postStyleLoadEvent.bind(W),X=new G({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Y=X.postMetricsEvent.bind(X),K=new G({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Q=K.postMetricsEvent.bind(K),J=new class extends j{constructor(){super("gljs.performance");}postPerformanceEvent(e,t){B(e)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e);}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:i,customAccessToken:o}=this.queue.shift(),r=function(t){const i=performance.getEntriesByType("resource"),o=performance.getEntriesByType("mark"),r=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const o of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,n=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[r]=Math.max(t[r]||-1/0,o.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==o.transferSize&&0===o.transferSize&&a(s),a(n);}return t}(function(e,t){const i={};if(e)for(const o of e){const e=t(o);void 0===i[e]&&(i[e]=[]),i[e].push(o);}return i}(i,E)),s=window.devicePixelRatio,a=navigator.connection||navigator.mozConnection||navigator.webkitConnection,l=a?a.effectiveType:void 0,c={counters:[],metadata:[],attributes:[]},h=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in r)h(c.counters,e,r[e]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(h(c.counters,"interactionRangeMin",t.interactionRange[0]),h(c.counters,"interactionRangeMax",t.interactionRange[1])),o)for(const e of Object.values(w)){const t=o.find(t=>t.name===e);t&&h(c.counters,e,t.startTime);}return h(c.counters,"visibilityHidden",t.visibilityHidden),h(c.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return `mapbox://styles/${e[0]}/${e[1]}`}}}(i)),h(c.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),h(c.attributes,"fogEnabled",t.fogEnabled?"true":"false"),h(c.attributes,"projection",t.projection),h(c.attributes,"zoom",t.zoom),h(c.metadata,"devicePixelRatio",s),h(c.metadata,"connectionEffectiveType",l),h(c.metadata,"navigatorUserAgent",navigator.userAgent),h(c.metadata,"screenWidth",window.screen.width),h(c.metadata,"screenHeight",window.screen.height),h(c.metadata,"windowWidth",window.innerWidth),h(c.metadata,"windowHeight",window.innerHeight),h(c.metadata,"mapWidth",t.width/s),h(c.metadata,"mapHeight",t.height/s),h(c.metadata,"webglRenderer",t.renderer),h(c.metadata,"webglVendor",t.vendor),h(c.metadata,"sdkVersion",n),h(c.metadata,"sdkIdentifier","mapbox-gl-js"),c}(i);for(const e of r.metadata);for(const e of r.counters);for(const e of r.attributes);this.postEvent(t,r,()=>{},o);}},ee=J.postPerformanceEvent.bind(J),te=new class extends j{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(t,i,o,r){if(!e.g.API_URL||!e.g.SESSION_PATH)return;const n=O(e.g.API_URL+e.g.SESSION_PATH);n.params.push(`sku=${i||""}`),n.params.push(`access_token=${r||e.g.ACCESS_TOKEN||""}`);const s={url:M(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=!0,e.h(s).then(()=>{this.pendingRequest=!1,o(null),this.saveEventData(),this.processRequests();}).catch(e=>{this.pendingRequest=!1,o(e),this.saveEventData(),this.processRequests();});}getSessionAPI(t,i,o,r){this.skuToken=i,this.errorCb=r,e.g.EVENTS_URL&&e.g.SESSION_PATH&&e.g.API_URL&&(o||e.g.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(A)));}processRequests(){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:t,customAccessToken:i}=this.queue.shift();e&&this.success[e]||this.getSession(t,this.skuToken,t=>{t?this.errorCb(t):e&&(this.success[e]=!0);},i);}remove(){this.errorCb=null;}},ie=te.getSessionAPI.bind(te),oe=new Set;function re(e,t){t?oe.add(e):oe.delete(e);}class ne{constructor(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps=new Set,this._updatedImages=Object.create(null);}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty();}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear();}reset(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps.clear(),this._updatedImages=Object.create(null);}}class se{constructor(e){this._layer=e,this._filterDependencies=void 0;}invalidateFilter(){this._filterDependencies=void 0;}get _filterDeps(){return void 0===this._filterDependencies&&(this._filterDependencies=this._computeFilterDependencies()),this._filterDependencies}_computeFilterDependencies(){const t=this._layer;if(!t.type||"custom"===t.type||"background"===t.type||"sky"===t.type||"slot"===t.type)return null;const i=e.n(t.filter,e.m[`filter_${t.type}`]);return "error"===i.result?null:{configDependencies:i.value.configDependencies,isIndoorDependent:i.value.isIndoorDependent}}hasConfigDependency(e){const{_unevaluatedLayout:t,_transitionablePaint:i}=this._layer;if(t&&t.configDependencies.has(e))return !0;if(i&&i.configDependencies.has(e))return !0;const o=this._filterDeps;return !!o&&o.configDependencies.has(e)}get isConfigDependent(){const{_unevaluatedLayout:e,_transitionablePaint:t}=this._layer;if(e&&0!==e.configDependencies.size)return !0;if(t&&0!==t.configDependencies.size)return !0;const i=this._filterDeps;return !!i&&0!==i.configDependencies.size}get isIndoorDependent(){const{_unevaluatedLayout:e,_transitionablePaint:t}=this._layer;if(e&&e.isIndoorDependent())return !0;if(t&&t.isIndoorDependent())return !0;const i=this._filterDeps;return !!i&&i.isIndoorDependent}}function ae(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}const le=new e.C(0,0,0);function ce(e,t){const i=[],o=e[`stretch_${t}`];let r=null;for(let e=0;e>16&255)/255,(t>>8&255)/255,(255&t)/255,1)}function we(e,t){const i={spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0};let o;for(;o=e.nextField(t);)1===o?i.transform=ge(e,e.readVarint()+e.pos):2===o?i.spread_method=e.readVarint():3===o?i.stops.push(Te(e,e.readVarint()+e.pos)):4===o?i.x1=e.readFloat():5===o?i.y1=e.readFloat():6===o?i.x2=e.readFloat():7===o&&(i.y2=e.readFloat());return i}function Te(e,t){const i={offset:0,opacity:255,rgb_color:le};let o;for(;o=e.nextField(t);)1===o?i.offset=e.readFloat():2===o?i.opacity=e.readVarint():3===o&&(i.rgb_color=be(e.readVarint()));return i}function Ee(e,t){const i={spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0};let o;for(;o=e.nextField(t);)1===o?i.transform=ge(e,e.readVarint()+e.pos):2===o?i.spread_method=e.readVarint():3===o?i.stops.push(Te(e,e.readVarint()+e.pos)):4===o?i.cx=e.readFloat():5===o?i.cy=e.readFloat():6===o?i.r=e.readFloat():7===o?i.fx=e.readFloat():8===o?i.fy=e.readFloat():9===o&&(i.fr=e.readFloat());return i}function Se(e,t){const i={children:[]};let o;for(;o=e.nextField(t);)1===o?i.transform=ge(e,e.readVarint()+e.pos):2===o?i.clip_path_idx=e.readVarint():3===o&&i.children.push(pe(e,e.readVarint()+e.pos));return i}function Ie(e,t){const i={left:0,width:20,mask_type:1,children:[]};let o;for(;o=e.nextField(t);)1===o?i.left=i.top=e.readFloat():2===o?i.width=i.height=e.readFloat():3===o?i.top=e.readFloat():4===o?i.height=e.readFloat():5===o?i.mask_type=e.readVarint():6===o?i.mask_idx=e.readVarint():7===o&&i.children.push(pe(e,e.readVarint()+e.pos));return null==i.height&&(i.height=i.width),null==i.top&&(i.top=i.left),i}class Ce{static calculate(t={},i=[]){const o=new Map,r=new Map;if(0===Object.keys(t).length)return o;i.forEach(t=>{r.set(t.name,t.rgb_color||new e.C(0,0,0));});for(const[e,i]of Object.entries(t))r.has(e)?o.set(r.get(e).toString(),i):console.warn(`Ignoring unknown image variable "${e}"`);return o}}function Re(t,i=255,o){const r=o.get(t.toString())||t;return 255===i?r.toString():new e.C(r.r,r.g,r.b,r.a*i/255).toString()}const De=[];let Ae=0;function Le(t,i){if(Ae>=De.length){const o=e.x()?new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0}):document.createElement("canvas").getContext("2d",{willReadFrequently:!0});De.push(o);}const o=De[Ae++];return o.canvas.width=t,o.canvas.height=i,o}function Pe(){Ae--;}function Oe(e,t,i,o,r){for(const n of o.children)Me(e,t,i,n,r);}function Me(e,t,i,o,r){o.group?(e.save(),function(e,t,i,o,r){const n=null!=o.mask_idx?i.masks[o.mask_idx]:null,s=null!=o.clip_path_idx?i.clip_paths[o.clip_path_idx]:null;if(o.transform&&(t=Ve(o.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(o,null!=s,null!=n))return void Oe(e,t,i,o,r);const a=Le(e.canvas.width,e.canvas.height);Oe(a,t,i,o,r),s&&je(a,t,i,s),n&&Ge(a,t,i,n,r),e.globalAlpha=o.opacity/255,e.drawImage(a.canvas,0,0),Pe();}(e,t,i,o.group,r),e.restore()):o.path&&(e.save(),function(e,t,i,o,r){e.setTransform(t),1===o.paint_order?(Fe(e,i,o,r),Be(e,i,o,r)):(Be(e,i,o,r),Fe(e,i,o,r));}(e,t,i,o.path,r),e.restore());}function Fe(e,t,i,o){const r=i.fill;if(!r)return;const n=r.opacity/255;switch(e.save(),e.beginPath(),qe(i,e),r.paint){case "rgb_color":e.fillStyle=Re(r.rgb_color,r.opacity,o);break;case "linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(Ve(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=ke(e,i,n,o);break}case "radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(Ve(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Ne(e,i,n,o);}}e.fill(ze(i)),e.restore();}function ze(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function Be(e,t,i,o){const r=i.stroke;if(!r)return;const n=He(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const s=r.opacity/255;switch(r.paint){case "rgb_color":e.strokeStyle=Re(r.rgb_color,r.opacity,o);break;case "linear_gradient_idx":e.strokeStyle=ke(e,t.linear_gradients[r.linear_gradient_idx],s,o,!0);break;case "radial_gradient_idx":e.strokeStyle=Ne(e,t.radial_gradients[r.radial_gradient_idx],s,o,!0);}switch(r.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel";}switch(r.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square";}e.stroke(n);}function ke(e,t,i,o,r=!1){if(1===t.stops.length){const e=t.stops[0];return Re(e.rgb_color,e.opacity*i,o)}const{x1:n,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(n,s),h=new DOMPoint(a,l);if(r){const e=Ve(t.transform);c=e.transformPoint(c),h=e.transformPoint(h);}const d=e.createLinearGradient(c.x,c.y,h.x,h.y);for(const e of t.stops)d.addColorStop(e.offset,Re(e.rgb_color,e.opacity*i,o));return d}function Ne(e,t,i,o,r=!1){if(1===t.stops.length){const e=t.stops[0];return Re(e.rgb_color,e.opacity*i,o)}const n=Ve(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:h,r:d}=t;let u=new DOMPoint(s,a),_=new DOMPoint(c,h),f=l,p=d;if(r){u=n.transformPoint(u),_=n.transformPoint(_);const e=(n.a+n.d)/2;f=l*e,p=t.r*e;}const m=e.createRadialGradient(u.x,u.y,f,_.x,_.y,p);for(const e of t.stops)m.addColorStop(e.offset,Re(e.rgb_color,e.opacity*i,o));return m}function Ue(e,t,i,o){const r=o.transform?Ve(o.transform).preMultiplySelf(t):t,n=Le(e.canvas.width,e.canvas.height);for(const e of o.children)if(e.group)Ue(n,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(He(t),r),n.fill(i,ze(t));}const s=null!=o.clip_path_idx?i.clip_paths[o.clip_path_idx]:null;s&&je(n,r,i,s),e.globalCompositeOperation="source-over",e.drawImage(n.canvas,0,0),Pe();}function je(e,t,i,o){const r=Le(e.canvas.width,e.canvas.height);Ue(r,t,i,o),e.globalCompositeOperation="destination-in",e.drawImage(r.canvas,0,0),Pe();}function Ge(e,t,i,o,r){if(0===o.children.length)return;const n=null!=o.mask_idx?i.masks[o.mask_idx]:null;n&&Ge(e,t,i,n,r);const s=e.canvas.width,a=e.canvas.height,l=Le(s,a),c=o.width,h=o.height,d=o.left,u=o.top,_=new Path2D,f=new Path2D;f.rect(d,u,c,h),_.addPath(f,t),l.clip(_);for(const e of o.children)Me(l,t,i,e,r);const p=l.getImageData(0,0,s,a),m=p.data;if(1===o.mask_type)for(let e=0;ee.I.from(t))}getImageVersions(e){return this.imageVersions.get(e)||new Map}getImages(e,t,i){const o=[],r=[],n=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){o.push(i);continue}const e=n.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i));}if(0===o.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of o)l.has(e.toString())||(s=!1);a||s?this._notify(o,t,i):this.requestors.push({ids:o,scope:t,callback:i});}rasterizeImages(e,t){const i=new Map,{iconTasks:o,patternTasks:r,scope:n}=e;for(const e of [o,r])for(const[t,o]of e.entries()){const e=this.getImage(o.id,n);e&&i.set(t,{image:e,imageVariant:o});}t(null,this._rasterizeImages(n,i));}_rasterizeImages(e,t){const i=new Map;for(const[o,{image:r,imageVariant:n}]of t.entries())i.set(o,this.imageRasterizer.rasterize(n,r,e,0));return i}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,o){const r=this.images.get(i),n=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.B("styleimagemissing",{id:i.name}));}const t=r.get(i.toString());if(!t){e.w(`Image "${i.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const o={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(o,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),n.set(e.I.toString(i),o);}o(null,{images:n,versions:this.getImageVersions(i)});}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return {width:t,height:i}}getPattern(t,i,o){const r=t.toString(),n=this.patterns.get(i),s=n.get(r),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.position.version=a.version;}else {if(a.usvg&&!a.data){const n=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(n))return null;this.patternsInFlight.add(n);const s=new e.D(t).scaleSelf(e.r.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]),c=this._rasterizeImages(i,l);return this.storePatternImage(s,i,a,o,c),null}this.storePattern(t,i,a);}return this._updatePatternAtlas(i,o),n.get(r).position}getPatternInFlightId(t,i){return e.y(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,o,r){const n=e.toString(),s=r?r.get(n):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,o),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)));}storePattern(t,i,o){const r={w:o.data.width+2*e.F,h:o.data.height+2*e.F,x:0,y:0},n=new e.G(r,o,e.F);this.patterns.get(i).set(t.toString(),{bin:r,position:n});}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear();}bind(t,i){const o=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.T(t,this.atlasImage.get(i),o.RGBA8),this.atlasTexture.set(i,r)),r.bind(o.LINEAR,o.CLAMP_TO_EDGE);}_updatePatternAtlas(t,i){const o=this.patterns.get(t),r=Array.from(o.values()).map(({bin:e})=>e),{w:n,h:s}=e.H(r),a=this.atlasImage.get(t);a.resize({width:n||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:r,position:n}]of o.entries()){let o=n.padding;const s=r.x+o,c=r.y+o,h=l.get(t).data,d=h.width,u=h.height;o=o>1?o-1:o,e.t.copy(h,a,{x:0,y:0},{x:s,y:c},{width:d,height:u},i),e.t.copy(h,a,{x:0,y:u-o},{x:s,y:c-o},{width:d,height:o},i),e.t.copy(h,a,{x:0,y:0},{x:s,y:c+u},{width:d,height:o},i),e.t.copy(h,a,{x:d-o,y:0},{x:s-o,y:c},{width:o,height:u},i),e.t.copy(h,a,{x:0,y:0},{x:s+d,y:c},{width:o,height:u},i),e.t.copy(h,a,{x:d-o,y:u-o},{x:s-o,y:c-o},{width:o,height:o},i),e.t.copy(h,a,{x:0,y:u-o},{x:s+d,y:c-o},{width:o,height:o},i),e.t.copy(h,a,{x:0,y:0},{x:s+d,y:c+u},{width:o,height:o},i),e.t.copy(h,a,{x:d-o,y:0},{x:s-o,y:c+u},{width:o,height:o},i);}this.dirty=!0;}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set);this.imageAtlasCache.beginFrame();}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const o of e){if(this.callbackDispatchedThisFrame.get(t).has(o.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(o.toString());const e=i.get(o.toString());ae(e)&&this.updateImage(o,t,e);}}}class $e{constructor(e,t,i,o){this.message=(e?`${e}: `:"")+i,o&&(this.identifier=o),null!=t&&t.__line__&&(this.line=t.__line__);}}class Xe extends $e{}function Ye(t){const i=t.value,o=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,a=t.arrayElementValidator||Tt;if(!Array.isArray(i))return [new $e(s,i,`array expected, ${e.M(i)} found`)];if(o.length&&i.length!==o.length)return [new $e(s,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.lengthe)return [new $e(i,o,`${o} is greater than the maximum value ${e}`)]}return []}function Qe(t){const i=t.key,o=t.value;if(!e.J(o))return [new $e(i,o,`object expected, ${e.M(o)} found`)];const r=t.valueSpec,n=e.K(o.type);let s,a,l,c={};const h="categorical"!==n&&void 0===o.property,d=!h,u=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.J(i[0][0])}(o),_=Et({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return [new $e(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(Ye({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:f})),Array.isArray(i)&&0===i.length&&t.push(new $e(e.key,i,"array must have at least one stop")),t},default:function(e){return Tt({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===n&&h&&_.push(new $e(t.key,t.value,'missing required property "property"')),"identity"===n||o.stops||_.push(new $e(t.key,t.value,'missing required property "stops"')),"exponential"===n&&r.expression&&!e.O(r)&&_.push(new $e(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(d&&!e.Q(r)?_.push(new $e(t.key,t.value,"property functions not supported")):h&&!e.S(r)&&_.push(new $e(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==o.property||_.push(new $e(t.key,t.value,'"property" property is required')),_;function f(t){let i=[];const o=t.value,n=t.key;if(!Array.isArray(o))return [new $e(n,o,`array expected, ${e.M(o)} found`)];if(2!==o.length)return [new $e(n,o,`array length 2 expected, length ${o.length} found`)];if(u){if(!e.J(o[0]))return [new $e(n,o,`object expected, ${e.M(o[0])} found`)];const r=o[0];if(void 0===r.zoom)return [new $e(n,o,"object stop key must have zoom")];if(void 0===r.value)return [new $e(n,o,"object stop key must have value")];const s=e.K(r.zoom);if("number"!=typeof s)return [new $e(n,r.zoom,"stop zoom values must be numbers")];if(l&&l>s)return [new $e(n,r.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(Et({key:`${n}[0]`,value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Ke,value:p}}));}else i=i.concat(p({key:`${n}[0]`,value:o[0],style:t.style,styleSpec:t.styleSpec},o));return e.U(e.V(o[1]))?i.concat([new $e(`${n}[1]`,o[1],"expressions are not allowed in function stops.")]):i.concat(Tt({key:`${n}[1]`,value:o[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function p(t,i){const o=e.M(t.value),l=e.K(t.value),h=null!==t.value?t.value:i;if(s){if(o!==s)return [new $e(t.key,h,`${o} stop domain type must match previous stop domain type ${s}`)]}else s=o;if("number"!==o&&"string"!==o&&"boolean"!==o&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new $e(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==n){let i=`number expected, ${o} found`;return e.Q(r)&&void 0===n&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new $e(t.key,h,i)]}return "categorical"!==n||"number"!==o||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===o&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew $e(`${t.key}${e.key}`,t.value,e.message));const o=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!o.outputDefined())return [new $e(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&&!e.Z(o))return [new $e(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return et(o,t);if("appearance"===t.expressionContext)return ot(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.X(o,["zoom","feature-state"]))return [new $e(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.Y(o))return [new $e(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function et(t,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const r=[];return t instanceof e._&&o.has(t.name)?[new $e(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...et(e,i));}),r)}const tt=new Set(["get","has","properties","geometry-type","id"]),it=new Set(["zoom","pitch","distance-from-center","feature","feature-state","measure-light","heatmap-density","line-progress","raster-value","raster-particle-speed","sky-radial-progress"]);function ot(t,i){if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)it.delete(e);if(0===it.size)return [];const o=[];if(t instanceof e._){const e=tt.has(t.name)?"feature":t.name;if(it.has(e))return [new $e(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]}return t.eachChild(e=>{o.push(...ot(e,i));}),o}function rt(t){const i=t.key,o=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?r.values.includes(e.K(o))||n.push(new $e(i,o,`expected one of [${r.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(r.values).includes(e.K(o))||n.push(new $e(i,o,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(o)} found`)),n}function nt(t){if(e.a1(e.V(t.value))){const e=t.layerType||"fill";return Je({...t,expressionContext:"filter",valueSpec:t.styleSpec[`filter_${e}`]})}return st(t)}function st(t){const i=t.value,o=t.key;if(!Array.isArray(i))return [new $e(o,i,`array expected, ${e.M(i)} found`)];if(i.length<1)return [new $e(o,i,"filter array must have at least 1 element")];const r=t.styleSpec;let n=rt({key:`${o}[0]`,value:i[0],valueSpec:r.filter_operator});const s=()=>{i.length>=2&&(e.a0(i[1])||n.push(new $e(`${o}[1]`,i[1],`string expected, ${e.M(i[1])} found`)));for(let t=2;t":case ">=":i.length>=2&&"$type"===e.K(i[1])&&n.push(new $e(o,i,`"$type" cannot be use with operator "${i[0]}"`)),3!==i.length&&n.push(new $e(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),s();break;case "==":case "!=":3!==i.length&&n.push(new $e(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),s();break;case "in":case "!in":s();break;case "any":case "all":case "none":for(let e=1;e{e in o&&i.push(new $e(r,o[e],`"${e}" is prohibited for ref layers`));}),n.layers.forEach(i=>{e.K(i.id)===l&&(t=i);}),t?t.ref?i.push(new $e(r,o.ref,"ref cannot reference another ref layer")):a=e.K(t.type):"string"==typeof l&&i.push(new $e(r,o.ref,`ref layer "${l}" not found`));}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(o.source)if(e.a0(o.source)){const t=n.sources&&Object.hasOwn(n.sources,o.source)?n.sources[o.source]:void 0,s=t&&e.K(t.type);t?"vector"===s&&"raster"===a?i.push(new $e(r,o.source,`layer "${o.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new $e(r,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==s||o["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new $e(r,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&o.paint&&o.paint["line-gradient"]&&"geojson"===s&&!t.lineMetrics?i.push(new $e(r,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"line"===a&&o.paint&&o.paint["line-trim-offset"]&&"geojson"===s&&!t.lineMetrics?i.push(new $e(r,o,`layer "${o.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new $e(r,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new $e(r,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new $e(r,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new $e(r,o.source,`source "${o.source}" not found`));}else i.push(new $e(`${r}.source`,o.source,'"source" must be a string'));else i.push(new $e(r,o,'missing required property "source"'));return i=i.concat(Et({key:r,value:o,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Tt({key:`${r}.type`,value:o.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:e=>nt({layerType:a,...e}),layout:e=>Et({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ht({layerType:a,...e})}}),paint:e=>Et({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ct({layerType:a,layer:o,...e})}}),appearances(t){const i=Ye({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:o,layerType:r}=t,n=e.K(t.value),s=e.K(n.name),a=e.K(n.condition),l=Et({key:i,value:n,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...Je({key:t.key,value:t.object.condition,valueSpec:e.m.appearance.condition,expressionContext:"appearance"})),i}({...t}),properties:e=>function(e){const t=[],{styleSpec:i,layer:o,layerType:r}=e,n=i[`paint_${r}`],s=i[`layout_${r}`],a=e.object[e.objectKey];for(const i in a){const l=i in n?"paint":i in s?"layout":void 0;if(!l){t.push(new $e(e.key,i,`unknown property "${i}" for layer type "${r}"`));continue}const c={...e,key:`${e.key}.${i}`,objectKey:i,layer:o,layerType:r,value:a[i],valueSpec:"paint"===l?n[i]:s[i]};t.push(...lt(c,l));}return t}({layer:o,layerType:r,...e})}});return "hidden"!==s&&void 0===a&&l.push(new $e(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}({layerType:a,layer:o,...t})}),r=Array.isArray(t.value)?t.value:[],n=new Set;return r.forEach((r,s)=>{const a=e.K(r.name);if(a)if(n.has(a)){const r=e.K(o.id);i.push(new $e(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`));}else n.add(a);}),i}}})),i}function ut({key:t,value:i}){return e.a0(i)?[]:[new $e(t,i,`string expected, ${e.M(i)} found`)]}const _t={promoteId:function t({key:i,value:o}){if(e.a0(o))return ut({key:i,value:o});if(Array.isArray(o)){const t=[],r=e.V(o),n=e.n(r);return "error"===n.result?(n.value.forEach(e=>{t.push(new $e(`${i}${e.key}`,null,`${e.message}`));}),t):(e.X(n.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new $e(`${i}`,null,"promoteId expression should be only feature dependent")),t)}if(!e.J(o))return [new $e(i,o,`string, expression or object expected, "${e.M(o)}" found`)];const r=[];for(const e in o)r.push(...t({key:`${i}.${e}`,value:o[e]}));return r}};function ft(t){const i=t.value,o=t.key,r=t.styleSpec,n=t.style;if(!e.J(i))return [new $e(o,i,`object expected, ${e.M(i)} found`)];if(!("type"in i))return [new $e(o,i,'"type" is required')];const s=e.K(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new Xe(o,i,'Either "url" or "tiles" is required.'))),s){case "vector":case "raster":case "raster-dem":case "raster-array":return a=a.concat(Et({key:o,value:i,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:_t})),a;case "geojson":if(a=Et({key:o,value:i,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:_t}),"cluster"in i&&"clusterProperties"in i){if(!e.J(i.clusterProperties))return [new $e(`${o}.clusterProperties`,i,`object expected, ${e.M(i)} found`)];for(const e in i.clusterProperties){const t=i.clusterProperties[e];if(!Array.isArray(t))return [new $e(`${o}.clusterProperties.${e}`,t,"array expected")];const[r,n]=t,s="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...Je({key:`${o}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...Je({key:`${o}.${e}.reduce`,value:s,expressionContext:"cluster-reduce"}));}}return a;case "video":return Et({key:o,value:i,valueSpec:r.source_video,style:n,styleSpec:r});case "image":return Et({key:o,value:i,valueSpec:r.source_image,style:n,styleSpec:r});case "canvas":return [new $e(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return rt({key:`${o}.type`,value:i.type,valueSpec:{values:pt(r)}})}}function pt(e){return e.source.reduce((t,i)=>{const o=e[i];return "enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values||{}))),t},[])}function mt(e,t){const i=!e.includes("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return !1}}function gt(t){const i=t.value;return i?e.a0(i)?mt(i,!0)?[]:[new $e(t.key,i,`invalid url "${i}"`)]:[new $e(t.key,i,`string expected, "${e.M(i)}" found`)]:[]}function vt(t){const i=t.value,o=t.styleSpec,r=o.light,n=t.style;if(void 0===i)return [];if(!e.J(i))return [new $e("light",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(e.a3),l=t.match(e.a2);s=s.concat(l&&r[l[1]]?Tt({key:t,value:i[t],valueSpec:{type:"string"},style:n,styleSpec:o}):a&&r[a[1]]&&r[a[1]].transition?Tt({key:t,value:i[t],valueSpec:o.transition,style:n,styleSpec:o}):r[t]?Tt({key:t,value:i[t],valueSpec:r[t],style:n,styleSpec:o}):[new $e(t,i[t],`unknown property "${t}"`)]);}return s}function yt(t){const i=t.value;if(!i)return [];const o=t.key;if(!e.J(i))return [new $e(o,i,`object expected, ${e.M(i)} found`)];let r=[];const n=t.styleSpec,s=n["light-3d"],a=t.style,l=t.style.lights;for(const e of ["type","id"])if(!(e in i))return r=r.concat([new $e(o,i,`missing property "${e}"`)]),r;if(!e.a0(i.type))return r=r.concat([new $e(`${o}.type`,i.type,"string expected")]),r;if(l)for(let n=0;n[],array:Ye,boolean:function(t){const i=t.value,o=t.key;return e.$(i)?[]:[new $e(o,i,`boolean expected, ${e.M(i)} found`)]},number:Ke,color:function({key:t,value:i}){return e.a0(i)?void 0===e.C.parse(e.K(i))?[new $e(t,i,`color expected, "${i}" found`)]:[]:[new $e(t,i,`color expected, ${e.M(i)} found`)]},enum:rt,filter:nt,function:Qe,layer:dt,object:Et,source:ft,model:gt,light:vt,"light-3d":yt,terrain:xt,fog:bt,string:ut,formatted:function(e){return 0===ut(e).length?[]:Je(e)},resolvedImage:function(e){return 0===ut(e).length?[]:Je(e)},projection:function(t){const i=t.value,o=t.styleSpec,r=o.projection,n=t.style;if(e.J(i)){let e=[];for(const t in i)e=e.concat(Tt({key:t,value:i[t],valueSpec:r[t],style:n,styleSpec:o}));return e}return e.a0(i)?[]:[new $e("projection",i,`object or string expected, ${e.M(i)} found`)]},import:function(t){const i=t.key,{value:o,styleSpec:r}=t;if(!e.J(o))return [new $e(i,o,"import must be an object")];const{data:n,...s}=o;Object.defineProperty(s,"__line__",{value:o.__line__,enumerable:!1});let a=Et({...t,value:s,valueSpec:r.import});""===e.K(s.id)&&a.push(new $e(`${t.key}.id`,s,"import id can't be an empty string"));const l=e.K(s.id);return "__proto__"!==l&&"constructor"!==l&&"prototype"!==l||a.push(new $e(`${t.key}.id`,s,`import id can't be "${String(l)}"`)),n&&(a=a.concat(It(n,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,o=t.key,r=t.styleSpec,n=t.style;if(!e.J(i))return [new $e(o,i,"object expected")];if(!i.type)return [new $e(o,i,'"type" is required')];const s=e.K(i.type);let a=[];if(a=a.concat(Et({key:o,value:i,valueSpec:r[`iconset_${s}`],style:n,styleSpec:r})),function(e,t){return !("source"!==e||!t.source)}(s,i)){const t=n.sources&&Object.hasOwn(n.sources,i.source)?n.sources[i.source]:void 0,r=t&&e.K(t.type);t?"raster-array"!==r&&a.push(new $e(o,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new $e(o,i.source,`source "${i.source}" not found`));}return a},option:function(t){const i=t.styleSpec,o=t.value,r=e.J(o)&&!0===e.K(o.array)||!e.J(o)?void 0:e.K(o.type);return Et({...t,valueSpec:i.option,objectElementValidators:r?{default:e=>Array.isArray(e.value)?Tt({...e,valueSpec:{...e.valueSpec,type:r}}):Tt(e)}:void 0})}};function Tt(t,i=!1){const o=t.value,r=t.valueSpec,n=t.styleSpec;if(r.expression){if(e.a4(e.K(o)))return Qe(t);if(e.U(e.V(o)))return Je(t)}if(r.type&&wt[r.type]){const e=wt[r.type](t);return !0===i&&e.length>0&&Array.isArray(t.value)?Je(t):e}return Et({...t,valueSpec:r.type?n[r.type]:r})}function Et(t){const i=t.key,o=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.J(o))return [new $e(i,o,`object expected, ${e.M(o)} found`)];let l=[];for(const e in o){if(!Object.hasOwn(o,e))continue;const t=e.split(".")[0],c=Object.hasOwn(r,t),h=Object.hasOwn(r,"*"),d=c?r[t]:h?r["*"]:void 0;let u;Object.hasOwn(n,t)?u=n[t]:c?u=Tt:Object.hasOwn(n,"*")?u=n["*"]:h&&(u=Tt),u?l=l.concat(u({key:(i?`${i}.`:i)+e,value:o[e],valueSpec:d,style:s,styleSpec:a,object:o,objectKey:e},o)):l.push(new Xe(i,o[e],`unknown property "${e}"`));}for(const e in r){if(!Object.hasOwn(r,e))continue;if(Object.hasOwn(n,e))continue;const t=r[e];!t.required||void 0!==t.default||Object.hasOwn(o,e)&&void 0!==o[e]||l.push(new $e(i,o,`missing required property "${e}"`));}return l}function St({key:e,value:t}){const i=ut({key:e,value:t});if(i.length)return i;const o=t;return o.includes("{fontstack}")||i.push(new $e(e,t,'"glyphs" url must include a "{fontstack}" token')),o.includes("{range}")||i.push(new $e(e,t,'"glyphs" url must include a "{range}" token')),i}function It(t,i=e.m,o={}){return Et({key:o.key||"",value:t,valueSpec:{...i.$root,"*":{type:"*"}},styleSpec:i,style:t,objectElementValidators:{glyphs:St}})}function Ct(t,i=e.m){return Ut(It(t,i))}const Rt=e=>Ut(ft(e)),Dt=e=>Ut(vt(e)),At=e=>Ut(yt(e)),Lt=e=>Ut(xt(e)),Pt=e=>Ut(bt(e)),Ot=t=>Ut(function(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.snow;if(void 0===i)return [];if(!e.J(i))return [new $e("snow",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(e.a3);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Tt({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Tt({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new Xe(t,i[t],`unknown property "${t}"`)]);}return s}(t)),Mt=t=>Ut(function(t){const i=t.value,o=t.style,r=t.styleSpec,n=r.rain;if(void 0===i)return [];if(!e.J(i))return [new $e("rain",i,`object expected, ${e.M(i)} found`)];let s=[];for(const t in i){const a=t.match(e.a3);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Tt({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Tt({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new Xe(t,i[t],`unknown property "${t}"`)]);}return s}(t)),Ft=e=>Ut(dt(e)),zt=e=>Ut(nt(e)),Bt=e=>Ut(ct(e)),kt=e=>Ut(ht(e)),Nt=e=>Ut(gt(e));function Ut(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function jt(t,i){let o=!1;if(i&&i.length)for(const r of i)r instanceof Xe?e.w(r.message):(t.fire(new e.A(new Error(r.message))),o=!0);return o}const Gt=e.m.light;let Vt;class qt extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a6(Vt||(Vt=new e.a7({anchor:new e.a8(Gt.anchor),position:new e.a9(Gt.position),color:new e.a8(Gt.color),intensity:new e.a8(Gt.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Dt,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&jt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.m}))}}const Ht=e.m.terrain;let Zt=class extends e.E{constructor(t,i,o,r,n){super(),this.scope=o,this._transitionable=new e.a6(new e.a7({source:new e.a8(Ht.source),exaggeration:new e.a8(Ht.exaggeration)}),o,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=n;}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.aa(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let o=-1,r=-1,n=1;for(const t of i.zoomStops)n=i.evaluate(new e.aa(t,{worldview:this.worldview})),n>.01?(o=t,r=-1):r=t;return n<.01&&o>0&&r>o?[o,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ab}};function Wt(e,t){const i=e?e.terrain:null;return !!i&&(!t||!!t.projection.requiresDraping||!i.isZoomDependent()||i.getExaggeration(t.zoom)>0)}const $t=.05;function Xt(t,i,o){const r=e.af(45,65,o),[n,s]=t.range;let a=1-Math.min(1,Math.exp((i-n)/(s-n)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*r*t.alpha}function Yt(t,i,o,r,n){const s=e.ad([],[i,o,r],n.mercatorFogMatrix);return Xt(t,e.ae(s),n.pitch)}function Kt(t,i,o,r,n,s,a){const l=[[o,r,0],[n,r,0],[n,s,0],[o,s,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.ad([],t,i),r=e.ae(o);c=Math.min(c,r),h=Math.max(h,r);}return [Xt(t,c,a.pitch),Xt(t,h,a.pitch)]}const Qt=e.m.fog;class Jt extends e.E{constructor(t,i,o,r){super();const n=new e.a7({range:new e.a8(Qt.range),color:new e.a8(Qt.color),"color-use-theme":new e.a8({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.a8(Qt["high-color"]),"high-color-use-theme":new e.a8({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.a8(Qt["space-color"]),"space-color-use-theme":new e.a8({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.a8(Qt["horizon-blend"]),"star-intensity":new e.a8(Qt["star-intensity"]),"vertical-range":new e.a8(Qt["vertical-range"])});this._transitionable=new e.a6(n,o,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ag(n),this.scope=o;}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.ah(t.zoom),r=this.properties.get("range"),n=[2,4.5],s=.5/Math.tan(.5*t._fov),a=[r[0]+s,r[1]+s];return {range:i?[e.ai(n[0],a[0],o),e.ai(n[1],a[1],o)]:a,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Pt,e,i))return;const o={...e};for(const e of Object.keys(Qt))void 0===o[e]&&(o[e]=Qt[e].default);this._options=o,this._transitionable.setTransitionOrValue(this._options,t);}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:e.af(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const r=e.ac.fromLngLat(i),n=o.elevation?o.elevation.getAtPointOrZero(r):0;return Yt(t,r.x,r.y,n,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Kt(this.state,i,0,0,e.aj,e.aj,this._transform)}getOpacityForBounds(e,t,i,o,r){return this._transform.projection.supportsFog?Kt(this.state,e,t,i,o,r,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let r;if(i[2]>=0)r=i;else {const n=t.points[o-4];r=e.ak(n,i,n[2]/(n[2]-i[2]));}if(Yt(this.state,r[0],r[1],0,this._transform)>=$t)return !0}return !1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&jt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.m}))}}let ei,ti,ii=class extends e.E{constructor(t,i,o,r){super();const n=ei||(ei=new e.a7({density:new e.a8(e.m.snow.density),intensity:new e.a8(e.m.snow.intensity),color:new e.a8(e.m.snow.color),opacity:new e.a8(e.m.snow.opacity),vignette:new e.a8(e.m.snow.vignette),"vignette-color":new e.a8(e.m.snow["vignette-color"]),"center-thinning":new e.a8(e.m.snow["center-thinning"]),direction:new e.a8(e.m.snow.direction),"flake-size":new e.a8(e.m.snow["flake-size"])}));this._transitionable=new e.a6(n,o,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ag(n),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),r=e.al(o[0]),n=-Math.max(e.al(o[1]),.01),s=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color"),c=new e.C(l.r,l.g,l.b,a);return {density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.C(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:c}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Ot,t,o))return;const r={...t},n=e.m.snow;for(const e of Object.keys(n))void 0===r[e]&&(r[e]=n[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&jt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.m}))}},oi=class extends e.E{constructor(t,i,o,r){super();const n=ti||(ti=new e.a7({density:new e.a8(e.m.rain.density),intensity:new e.a8(e.m.rain.intensity),color:new e.a8(e.m.rain.color),opacity:new e.a8(e.m.rain.opacity),vignette:new e.a8(e.m.rain.vignette),"vignette-color":new e.a8(e.m.rain["vignette-color"]),"center-thinning":new e.a8(e.m.rain["center-thinning"]),direction:new e.a8(e.m.rain.direction),"droplet-size":new e.a8(e.m.rain["droplet-size"]),"distortion-strength":new e.a8(e.m.rain["distortion-strength"])}));this._transitionable=new e.a6(n,o,r),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ag(n),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),r=e.al(o[0]),n=-Math.max(e.al(o[1]),.01),s=[Math.cos(r)*Math.cos(n),Math.sin(r)*Math.cos(n),Math.sin(n)],a=this.properties.get("vignette-color"),l=new e.C(a.r,a.g,a.b,this.properties.get("vignette"));return {density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.C(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Mt,t,o))return;const r={...t},n=e.m.rain;for(const e of Object.keys(n))void 0===r[e]&&(r[e]=n[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(t,i,o){return (!o||!1!==o.validate)&&jt(this,t.call(Ct,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.m}))}};const ri={workerUrl:"",workerClass:null,workerParams:void 0};function ni(e){return null!=ri.workerClass?new ri.workerClass:new self.Worker(ri.workerUrl,{name:e,type:"module",...ri.workerParams})}const si="mapboxgl_preloaded_worker_pool";class ai{constructor(e){this.active={},this.name=e;}acquire(e,t=ai.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate();}),this.workers=null);}isPreloaded(){return !!this.active[si]}numActive(){return Object.keys(this.active).length}}ai.workerCount=2;class li{constructor(t,i,o="Worker",r=ai.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.am();const n=this.workerPool.acquire(this.id,r);for(let e=0;e{this.ready=!0;}).catch(()=>{});}send(e,t,i){return Promise.all(this.actors.map(o=>o.send(e,t,i)))}broadcast(e,t){for(const i of this.actors)i.notify(e,t);}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove();}),this.actors=[],this.workerPool.release(this.id);}}li.Actor=e.an;class ci extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._options=t,this.properties=new e.ag(i),this._transitionable=new e.a6(i,o,r),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,e);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}let hi;const di=()=>hi||(hi=new e.a7({color:new e.a8(e.m.properties_light_ambient.color),"color-use-theme":new e.a8({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.a8(e.m.properties_light_ambient.intensity)}));let ui;const _i=()=>ui||(ui=new e.a7({direction:new e.ao(e.m.properties_light_directional.direction),color:new e.a8(e.m.properties_light_directional.color),"color-use-theme":new e.a8({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.a8(e.m.properties_light_directional.intensity),"cast-shadows":new e.a8(e.m.properties_light_directional["cast-shadows"]),"shadow-quality":new e.a8(e.m.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.a8(e.m.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new e.a8(e.m.properties_light_directional["shadow-draw-before-layer"])})),fi=(e,t,i,o,r,n,s,a,l,c=[0,0,1])=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:o,u_camera_pos:r,u_tile_to_meter:n,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l,u_front_cutoff_params:c}),pi=e=>({u_matrix:e}),mi=e=>({u_matrix:e}),gi=1029,vi=2305;class yi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}yi.disabled=new yi(!1,gi,vi),yi.backCCW=new yi(!0,gi,vi),yi.backCW=new yi(!0,gi,2304),yi.frontCW=new yi(!0,1028,2304),yi.frontCCW=new yi(!0,1028,vi);class xi{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}xi.ReadOnly=!1,xi.ReadWrite=!0,xi.disabled=new xi(519,xi.ReadOnly,[0,1]);class bi{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.ai(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.ai(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.ai(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.ai(t.right,i.right,o)),this}getCenter(t,i){const o=e.as((this.left+t-this.right)/2,0,t),r=e.as((this.top+i-this.bottom)/2,0,i);return new e.P(o,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new bi(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function wi(t,i){const o=e.aD(t,3);e.aI(t,i),e.aN(t,3,o);}function Ti(t,i){const o=e.az([]);return e.aA(o,o,-i),e.aB(o,o,-t),o}function Ei(t,i){const o=[t[0],t[1],0],r=[i[0],i[1],0];if(e.ae(o)>=1e-15){const t=e.au([],o);e.av(r,t,e.aw(r,t)),i[0]=r[0],i[1]=r[1];}const n=e.ax([],i,t);if(e.ay(n)<1e-15)return null;const s=Math.atan2(-n[1],n[0]);return Ti(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class Si{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ac?t:new e.ac(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.at(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i,o){if(this.orientation=null,!this.position)return;const r=this.position,n=o||(this._elevation?this._elevation.getAtPointOrZero(e.ac.fromLngLat(t)):0),s=e.ac.fromLngLat(t,n),a=[s.x-r.x,s.y-r.y,s.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Ei(a,i);}setPitchBearing(t,i){this.orientation=Ti(e.al(t),e.al(-i));}}class Ii{constructor(t,i){this._transform=e.aC([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.ac(t[0],t[1],t[2])}get position(){const t=e.aD(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.aN(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.az([]),t&&wi(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Ti(e,t),wi(this._transform,this._orientation);}forward(){const t=e.aD(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.aD(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.aD(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.aE(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const r=this.position;e.av(r,r,-t);const n=new Float64Array(16);return e.aF(n,[o,o,o]),e.aG(n,n,r),n[10]*=i,n}getWorldToCamera(t,i){const o=new Float64Array(16),r=new Float64Array(4),n=this.position;return e.aH(r,this._orientation),e.av(n,n,-t),e.aI(o,r),e.aG(o,o,n),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,r){const n=new Float64Array(16);return e.aJ(n,t,i,o,r),n}getCameraToClipOrthographic(t,i,o,r,n,s){const a=new Float64Array(16);return e.aK(a,t,i,o,r,n,s),a}getDistanceToElevation(t,i=!1){const o=0===t?0:e.aL(t,i?e.aM(this.position[1]):this.position[1]),r=this.forward();return (o-this.position[2])/r[2]}clone(){return new Ii([...this.position],[...this.orientation])}}const Ci=Math.tan(85*Math.PI/180);function Ri(t,i,o,r,n,s,a){const l=e.aS();if(o)if("globe"===s.name){const t=e.aT(n,i);e.aP(l,l,t);}else {const t=e.aU([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.aR(l,l,n.angle);}else e.aP(l,n.labelPlaneMatrix,t);return l}function Di(e,t,i,o,r,n,s){const a=Ri(e,t,i,o,r,n,s);return "globe"===n.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function Ai(t,i,o,r,n,s,a){if(o){if("globe"===s.name){const l=Ri(t,i,o,r,n,s,a);return e.aE(l,l),e.aP(l,t,l),l}{const i=e.aQ(t),[o,s,l,c]=a,[h,d,u,_,f,p,m,g]=i;return i[0]=o*h+s*f,i[1]=o*d+s*p,i[2]=o*u+s*m,i[3]=o*_+s*g,i[4]=l*h+c*f,i[5]=l*d+c*p,i[6]=l*u+c*m,i[7]=l*_+c*g,r||e.aR(i,i,-n.angle),i}}return n.glCoordMatrix}function Li(t,i,o,r){const n=[t,i,o,1];o?e.aO(n,n,r):Vi(n,n,r);const s=n[3];return n[0]/=s,n[1]/=s,n[2]/=s,n}function Pi(e,t){return Math.min(.5+e/t*.5,1.5)}function Oi(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function Mi(t,i,o,r,n,s,a,l,c,h,d=1){const u=o.transform,_=r?t.textSizeData:t.iconSizeData,f=e.aZ(_,o.transform.zoom,d),p="globe"===u.projection.name,m=(()=>{if(!p)return null;const t=e.ah(u.zoom);return 0===t?null:{t,invMatrix:u.projection.createInversionMatrix(u,h.canonical),mercCenter:[e.a_(u.center.lng),e.a$(u.center.lat)]}})(),g=[256/o.width*2+1,256/o.height*2+1],v=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;v.clear();let y=null;p&&(y=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const x=t.lineVertexArray,b=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=o.transform.width/o.transform.height;let T,E=!1;for(let d=0;dMath.abs(o)?{useVertical:!0}:t===e.b0.vertical?r>0?{needsFlipping:!0}:null:0!==i&&function(e,t){return 0===e||Math.abs(t/e)>Ci}(o,r)?1===i?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Bi(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y,x,b){const w=i/24,T=t.lineOffsetX*w,E=t.lineOffsetY*w,{lineStartIndex:S,glyphStartIndex:I,numGlyphs:C,segment:R,writingMode:D,flipState:A}=t,L=S+t.lineLength,P=t=>{if(d){const[i,o,r]=t.up,n=h.length;e.b2(d,n+0,i,o,r),e.b2(d,n+1,i,o,r),e.b2(d,n+2,i,o,r),e.b2(d,n+3,i,o,r);}const[i,o,r]=t.point;e.b3(h,i,o,r,t.angle);};if(C>1){const e=Fi(w,l,T,E,o,u,_,t,c,s,f,m,!1,g,v,y,x,b);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[n,s,l]=e.last.point;[i,o]=Li(i,o,r,a),[n,s]=Li(n,s,l,a);const c=zi(D,A,(n-i)*p,s-o);if(t.flipState=c&&c.needsFlipping?1:2,c)return c}P(e.first);for(let e=I+1;e0?s:Ui(_,r,i,1,n,void 0,g,v.canonical),l=zi(D,A,(a[0]-i[0])*p,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=ji(w*l.getoffsetX(I),T,E,o,u,_,R,S,L,c,s,f,m,!1,!1,g,v,y,x,b);if(!i)return {notEnoughRoom:!0};P(i);}return {}}function ki(t,i,o){const r=1<0?1:-1,T=0;r&&(w*=-1,T=Math.PI),w<0&&(T+=Math.PI);let E=l+a+(w>0?0:1)|0,S=n,I=n,C=0,R=0;const D=Math.abs(b),A=[],L=[];let P=s,O=P,M=e.aV([]);const F=()=>Ui(O,P,I,D-C+1,d,_,m,g.canonical,x);for(;C+R<=D;){if(E+=w,E=c)return null;if(I=S,O=P,A.push(I),f&&L.push(O),P=new e.P(h.getx(E),h.gety(E)),S=u[E],!S){const e=Ni(P,g.canonical,d,m,_,x);S=e[3]>0?u[E]=e:F();}C+=R;const t=e.aW([],S,I),i=e.aX(I,S);if(o&&i>0&&R>0&&e.aw(M,t)/(R*i)0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e);}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let r=0,n=0;for(let s=0;s{const a=e.bq(i,t,o,r,s);l.has(a)||(n.push(new e.br(t,i,o,r,s)),l.add(a));};for(let e=0;en.canonical.z)continue;const l=n.canonical,h=n.overscaledZ,d=n.wrap,u=1<0,p=l.y+10,g=n.wrap-(f?0:1),v=n.wrap+(_?0:1),y=f?l.x-1:u-1,x=_?l.x+1:0;if(s)o[0]<0?(c(h,v,l.z,x,l.y),o[1]<0&&p&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))):o[0]>0?(c(h,g,l.z,y,l.y),o[1]<0&&p&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))):o[1]<0&&p?c(h,d,l.z,l.x,l.y+1):m&&c(h,d,l.z,l.x,l.y-1);else {const e=n.visibleQuadrants;1&e&&(c(h,g,l.z,y,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))),2&e&&(c(h,v,l.z,x,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))),4&e&&(c(h,g,l.z,y,l.y),p&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1))),8&e&&(c(h,v,l.z,x,l.y),p&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)));}}const h=[];for(const e of n)n.some(t=>e.isChildOf(t))||h.push(e);if(n=h.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-o[0],i=e.canonical.y+.5-o[1];return t*t+i*i{const l=e.bq(i,t,o,s,a);n.has(l)||(r.push(new e.br(t,i,o,s,a)),n.add(l));},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),o),l=1<{const r=Math.floor(t[0]),n=Math.floor(t[1]),u=(t[0]-r)*e.aj,_=(t[1]-n)*e.aj,f=Math.floor(i[0]),p=Math.floor(i[1]),m=(i[0]-f)*e.aj,g=(i[1]-p)*e.aj;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){h.x=u-t*e.aj,d.x=m-(i-f)*e.aj;for(let t=-1;t<=1;t++){const r=n+t;h.y=_-t*e.aj,d.y=g-(r-p)*e.aj,e.bT(h,d,c)&&s(a,0,o,i,r);}}}},_=i.points,f=_[e.be],p=_[e.bf],m=this._projectToGround(f,_[e.bg]),g=this._projectToGround(p,_[e.bh]);return u(f,m),u(p,g),r}_projectToGround(t,i){return e.bi(e.bj(),t,i,t[2]/(t[2]-i[2]))}_projectToZ(t,i,o){const r=t[2]-i[2];return Math.abs(r)<1e-6?e.bk(t):e.bi(e.bj(),t,i,(t[2]-o)/r)}extendTileCoverForTunnels(t,i,o,r){if(o<18)return [];const n=i.points,s=n[e.bl],a=n[e.bm],l=n[e.bn],c=n[e.bo];if(l[2]>=0&&c[2]>=0||s[2]<=0||a[2]<=0)return [];const h=l[2]<0?this._projectToZ(s,l,0):l,d=c[2]<0?this._projectToZ(a,c,0):c,u=-r,_=l[2]3&&(p.length=3),p}_findExtensionTilesInQuad(t,i,o,r){const n=[],s=new Set;for(const e of t)s.add(e.key);const a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),i),l=1<{const i=e.canonical.x+.5-w,o=e.canonical.y+.5-T,r=t.canonical.x+.5-w,n=t.canonical.y+.5-T;return i*i+o*o-(r*r+n*n)||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y}),n}coveringTiles(t){let i=this.coveringZoomLevel(t);const o=i,r=this.elevation&&this.elevation.exaggeration(),n=r&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,o=new e.ac(t.x+i,t.y,t.z),r=new e.ac(t.x,t.y+i,t.z),n=t.toLngLat(),s=o.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(n),c=this.locationCoordinate(s),h=this.locationCoordinate(a),d=Math.hypot(c.x-l.x,c.y-l.y),u=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(d*u)*T/i},S=t=>{const i=b,o=w;return {aabb:e.bw(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},I=[];let C=[];const R=i,D=t.reparseOverscaled?o:i,A=(m-this._centerAltitude)*p,L=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=O(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},P=(e,t)=>{if(.707*t{if(t.zoom=.9)return !0}else if(n&&(a=t.aabb.distanceZ(g)*p),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.ac((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!s&&!d){const e=Math.sqrt(i*i+r*r+a*a);let o=(1<0;){const o=I.pop(),r=o.x,a=o.y;let l=o.fullyVisible;const u=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<n)continue;let s=0;if(!l){let i=v?o.aabb.intersectsPrecise(_):o.aabb.intersectsPreciseFlat(_);if(0===i&&u()){const t=new e.bu(o.zoom,r,a);i=e.bv(this,c,t,!0).intersectsPrecise(_);}if(0===i)continue;if(t.calculateQuadrantVisibility)if(_.containsPoint(o.aabb.center))s=15;else for(let e=0;e<4;e++)0!==o.aabb.quadrant(e).intersects(_)&&(s|=1<>1),u={aabb:s?o.aabb.quadrant(t):e.bw(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};n&&!d&&(u.tileID=new e.br(o.zoom+1===R?D:o.zoom+1,o.wrap,o.zoom+1,i,h),L(u)),I.push(u);}}if(this.fogCullDistSq){const i=this.fogCullDistSq,o=this.horizonLineFromTop();C=C.filter(r=>{const n=[0,0,0,1],s=[e.aj,e.aj,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aO(n,n,a),e.aO(s,s,a);const l=e.bx([],n,s),c=e.by([],n,s),h=e.bV(l,c);if(0===h)return !0;let d=!1;const u=this._elevation;if(u&&h>i&&0!==o){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;t.isTerrainDEM||(n=u.getMinMaxForTile(r.tileID)),n||(n={min:w,max:b});const s=e.bz(this.rotation),a=[s[0]*e.aj,s[1]*e.aj,n.max];e.ad(a,a,i),d=(1-a[1])*this.height*.5e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(t){const i=e.as(t.lat,-e.bA,e.bA),o=this.projection.project(t.lng,i);return new e.P(o.x*this.worldSize,o.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.aL(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;o=(i.x-n.x)/e,r=(i.y-n.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(n);o=e.x-t.x,r=e.y-t.y;}const s=this.locationCoordinate(t);this.setLocation(new e.ac(s.x-o,s.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const o=i?e.aL(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ac(r.x,r.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],n=[t.x,t.y,1,1];e.aO(r,r,this.pixelMatrixInverse),e.aO(n,n,this.pixelMatrixInverse);const s=n[3];e.bB(r,r,1/r[3]),e.bB(n,n,1/s);const a=r[2],l=n[2];return {p0:r,p1:n,t:a===l?0:(o-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.aO(i,i,this.pixelMatrixInverse),e.aO(o,o,this.pixelMatrixInverse),e.bB(i,i,1/i[3]),e.bB(o,o,1/o[3]),i[2]=e.aL(i[2],this._center.lat)*this.worldSize,o[2]=e.aL(o[2],this._center.lat)*this.worldSize,e.bB(i,i,1/this.worldSize),e.bB(o,o,1/this.worldSize),new e.bC([i[0],i[1],i[2]],e.au([],e.aW([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:r}=t,n=e.aL(i[2],this._center.lat),s=e.aL(o[2],this._center.lat);return new e.ac(e.ai(i[0],o[0],r)/this.worldSize,e.ai(i[1],o[1],r)/this.worldSize,e.ai(n,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let o=this.projection.pointCoordinate3D(this,t.x,t.y);if(o)return new e.ac(o[0],o[1],o[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t,i);const s=.02*n,a=t.clone();for(let t=0;t<10&&n-r>s;t++){a.y=e.ai(r,n,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(n=a.y,o=t):r=a.y;}return o?new e.ac(o[0],o[1],o[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return !1;if(this.elevation||this.zoom>=e.bD)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.aO(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,n=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(n.lng,s.lng,a.lng,l.lng),h=Math.max(n.lng,s.lng,a.lng,l.lng),d=Math.min(n.lat,s.lat,a.lat,l.lat),u=Math.max(n.lat,s.lat,a.lat,l.lat);const _=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,p=(t,i,o,r,n)=>{const s=(t+o)/2,a=(i+r)/2,l=new e.P(s,a),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,d-g,m-h,g-u);c=Math.min(c,m),h=Math.max(h,m),d=Math.min(d,g),u=Math.max(u,g),(n_)&&(p(t,i,s,a,n+1),p(s,a,o,r,n+1));};if(p(i,t,r,t,1),p(r,t,r,o,1),p(r,o,i,o,1),p(i,o,i,t,1),"globe"===this.projection.name){const[t,i]=e.bE(this);t?(u=90,h=180,c=-180):i&&(d=-90,h=180,c=-180);}return new e.bF(new e.b4(c,d),new e.b4(h,u))}_getBoundsRectangular(t,i){const{top:o,left:r}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(r,o),l=new e.P(s,o),c=new e.P(s,n),h=new e.P(r,n);let d=this.pointCoordinate(a,t),u=this.pointCoordinate(l,t);const _=this.pointCoordinate(c,i),f=this.pointCoordinate(h,i),p=(e,t)=>(t.y-e.y)/(t.x-e.x);return d.y>1&&u.y>=0?d=new e.ac((1-f.y)/p(f,d)+f.x,1):d.y<0&&u.y<=1&&(d=new e.ac(-f.y/p(f,d)+f.x,0)),u.y>1&&d.y>=0?u=new e.ac((1-_.y)/p(_,u)+_.x,1):u.y<0&&d.y<=1&&(u=new e.ac(-_.y/p(_,u)+_.x,0)),(new e.bF).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(_))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bA,this.maxLat=e.bA,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngd&&(a=d-c),d-ht&&(s=t-l),t-e{for(let n=0;n<16;n++)t[n]=e.ai(i[n],o[n],r);})(a,a,l,e.bW(this.pitch>=qi?1:this.pitch/qi));}else a=l;const c=e.bI([],l,s),h=e.bI([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center);e.aC(this._mat4Scratch);const i=this._mat4Scratch;e.aG(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aP(i,i,e.bJ(this)),e.aG(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aP(h,h,i),e.aP(c,c,i),this.inverseAdjustmentMatrix=e.bK(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(e.bL(this.mercatorMatrix,h,[this.worldSize,this.worldSize,this.worldSize/n,1]),this.projMatrix=h,e.aE(this.invProjMatrix,this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,e.bI(this._expandedFarZProjMatrixBuf,i,s),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf;}else this.expandedFarZProjMatrix=this.projMatrix;e.aE(this._mat4Scratch,a),this.frustumCorners=e.bM.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bs.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i),e.aF(this.skyboxMatrix,[1,-1,1]),e.bN(this.skyboxMatrix,this.skyboxMatrix,this._pitch),e.aR(this.skyboxMatrix,this.skyboxMatrix,this.angle),e.aJ(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);const d=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;e.bO(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-t.x/this.width,this._mat4Scratch[9]=2*(t.y+d)/this.height,e.aP(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);const u=this.point,_=u.x,f=u.y,p=this.width%2/2,m=this.height%2/2,g=Math.cos(this.angle),v=Math.sin(this.angle),y=_-Math.round(_)+g*p+v*m,x=f-Math.round(f)+g*m+v*p;if(e.bO(this.alignedProjMatrix,h),e.aG(this.alignedProjMatrix,this.alignedProjMatrix,[y>.5?y-1:y,x>.5?x-1:x,0]),e.aF(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),e.aG(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),e.aF(this.glCoordMatrix,[1,-1,1]),e.aG(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),e.bL(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),e.aP(this.pixelMatrix,this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},!e.aE(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if("globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bP(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.ad(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[t,t,i];e.av(n,n,r),e.av(o,o,-1),e.bQ(o,o,n),e.bR(this.mercatorFogMatrix,o),e.bL(this.mercatorFogMatrix,this.mercatorFogMatrix,n),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*r,o.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=this._camera.position[2],r=t[2];let n=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(n=Math.min((i-o)/r,1)),this._camera.position=e.aY([],this._camera.position,t,n),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:r}=this._camera.getPitchBearing(),n=e.aL(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.al(this._maxPitch)),a=Math.max((t[2]-n)/Math.cos(o),s),l=this._zoomFromMercatorZ(a);e.aY(t,t,i,a),this._pitch=e.as(o,e.al(this.minPitch),e.al(this.maxPitch)),this.angle=e.at(r,-Math.PI,Math.PI),this._setZoom(e.as(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ac(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.bD,r=0,n=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.bS(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.ae(e.aW([],this._camera.position,t)),r=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,o],r){const n=[t,i,o,1];e.aO(n,n,r);const s=n[3]=Math.max(n[3],1e-6);return n[0]/=s,n[1]/=s,n[2]/=s,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,o=this.worldSize){const r=e.bH(t,i,this.width,this.height,1024),n=t.pixelSpaceConversion(this.center.lat,o,r);let s=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(s=e.ai(1,s,e.bW(this.pitch>=qi?1:this.pitch/qi))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.aP(t,t,this.globeMatrix),t}getFrustum(t){return e.bs.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const Zi=(t,i)=>{if(i<=0||t.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=t.transform,r=o.pitch,n=o.isLODDisabled(!1)?60:30;if(r0,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(d-o._nearZ)/s,(d-u-o._nearZ)/s]}}},Wi=7680;class $i{constructor(e,t,i,o,r,n){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=r,this.pass=n;}}$i.disabled=new $i({func:519,mask:0},0,0,Wi,Wi,Wi);const Xi=new Float32Array(16);function Yi(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y,x,b){const w=i.context,T=w.gl,E=i.transform,S=i.transform.zoom,I=[],C=t.translate,R=t.translateAnchor,D=t.edgeRadius,A=Zi(i,t.cutoffFadeRange);"clear"===d?(I.push("CLEAR_SUBPASS"),x&&(I.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE))):"sdf"===d?I.push("SDF_SUBPASS"):"emissive"===d&&(I.push("USE_MRT1"),w.activeTexture.set(T.TEXTURE0),x.bind(T.LINEAR,T.CLAMP_TO_EDGE)),v&&I.push("HAS_CENTROID"),A.shouldRenderCutoff&&I.push("RENDER_CUTOFF");const L=(e,t,o,n,d)=>{let y=I;null!=t.groundRadiusBuffer&&(y=I.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),T=i.isTileAffectedByFog(e),E=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:T}),C=((e,t,i,o,r,n,s,a,l,c)=>({u_matrix:e,u_opacity:t,u_ao_pass:i?1:0,u_meter_to_tile:o,u_ao:r,u_flood_light_intensity:n,u_flood_light_color:s,u_attenuation:a,u_edge_radius:l,u_fb:0,u_fb_size:c,u_dynamic_offset:1}))(n,u,h,d,[_,f*d],p,m,g,S>=17?0:D*d,x?x.size[0]:0),R=[];v&&R.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&R.push(t.groundRadiusBuffer),i.uploadCommonUniforms(w,E,e.toUnwrapped(),null,A),E.draw(i,w.gl.TRIANGLES,s,a,l,c,C,r.id,t.vertexBuffer,t.indexBuffer,o,r.paint,S,b,R);};for(const t of n){const n=o.getTile(t),s=n.getBucket(r);if(!s||s.projection.name!==E.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,n,C,R),o=a.getDefaultSegment();L(t,a,o,e,l);}if(y)for(let s=0;s<4;s++){const a=e.c0[s](t),c=o.getTile(a);if(!c)continue;const h=c.getBucket(r);if(!h||h.projection.name!==E.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const d=h.groundEffect;let u,_;0===s?(u=[-e.aj,0,0],_=1):1===s?(u=[e.aj,0,0],_=0):2===s?(u=[0,-e.aj,0],_=3):(u=[0,e.aj,0],_=2);const f=d.regionSegments[_];f&&(e.aG(Xi,t.projMatrix,u),L(t,d,f,i.translatePosMatrix(Xi,n,C,R),l));}}}const Ki=770,Qi=771;class Ji{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=o;}}function eo(t,i,o=0){const r=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=n*(i.tileID.canonical.x+i.tileID.wrap*r),a=n*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.c1(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:o}}Ji.Replace=[1,0,1,0],Ji.disabled=new Ji(Ji.Replace,e.C.transparent,[!1,!1,!1,!1]),Ji.unblended=new Ji(Ji.Replace,e.C.transparent,[!0,!0,!0,!0]),Ji.alphaBlended=new Ji([1,Qi,1,Qi],e.C.transparent,[!0,!0,!0,!0]),Ji.alphaBlendedNonPremultiplied=new Ji([Ki,Qi,Ki,Qi],e.C.transparent,[!0,!0,!0,!0]),Ji.multiply=new Ji([774,0,774,0],e.C.transparent,[!0,!0,!0,!0]),Ji.multiplyAccumulateAlpha=new Ji([774,0,1,Qi],e.C.transparent,[!0,!0,!0,!0]),Ji.additive=new Ji([1,1,1,1],e.C.transparent,[!0,!0,!0,!0]),Ji.additiveAlphaWeighted=new Ji([Ki,1,773,1],e.C.transparent,[!0,!0,!0,!0]),Ji.additiveAlphaWeightedUnboundedAlpha=new Ji([Ki,1,1,1],e.C.transparent,[!0,!0,!0,!0]);const to={terrain:0,flat:1},io=e.aS(),oo=[0,0,0],ro=(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y=[0,0,1],x=!1)=>{let b=oo,w=0,T=oo;if(!x){const t=i.style.light,o=t.properties.get("position");if(b=[o.x,o.y,o.z],"viewport"===t.properties.get("anchor")){const t=e.c2();e.c3(t,-i.transform.angle),e.c4(b,b,t);}const r=t.properties.get("color").toPremultipliedRenderColor(null);w=t.properties.get("intensity"),T=[r.r,r.g,r.b];}const E=i.transform,S={u_matrix:t,u_lightpos:b,u_lightintensity:w,u_lightcolor:T,u_vertical_gradient:+o,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:io,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:to[h],u_base_type:to[d],u_ao:n,u_edge_radius:s,u_width_scale:a,u_flood_light_color:p,u_vertical_scale:m,u_flood_light_intensity:g,u_ground_shadow_factor:v,u_front_cutoff_params:y};return "globe"===E.projection.name&&(S.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:o,u_height_type:to[r],u_base_type:to[n]}),so=(e,t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v=!1)=>{const y=ro(e,t,i,o,r,n,s,a,c,h,d,u,_,f,p,m,1,[0,0,0],[0,0,1],v),x={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(y,eo(t,l,g),x)};function ao(t){const i=t.properties.get("direction"),o=e.c5(i.x,i.y,i.z);o[2]=e.as(o[2],0,75);const r=e.c8([o[0],o[1],o[2]]);return e.c6(r.x,r.y,r.z)}function lo(t,i,o){const r="none"===i.properties.get("color-use-theme"),n=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===o.properties.get("color-use-theme"),h=o.properties.get("color"),d=o.properties.get("intensity"),u=Math.max(e.aw([0,0,1],l),0),_=[0,0,0];e.av(_,h.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),d);const f=[0,0,0];return e.av(f,n.toPremultipliedRenderColor(r?null:t.getLut(o.scope)).toArray01Linear().slice(0,3),u*s),e.c7([_[0]>0?_[0]/(_[0]+f[0]):0,_[1]>0?_[1]/(_[1]+f[1]):0,_[2]>0?_[2]/(_[2]+f[2]):0])}const co=new Float32Array(e.aC([])),ho=[0,0,0],uo=(t,i,o,r,n,s,a,l,c,h,d,u,_,f=[0,0,0],p,m,g,v=1,y=!1)=>{let x=ho,b=0,w=ho;if(!y){const t=n.style.light,i=t.properties.get("position");if(x=[-i.x,-i.y,i.z],"viewport"===t.properties.get("anchor")){const t=e.c2();e.c3(t,-n.transform.angle),e.c4(x,x,t);}const o=t.properties.get("color").toNonPremultipliedRenderColor(null);b=t.properties.get("intensity"),w=[o.r,o.g,o.b];}const T="MASK"===d.alphaMode,E=_.paint.get("model-ambient-occlusion-intensity"),S=_.paint.get("model-color").constantOr(e.C.white).toNonPremultipliedRenderColor(null);return S.a=_.paint.get("model-color-mix-intensity").constantOr(0),g&&(S.r=g[0],S.g=g[1],S.b=g[2],S.a=g[3]),m&&(S.r=m.color.r,S.g=m.color.g,S.b=m.color.b,S.a=m.colorMix,u=m.emissionStrength,s*=m.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:r||co,u_lightpos:x,u_lightintensity:b,u_lightcolor:w,u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+T,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:S.toArray01(),u_aoIntensity:E,u_emissive_strength:u,u_occlusionTextureTransform:p||[0,0,0,0],u_dithered_discard_threshold:v}},_o=(e,t=co,i=co)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),fo=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),po=new Float64Array(16),mo=new Float64Array(16),go=new Float64Array(16),vo=new Float64Array(16),yo=new Float64Array(16),xo=new Float64Array(16),bo=new Float64Array(16),wo=[0,0,0],To=new Float32Array(16),Eo=[0,0,0],So=[0,0,0],Io=[];function Co(t,i,o){const r=o.cameraWorldSizeForFog/o.worldSize;return e.bL(t,o.worldToFogMatrix,[r,r,1]),e.aP(t,t,i),t}function Ro(t,i,o,r){return e.aG(t,i,o),e.b9(r,e.cu)||e.bL(t,t,r),t}function Do(t,i,o,r,n){const s=o.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:d,emissionTexture:u}=s;function _(e,i,o){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+o),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:o,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,o,r);}}_(l,"HAS_TEXTURE_u_baseColorTexture",5),_(c,"HAS_TEXTURE_u_metallicRoughnessTexture",6),_(h,"HAS_TEXTURE_u_normalTexture",7),_(d,"HAS_TEXTURE_u_occlusionTexture",8),_(u,"HAS_TEXTURE_u_emissionTexture",9),n&&(n.texture||(n.texture=new e.ct(r.context,n.image,[n.image.height,n.image.height,n.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+10),n.texture&&n.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(o.texcoordBuffer)),o.colorBuffer&&(t.push(12===o.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(o.colorBuffer)),o.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(o.normalBuffer)),o.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(o.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const f=r.shadowRenderer;f&&(t.push("RENDER_SHADOWS"),f.useNormalOffset&&t.push("NORMAL_OFFSET"));}function Ao(t,i,o,r,n,s){const a=t.modelOpacity,l=i.context,c=new xi(i.context.gl.LEQUAL,t.isLightMesh?xi.ReadOnly:xi.ReadWrite,i.depthRangeFor3D),h=i.transform,d=t.mesh,u=d.material,_=u.pbrMetallicRoughness,f=i.style.fog;"pixels"===i.transform.projection.zAxisUnit?po.set(t.nodeModelMatrix):e.aP(po,r.zScaleMatrix,t.nodeModelMatrix),e.aP(po,r.negCameraPosMatrix,po),e.aE(mo,po),e.cl(mo,mo);const p="none"===o.paint.get("model-color-use-theme").constantOr("default"),m=o.paint.get("model-emissive-strength").constantOr(0),g={defines:[]},v=[],y=i.shadowRenderer;y&&(y.useNormalOffset=!1),Do(g.defines,v,d,i,p?null:o.lut);let x=null;if(f&&(x=Co(go,t.nodeModelMatrix,i.transform),"globe"!==h.projection.name)){const e=d.aabb.min,t=d.aabb.max,[i,o]=f.getOpacityForBounds(x,e[0],e[1],t[0],t[1]);g.overrideFog=i>=$t||o>=$t;}const b=Zi(i,o.paint.get("model-cutoff-fade-range"));b.shouldRenderCutoff&&g.defines.push("RENDER_CUTOFF");const w=i.getOrCreateProgram("model",g),T=uo(t.worldViewProjection,po,mo,null,i,a,_.baseColorFactor,u.emissiveFactor,_.metallicFactor,_.roughnessFactor,u,m,o,void 0,void 0,t.materialOverride,t.modelColor,1,w.fixedDefines.includes("LIGHTING_3D_MODE"));i.uploadCommonUniforms(l,w,null,x,b,t.lightOverrides),"shadow"!==i.renderPass&&y&&y.setupShadowsFromMatrix(t.nodeModelMatrix,w),w.draw(i,l.gl.TRIANGLES,c,n,s,d.material.doubleSided?yi.disabled:yi.backCCW,T,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,i.transform.zoom,void 0,v);}function Lo(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function Po(t,i,o,r,n,s,a,l,c,h,d){const u=t.transform,_=!!i.isGeometryBloom&&i.isGeometryBloom;if(void 0!==i.minZoom&&t.transform.zoomi.maxZoom)return;if(_&&"shadow"===t.renderPass)return;const f="globe"===u.projection.name?e.cj(o,u):[...o];e.aP(f,f,i.globalMatrix);const p=e.aP([],r,f);if(i.meshes)for(const t of i.meshes){const r=l.get(t.material.name);if(r&&r.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:n,worldViewProjection:p,nodeModelMatrix:f,isLightMesh:_,materialOverride:r,modelOpacity:c,modelColor:h,lightOverrides:d,node:i,modelMatrix:o});continue}const m=e.ad([],t.centroid,p);!u.isOrthographic&&m[2]<=0||s.push({mesh:t,depth:m[2],modelIndex:n,worldViewProjection:p,nodeModelMatrix:f,isLightMesh:_,materialOverride:r,modelOpacity:c,modelColor:h,lightOverrides:d,node:i,modelMatrix:o});}if(i.children)for(const e of i.children)Po(t,e,o,r,n,s,a,l,c,h,d);}function Oo(e,t,i,o,r){const n=i.shadowRenderer;if(!n)return;const s=n.getShadowPassDepthMode(),a=r||n.calculateShadowPassMatrixFromMatrix(t),l=_o(a);i.getOrCreateProgram("modelDepth").draw(i,i.context.gl.TRIANGLES,s,$i.disabled,Ji.disabled,yi.disabled,l,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function Mo(t,i,o,r){const n=function(t,i){if(i.footprintDebugMesh)return i.footprintDebugMesh;if(!i.footprint)return null;const o=t.context,r=i.footprint.vertices,n=i.footprint.indices,s=new e.co;s.reserve(r.length);for(const e of r)s.emplaceBack(e.x,e.y);const a=new e.cp;a.reserve(n.length);for(let e=0;e0){const i=t.terrain,n=i.findDEMTileFor(o);n&&n.dem?r=e.cs.create(i,o,n):a=0;}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return !1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eh&&(h=e.max);}const d=e.as(r.x,s,a)-r.x,u=e.as(r.y,l,c)-r.y,_=e.aL(h,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(d*d+u*u+_*_))}function jo(e,t,i,o,r,n,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new xi(a.gl.LEQUAL,xi.ReadWrite,e.depthRangeFor3D),d=e.isTileAffectedByFog(n),u="globe"===e.transform.projection.name;if(i.meshes)for(const _ of i.meshes){const f=u?[]:["MODEL_POSITION_ON_GPU"],p=[];let m,g,v;const y=!u&&o.instancedDataArray.length>20;y&&f.push("INSTANCED_ARRAYS");const x=Zi(e,t.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:f}),g=_o(s.shadowTileMatrix,s.shadowTileMatrix,i.globalMatrix),v=Ji.disabled;else {Do(f,p,_,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),m=e.getOrCreateProgram("model",{defines:f,overrideFog:d});const o=_.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity").constantOr(1),u=t.paint.get("model-emissive-strength").constantOr(0);g=uo(n.expandedProjMatrix,i.globalMatrix,To,null,e,h,l.baseColorFactor,o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,u,t,r,void 0,void 0,void 0,1,m.fixedDefines.includes("LIGHTING_3D_MODE")),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(n.toUnwrapped(),m,"model-tile"),s.shadowUniformsInitialized=!0)),v=x.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?Ji.alphaBlended:Ji.unblended;}e.uploadCommonUniforms(a,m,n.toUnwrapped(),null,x);const b=_.material.doubleSided?yi.disabled:yi.backCCW;if(y)p.push(o.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,$i.disabled,v,b,g,t.id,_.vertexBuffer,_.indexBuffer,_.segments,t.paint,e.transform.zoom,void 0,p,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let r=0;r0)if(t.targetLod<0)t.targetLod=i>r?1:0;else {const s=n>0?o/1e3/n:1;t.targetLod=e.as(i>r?t.targetLod+s:t.targetLod-s,0,1);}else t.targetLod=0;}function Vo(t,i,o,r){if(!o.modelManager)return !0;const n=o.modelManager;if(!o.shadowRenderer)return !0;const s=o.shadowRenderer,a=i.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const i in t.instancesPerModel){const t=n.getModel(i,r);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1;}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c);}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.ad(a.min,a.min,i.tileMatrix),e.ad(a.max,a.max,i.tileMatrix);const h=a.intersects(s.getCurrentCascadeFrustum());return 0===o.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===h),0===h}function qo(t,i){const o=t.uniformValues.u_cutoff_params[0],r=t.uniformValues.u_cutoff_params[1],n=t.uniformValues.u_cutoff_params[2],s=t.uniformValues.u_cutoff_params[3];return r===o||s===n?1:e.as(((i-o)/(r-o)-n)/(s-n),0,1)}function Ho(t,i,o,r){if(i.pitch<20)return 1;const n=i.getWorldToCameraMatrix();e.aP(n,n,t);const s=e.cv(o.min[0],o.min[1],o.min[2],1);let a=e.aO(e.cw(),s,n),l=a,c=a;s[1]=o.max[1],a=e.aO(e.cw(),s,n),l=a[1]c[1]?a:c,s[0]=o.max[0],a=e.aO(e.cw(),s,n),l=a[1]c[1]?a:c,s[1]=o.min[1],a=e.aO(e.cw(),s,n),l=a[1]c[1]?a:c;const h=e.as(r[0],0,1),d=100*i.pixelsPerMeter*e.as(r[1],0,1),u=e.as(r[2],0,1),_=e.cx(e.cw(),l,c,h),f=Math.tan(.5*i.fovX),p=-_[2]*f;if(0===d)return _[1]<-Math.abs(p)?u:1;const m=(-Math.abs(p)-_[1])/d,g=e.as(e.ai(1,u,m),u,1);return e.ai(1,g,e.as((i.pitch-20)/20,0,1))}var Zo="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Wo="\n#if defined(VIEWPORT_ORIGIN_TOP_LEFT) || defined(FLIP_Y)\n#define FLIP_VIEWPORT_UV_Y(uv) (uv).y=1.0-(uv).y\n#else\n#define FLIP_VIEWPORT_UV_Y(uv)\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#elif defined(FLOAT_RENDER_TARGET)\nlayout(location=0) out highp vec4 glFragColor;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp float depth=ndc_z;\n#else\nhighp float depth=ndc_z*0.5+0.5;\n#endif\nconst highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}const float DITHER_THRESHOLDS[16]=float[16](\n1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0\n);int viewport_dither_index(vec2 fragCoordXY) {return (int(fragCoordXY.x) % 4)*4+(int(fragCoordXY.y) % 4);}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}",$o="\n#define EXTENT 8192.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\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);}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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)\n{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Xo="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",Yo="\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;\n#endif\nvec3 elevationVector(vec2 pos) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 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\nreturn vec3(0,0,1);\n#endif\n}\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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;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 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*texture(u_dem,pos).r;\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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;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*texture(u_dem_prev,pos).r;\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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return 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;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#endif\nfloat elevation(vec2 apos) {\n#ifdef TERRAIN\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);\n#else\nreturn currentElevation(apos);\n#endif\n#else\nreturn 0.0;\n#endif\n}\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",Ko="#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;out 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",Qo="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in 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;FLIP_VIEWPORT_UV_Y(uv);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 opacity_limit) {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,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Jo="\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif",er="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",tr="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif",ir="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp vec2 shadow_map_ndc_to_uv(highp vec2 ndc_xy) {\n#ifdef SHADOW_MAP_FLIP_Y\nreturn ndc_xy*vec2(0.5,-0.5)+0.5;\n#else\nreturn ndc_xy*0.5+0.5;\n#endif\n}highp vec3 shadow_map_ndc_to_sample_space(highp vec3 ndc) {\n#ifdef CLIP_ZERO_TO_ONE\nreturn vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z);\n#else\nreturn vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z*0.5+0.5);\n#endif\n}float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z-bias);\n#else\nhighp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=shadow_map_ndc_to_sample_space(light_view_pos0.xyz/light_view_pos0.w);highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const or=/^#include\s+"([^"]+)"\s*\r?\n/gm,rr=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,nr=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,sr=new Set(["ifdef","ifndef","elif","if","defined"]),ar=new Set;gr(Zo,ar),gr($o,ar),gr(Wo,ar);const lr={"_prelude_fog.vertex.glsl":Ko,"_prelude_terrain.vertex.glsl":Yo,"_prelude_shadow.vertex.glsl":tr,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":Qo,"_prelude_shadow.fragment.glsl":ir,"_prelude_lighting.glsl":Jo,"_prelude_raster_array.glsl":er,"_prelude_indicator_cutout.fragment.glsl":"\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}float cutoutGroundRoofOpacity(vec4 groundRoof) {\n#ifdef INDICATOR_CUTOUT\nfloat fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);\n#else\nreturn 1.0;\n#endif\n}","_prelude_feature_cutout.fragment.glsl":"// feature cutout (gl-native only)\n","_prelude_feature_cutout.vertex.glsl":"// feature cutout (gl-native only)\n"},cr={},hr="precision highp float;",dr="precision mediump float;",ur="\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif",_r={preludeTerrain:yr("",Yo),preludeFog:yr(Qo,Ko),preludeShadow:yr(ir,tr),preludeRasterArray:yr(er,""),preludeLighting:yr(Jo,Jo),preludePrecisionQualifiers:yr(dr,hr),prelude:yr(Wo,$o),preludeExtensions:yr(ur,"")},fr=[ur,dr,Zo,_r.prelude.fragmentSource].join("\n"),pr=[hr,Zo,_r.prelude.vertexSource].join("\n");var mr={background:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef FEATURE_CUTOUT\nvec2 uv=fragcoord_to_viewport_uv(gl_FragCoord.xy,u_inv_viewport_size.xy);float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);\n#else\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifndef FEATURE_CUTOUT\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\n}'),backgroundPattern:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),circle:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void 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 blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\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;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\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.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),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() {\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 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nsurface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,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)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;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);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);\n#endif\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\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();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;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:yr("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:yr('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_intensity;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\nout 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() {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(vec2(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(vec2(a_pos)*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=vec3(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=vec3(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;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=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:yr("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:yr("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_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+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}'),collisionCircle:yr("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));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=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:yr("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);\n#endif\n}'),fill:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fillOutlinePattern:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillPattern:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),lineBlendComposite:yr("uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;\n#define ADDITIVE 1\nvoid main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:yr("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,h);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;\n#endif\nuniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\nout vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;\n#else\nh=t > 0.0 ? height : base;\n#endif\npos=vec3(pos_nx.xy,h);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);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 cutoff=1.0;vec3 scaled_pos=pos;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);\n#endif\n#ifdef RENDER_CUTOFF\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);\n#endif\n#endif\n}'),fillExtrusionPattern:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;in ivec4 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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(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\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.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=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),hillshadePrepare:yr("precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}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+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=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+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos.y=1.0-v_pos.y;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),line:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform highp float u_floor_width_scale;in vec2 v_tex;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 v_elevation_id_col;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec3 v_uv;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nuniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform bool u_emissive_in_shadows;uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);float pxStep;float delta;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\npxStep=fwidth(dist);float out_edge=v_width2_dilute.x-dist;float in_edge=dist-(v_width2_dilute.y-2.0*ANTIALIASING);delta=v_width2_dilute.y > 0.0 ? min(in_edge,out_edge) : out_edge;float edge=ANTIALIASING;alpha=delta > 0.0 ? smoothstep(edge-pxStep,u_width_scale*blur+edge+pxStep,delta) : 0.0;\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=ANTIALIASING/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edge2=border_width*u_width_scale+ANTIALIASING;float alpha2=smoothstep(edge2-pxStep,edge2+pxStep,delta);if (alpha2 < 1.) {if (border_color.a==0.0) {\n#ifndef RENDER_LINE_GRADIENT\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-alpha2));} else {out_color.rgb*=(0.6+0.4*alpha2);}\n#else\nout_color.rgb*=(0.6+0.4*alpha2);\n#endif\n} else {out_color=mix(border_color*trim_alpha,out_color,alpha2);}out_color*=v_width2_dilute.w;}\n#endif\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef LINE_BLEND_ADDITIVE\n{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}\n#else\n#ifdef LINE_BLEND_MULTIPLY\nglFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);\n#else\nglFragColor=out_color;\n#endif\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef DEBUG_ELEVATION_ID\nglFragColor=vec4(v_elevation_id_col,1.0);\n#endif\nif (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) || defined(VARIABLE_LINE_EMISSIVE_STRENGTH)\nin vec4 a_z_offset_width;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 a_elevation_id_col;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nout vec3 v_elevation_id_col;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin 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;uniform float u_width_scale;uniform float u_z_offset;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform highp float u_floor_width_scale;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nout highp vec3 v_uv;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(\n2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2\n);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\n#ifdef VARIABLE_LINE_EMISSIVE_STRENGTH\nemissive_strength=a_z_offset_width.w;\n#endif\nfloat a_z_offset=u_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset+=a_z_offset_width.x;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nv_elevation_id_col=a_elevation_id_col;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\nvec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;\n#ifdef RENDER_LINE_CURVE\nCurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;float symmetric_outset=0.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=u_width_scale*(left ? left_width : right_width);if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=apply;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;symmetric_outset=zero_right_width ? u_width_scale*left_width : halfwidth;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth > 0.0 ? ANTIALIASING : 0.0);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);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\nv_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\nv_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else\n{\n#ifdef RENDER_LINE_BORDER\nfloat border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);\n#endif\n}}\n#endif\n#endif\nv_tile_pos=(v_tile_pos+extrude)/EXTENT;\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\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=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nvec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef VARIABLE_LINE_WIDTH\nv_width2_dilute.x=symmetric_outset;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity*u_opacity_multiplier);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec4 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#endif\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=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;in uvec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nfloat tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=vec2(a_pos);\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=vec2(a_texture_pos)/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef ELEVATED\nfloat z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbol:yr('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;\n#ifdef RENDER_TEXT_AND_SYMBOL\nuniform sampler2D u_texture_icon;\n#endif\nuniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_sdf;uniform lowp float u_scale_factor;uniform lowp float u_opacity_multiplier;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin lowp float v_opacity;in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;\n#ifdef LIGHTING_3D_MODE\nin lowp float v_emissive_strength;\n#endif\nvoid main() {lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;if (u_is_sdf) {fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;}lowp float emissive_strength=0.0;\n#ifdef LIGHTING_3D_MODE\nemissive_strength=v_emissive_strength;\n#endif\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity*u_opacity_multiplier;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nif (u_is_sdf) {float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;} else {\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n}out_color*=opacity*fade_opacity*u_opacity_multiplier;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,0.0);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin uvec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\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;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_inv_matrix;\n#endif\nuniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_up_vector;\n#endif\n#ifdef RENDER_TEXT_AND_SYMBOL\nuniform vec2 u_texsize_icon;\n#endif\nuniform bool u_is_halo;\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\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifndef MAX_UBO_SIZE_VEC4\n#define MAX_UBO_SIZE_VEC4 1024u\n#endif\n#define SPP_HEADER_SIZE_VEC4 3u\n#define DWORDS_PER_VEC4 4u\nstruct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;float zoomFactor;bool hasAppearanceZoomStops;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;uniform highp float u_spp_fill_color_zoom_factor;uniform highp float u_spp_halo_color_zoom_factor;uniform highp float u_spp_opacity_zoom_factor;uniform highp float u_spp_halo_width_zoom_factor;uniform highp float u_spp_halo_blur_zoom_factor;uniform highp float u_spp_emissive_strength_zoom_factor;uniform highp float u_spp_occlusion_opacity_zoom_factor;uniform highp float u_spp_z_offset_zoom_factor;uniform highp float u_spp_translate_zoom_factor;uniform highp float u_spp_zoom_fraction;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;\n#ifdef LIGHTING_3D_MODE\nout lowp float v_emissive_strength;\n#endif\nPropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint appearanceZoomStopsMask,uint offsetDwords,float zoomFactor) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;type.zoomFactor=zoomFactor;type.hasAppearanceZoomStops=(appearanceZoomStopsMask & (1u << propertyIndex)) !=0u;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask =u_spp_header.header[0][0];uint zoomMask =u_spp_header.header[0][1];uint zoomDependentMask =zoomMask & 0xFFFFu;uint appearanceZoomStopsMask =zoomMask >> 16u;header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[0][3],u_spp_fill_color_zoom_factor);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][0],u_spp_halo_color_zoom_factor);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][1],u_spp_opacity_zoom_factor);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][2],u_spp_halo_width_zoom_factor);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][3],u_spp_halo_blur_zoom_factor);header.emissive_strength=getPropertyType(5u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][0],u_spp_emissive_strength_zoom_factor);header.occlusion_opacity=getPropertyType(6u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][1],u_spp_occlusion_opacity_zoom_factor);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][2],u_spp_z_offset_zoom_factor);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][3],u_spp_translate_zoom_factor);return header;}float appearanceZoomStopsFactor(float zm,float zM) {if (zm==zM) {return u_spp_zoom_fraction >=zm ? 1.0 : 0.0;}return clamp((u_spp_zoom_fraction-zm)/(zM-zm),0.0,1.0);}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);}uint readUint(uvec4 slot,uint offset) {return uvec4At(slot,offset % DWORDS_PER_VEC4);}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {float t=propertyType.zoomFactor;if (propertyType.hasAppearanceZoomStops) {vec4 zoomRange=readVec4(blockOffsetVec4,propertyType.offsetDwords+4u);t=appearanceZoomStopsFactor(zoomRange.x,zoomRange.y);}color=unpack_mix_color(color,t);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {float t=propertyType.zoomFactor;if (propertyType.hasAppearanceZoomStops) {vec4 zoomRange=readVec4(blockOffsetVec4,propertyType.offsetDwords+4u);t=appearanceZoomStopsFactor(zoomRange.x,zoomRange.y);}return mix(slot.xy,slot.zw,t);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);float t=propertyType.hasAppearanceZoomStops\n? appearanceZoomStopsFactor(readFloat(slot,propertyType.offsetDwords+2u),readFloat(slot,propertyType.offsetDwords+3u))\n: propertyType.zoomFactor;value=unpack_mix_vec2(packedValues,t);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;}vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;\n#ifdef LIGHTING_3D_MODE\nv_emissive_strength=paint_properties.emissive_strength;\n#endif\nlowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); \n#endif\n#else\nprojected_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 TERRAIN\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\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\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);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(\nu_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y\n);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=vec2(a_texb)/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos0.y=1.0-v_pos0.y;\n#endif\ngl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:yr("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:yr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Xo),skyboxGradient:yr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Xo),skyboxCapture:yr("\nin 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;precision highp float;\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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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;\n#ifndef VIEWPORT_ORIGIN_TOP_LEFT\nv_position.y*=-1.0;\n#endif\nv_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:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform float u_far_z_cutoff;in 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() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;FLIP_VIEWPORT_UV_Y(uv);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 norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;\n#ifndef GLOBE_POLES\nuniform mat4 u_merc_matrix;\n#endif\nuniform float u_zoom_transition;uniform vec2 u_merc_center;\n#ifndef GLOBE_POLES\nuniform mat3 u_grid_matrix;\n#endif\nuniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos0.y=1.0-v_pos0.y;\n#endif\nvec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:yr('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));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\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat 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);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 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=c2;glFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in 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;out highp vec3 v_ray_dir;out 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);}"),stars:yr("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),occlusion:yr("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function gr(e,t){const i=e.split("\n");for(let e of i){if(e=e.trimStart(),"#"!==e[0])continue;if(!e.includes("if"))continue;if(e.startsWith("#endif"))continue;const i=e.match(nr);if(i)for(const e of i)sr.has(e)||t.add(e);}}function vr(e){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(e)}function yr(e,t){const i=new Set,o=[],r=[];e=e.replace(or,(e,t)=>(r.push(t),"")),t=t.replace(or,(e,t)=>(o.push(t),""));let n=new Set(ar);gr(e,n),gr(t,n);for(const e of [...o,...r])cr[e]||(cr[e]=new Set,gr(lr[e],cr[e])),n=new Set([...n,...cr[e]]);return {fragmentSource:e=e.replace(rr,(e,t,o,r,n)=>(i.add(n),"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\n${vr(r)?"flat ":""}in ${o} ${r} ${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${o} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${o} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(rr,(e,t,o,r,n)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${n}`,a="float"===r?"vec2":r,l=`GET_ATTRIBUTE_${a}(a_${n}, materialInfo, ${s})`,c=n.includes("color")?"color":a;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${o} ${r} a_${n};\n#endif\n`:i.has(n)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\n #if !defined(${s})\n in ${o} ${a} a_${n};\n #endif\n${vr(r)?"flat ":""}out ${o} ${r} ${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${n})\n #ifdef ${s}\n ${n} = unpack_mix_${c}(${l}, u_${n}_t);\n #else\n ${n} = unpack_mix_${c}(a_${n}, u_${n}_t);\n #endif\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${o} ${r} a_${n};\n out ${o} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\n #if !defined(${s})\n in ${o} ${a} a_${n};\n #endif\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${o} ${a} a_${n};\n#else\nuniform ${o} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${o} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===c||"uvec4"===c?`\n#ifndef HAS_UNIFORM_u_${n}\n #ifdef ${s}\n ${o} ${r} ${n} = ${l};\n #else\n ${o} ${r} ${n} = a_${n};\n #endif\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n #ifdef ${s}\n ${o} ${r} ${n} = unpack_mix_${c}(${l}, u_${n}_t);\n #else\n ${o} ${r} ${n} = unpack_mix_${c}(a_${n}, u_${n}_t);\n #endif\n#else\n ${o} ${r} ${n} = u_${n};\n#endif\n`}),usedDefines:n,vertexIncludes:o,fragmentIncludes:r}}var xr={model:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;\n#endif\nuniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nin highp float v_cutout_factor;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\ntexColor=vec4(unpremultiplyColor(texColor),1.0);\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));\n#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir;vec3 lightColor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#else\nlightDir=u_lightpos;lightColor=u_lightcolor;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\napply_feature_cutout_dither(gl_FragCoord,v_cutout_factor);\n#else\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_feature_cutout.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nout highp float v_cutout_factor;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp uvec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nv_cutout_factor=1.0;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#ifdef FEATURE_CUTOUT_VERTEX\nhighp vec4 ground_pos=vec4(pos_a.xy,0.0,1.0);highp vec4 cutout_clip_pos=mix(u_matrix*ground_pos,AWAY,hidden);highp vec3 cutout_ndc=cutout_clip_pos.xyz/cutout_clip_pos.w;vec2 uv=cutout_ndc.xy*0.5+0.5;highp float fragDepthNDC=cutout_ndc.z*0.5+0.5;\n#ifdef FLIP_Y\nfragDepthNDC=cutout_ndc.z;\n#endif\nhighp float cutoutFactor=get_cutout_factors_vert(uv).x;highp float cutoutDepthNDC=sample_cutout_depth(u_cutout_depth_image,uv);highp float groundThreshold=0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);v_cutout_factor=mix(1.0-cutoutFactor,1.0,groundLimit);\n#endif\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:yr("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\n}"),fillExtrusionDepth:yr("void main() {}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}'),fillExtrusionGroundEffect:yr("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=float(a_hidden_by_landmark);\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),groundShadow:yr('#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp float cutoutFactor=get_cutout_factors(gl_FragCoord).y;highp float cutoutDepthNDC=sample_cutout_depth_bilinear(u_cutout_depth_image,uv);highp float fragDepthNDC=gl_FragCoord.z/u_feature_cutout_params.w;highp float groundThreshold=-0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);cutoutFactor=mix(0.0,cutoutFactor,groundLimit);shadow=mix(shadow,vec3(1.0),cutoutFactor);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);\n#endif\n}')};const br=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),wr={model:t=>({u_matrix:new e.ap(t),u_lighting_matrix:new e.ap(t),u_normal_matrix:new e.ap(t),u_node_matrix:new e.ap(t),u_lightpos:new e.aq(t),u_lightintensity:new e.ar(t),u_lightcolor:new e.aq(t),u_camera_pos:new e.aq(t),u_opacity:new e.ar(t),u_baseColorFactor:new e.bZ(t),u_emissiveFactor:new e.bZ(t),u_metallicFactor:new e.ar(t),u_roughnessFactor:new e.ar(t),u_baseTextureIsAlpha:new e.b_(t),u_alphaMask:new e.b_(t),u_alphaCutoff:new e.ar(t),u_baseColorTexture:new e.b_(t),u_metallicRoughnessTexture:new e.b_(t),u_normalTexture:new e.b_(t),u_occlusionTexture:new e.b_(t),u_emissionTexture:new e.b_(t),u_lutTexture:new e.b_(t),u_color_mix:new e.bZ(t),u_aoIntensity:new e.ar(t),u_emissive_strength:new e.ar(t),u_occlusionTextureTransform:new e.bZ(t),u_dithered_discard_threshold:new e.ar(t)}),modelDepth:t=>({u_matrix:new e.ap(t),u_instance:new e.ap(t),u_node_matrix:new e.ap(t)}),groundShadow:t=>({u_matrix:new e.ap(t),u_ground_shadow_factor:new e.aq(t)}),fillExtrusionDepth:t=>({u_matrix:new e.ap(t),u_edge_radius:new e.ar(t),u_width_scale:new e.ar(t),u_vertical_scale:new e.ar(t),u_height_type:new e.b_(t),u_base_type:new e.b_(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.ap(t),u_opacity:new e.ar(t),u_ao_pass:new e.ar(t),u_meter_to_tile:new e.ar(t),u_ao:new e.b$(t),u_flood_light_intensity:new e.ar(t),u_flood_light_color:new e.aq(t),u_attenuation:new e.ar(t),u_edge_radius:new e.ar(t),u_fb:new e.b_(t),u_fb_size:new e.ar(t),u_dynamic_offset:new e.ar(t)})},Tr=[];function Er(e){return Tr[e]=Tr[e]||new Float64Array(16)}const Sr=[],Ir=new Float32Array(16);class Cr{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class Rr{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new Cr(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const r=e.ca.fromPoints(t.points);let n=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!r.intersectsAabb(s.aabb))continue;s.aabb.min=r.closestPoint(s.aabb.min),s.aabb.max=r.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){r=!1;break}}if(s.lastCascade=t,n=Math.max(n,t),r)break}}return n+1}}function Dr(t,i,o){const r=e.aW([],o,i),n=e.aW([],t,i),s=e.ax([],r,n),a=e.ae(s);return 0===a?[0,0,1,0]:(e.av(s,s,1/a),[s[0],s[1],s[2],-e.aw(s,i)])}function Ar(t,i,o,r,n,s){const a=t.zoom,l=t.scale,c=t.worldSize,h=1/c,d=t.aspect,u=Math.sqrt(1+d*d)*Math.tan(.5*t.fovX),_=u*u,f=r-o,p=r+o;let m,g;_>f/p?(m=r,g=r*u):(m=.5*p*(1+_),g=.5*Math.sqrt(f*f+2*(r*r+o*o)*_+p*p*_*_));const v=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),x=[0,0,-m*h];e.ad(x,x,y);let b=g*h;const w=function(i){return i[0]/=l,i[1]/=l,i[2]=e.aL(i[2],t._center.lat),i},T=t._edgeInsets;if(!(0===T.left&&0===T.top&&0===T.right&&0===T.bottom||T.left===T.right&&T.top===T.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?v:1),n=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,r);n[8]=2*-t.centerOffset.x/t.width,n[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.bI(s,n,i);const l=new Float64Array(16);e.aE(l,s);const h=e.bs.fromInvProjectionMatrix(l,c,a,!0);for(const t of h.points){const i=w(t);b=Math.max(b,e.ay(e.cA([],x,i)));}}b*=n/(n-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),I=new Ii;I.position=x,I.setPitchBearing(E,S);const C=I.getWorldToCamera(c,v),R=b*c,D=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*R),A=I.getCameraToClipOrthographic(-R,R,-R,R,D,(R+s*v)/i[2]),L=new Float64Array(16);e.aP(L,A,C);const P=e.c6(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),O=.5*n,M=[0,0,0];e.ad(M,P,L),e.av(M,M,O);const F=[Math.floor(M[0]),Math.floor(M[1]),Math.floor(M[2])],z=[0,0,0];e.aW(z,M,F),e.av(z,z,-1/O);const B=new Float64Array(16);return e.aC(B),e.aG(B,B,z),e.aP(L,B,L),[L,R]}const Lr={loaded:!0,drawModels:function(t,i,o,r){if("opaque"===t.renderPass)return;const n=o.paint.get("model-opacity").constantOr(1),s=o.paint.get("model-elevation-reference"),a="ground"===s,l="ground"===s;if(0===n)return;const c=o.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!c)return;if(t.terrain&&n<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof e.ab)return}const h=t.shadowRenderer,d=o.paint.get("model-receive-shadows");h&&(h.useNormalOffset=!0,d||(h.enabled=!1));const u=()=>{h&&(h.useNormalOffset=!0,d||(h.enabled=!0));},_=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==_.type)return;if("vector"===_.type||"geojson"===_.type)return function(t,i,o,r,n){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;o.modelManager=c;const h=t.shadowRenderer;if(!Object.hasOwn(o._unevaluatedLayout._values,"model-id"))return;const d=o._unevaluatedLayout._values["model-id"],u={...o.layout.get("model-id").parameters},_=t.style.order.indexOf(o.fqid),f=o.paint.get("model-opacity").constantOr(1);for(const p of r){const r=i.getTile(p).getBucket(o);if(!r||r.projection.name!==s.projection.name)continue;const m=r.getModelUris();if(m&&!r.modelsRequested&&(c.addModelsFromBucket(m,n),r.modelsRequested=!0),a)u.zoom=p.overscaledZ;else {const e=Uo(p,s);u.zoom=e;}const g=d.possiblyEvaluate(u);if(ko(t,r,p),No.shadowUniformsInitialized=!1,No.useSingleShadowCascade=!!h&&0===h.getMaxCascadeForTile(p.toUnwrapped()),"shadow"===t.renderPass&&h){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(p.toUnwrapped(),s.worldSize);if(No.tileMatrix.set(i),No.shadowTileMatrix.set(h.calculateShadowPassMatrixFromMatrix(i)),No.aabb.min=[0,0,0],No.aabb.max[0]=No.aabb.max[1]=e.aj,No.aabb.max[2]=0,Vo(r,No,t,o.scope))continue}const v=1<0&&t.style.isLayerClipped(o,i.getSource())&&r.updateReplacement(p,t.replacementSource,_,o.scope)&&(r.uploaded=!1,r.upload(t.context));let x=0;const b=new Array,w=new Array,T=new Array;for(let i in r.instancesPerModel){const s=r.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const h=c.getModel(i,n);if(h||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),h&&h.uploaded)if(a){const i=e.av([],[l.x,l.y,l.z],t.transform.worldSize);e.cb(i,i);for(let o=0;o0&&o.elevationUpdate(e.terrain,r,s,i.source),o.needsReEvaluation(e,n,i)&&o.evaluate(i));}}))(t,i,o,r),function(){const c=new Map;let d,u,f;S?(d=r.length-1,u=-1,f=-1):(d=0,u=r.length,f=1);const R=e.bj(),D=new e.P(0,0);for(let A=d;A!==u;A+=f){const d=r[A],u=i.getTile(d).getBucket(o);if(!u||!u.uploaded)continue;let f=!1;l&&(f=0===l.getMaxCascadeForTile(d.toUnwrapped()));const L=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize),P=!!(u.modelTraits&e.ck.HasMapboxMeshFeatures);e.aP(vo,p,L),e.aP(yo,s.expandedFarZProjMatrix,L),e.aE(xo,vo),e.cl(xo,xo);const O=!x&&l&&l.enabled?l.computeCascadeTileMatrices(L):null;!x&&S&&(e.aE(mo,L),e.ad(R,h,mo),D.x=R[0],D.y=R[1]);const M=[];u.setFilter(o.filter);for(const i of u.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const o=i.node;let r=0;t.terrain&&o.elevation&&(r=o.elevation*t.terrain.exaggeration());const n=(()=>{const t=i.aabb,o=y.min,n=y.max;return o[0]=t.min[0],o[1]=t.min[1],o[2]=t.min[2]+r,n[0]=t.max[0],n[1]=t.max[1],n[2]=t.max[2]+r,e.ad(o,o,L),e.ad(n,n,L),y})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===n.intersects(T))continue;if(!x){const o=n.min,r=n.max;Eo[0]=.5*(o[0]+r[0]),Eo[1]=.5*(o[1]+r[1]),Eo[2]=.5*(o[2]+r[2]);const s=e.aX(h,Eo)*_,l=t._debugParams.lodSwitchDistance,c=l>=0;if(c&&l>=9999)i.targetLod=0;else {let e;if(c)e=l;else {const t=(r[2]-o[2])*_*a[2],i=Math.max(r[0]-o[0],r[1]-o[1])*_*Math.max(a[0],a[1]);let n;n=t>=30?1:i>=80?.5:Math.max(t,i)>=20?.25:0,e=2e3+3e3*n;}Go(i,s,Math.min(t.frameTimeDelta,1e3/30),e,t._debugParams.lodSwitchFadeDuration);}}if(!x&&S){const t=1/6;i.cameraCollisionOpacity=h[0]>n.min[0]&&h[0]n.min[1]&&h[1]!S||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of M){const r=i.nodeInfo,h=r.node;let d=null;if(t._debugParams.show3DModelFootprints&&h.footprint){const e=h.id||h.name||"footprint";if(!c.has(e)){const t=Ro(new Float64Array(16),yo,i.tileTranslation,i.nodeInfo.evaluatedScale);c.set(e,{node:h,mvp:t});}}const u=i.nodeInfo.evaluatedScale;Ro(po,vo,i.tileTranslation,u),wo[0]=1/u[0],wo[1]=-1/u[1],wo[2]=1/u[2],e.bL(mo,xo,wo),e.aP(po,po,h.globalMatrix);const _=P?0:r.evaluatedRMEA[0][2],p=r.targetLod,m=h.lodMeshes&&h.lodMeshes.length>0,y=m&&p>0&&p<1;if(x&&m&&1===Math.round(p))continue;const T=!x&&a?Co(go,i.nodeModelMatrix,t.transform):null,E=x&&l?l.calculateShadowPassMatrixFromMatrix(i.nodeModelMatrix):null,S=y?2:1,I=m&&1===Math.round(p);for(let e=0;e=$t||o>=$t;}const L=p.material;let M;L.occlusionTexture&&L.occlusionTexture.offsetScale&&(M=L.occlusionTexture.offsetScale,R.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),y&&R.defines.push("DITHERED_DISCARD");const F=t.getOrCreateProgram("model",R);if(!x&&l&&l.enabled)if(d!==A){for(let e=0;e0){const e=Array.from(c.keys()).sort();for(const i of e){const{node:e,mvp:o}=c.get(i);Mo(t,0,e,o);}}}();}(t,i,o,r),void u();if("model"!==_.type)return;const f=_.getModels(),p=[],m=t.transform.getFreeCameraOptions().position,g=e.av([],[m.x,m.y,m.z],t.transform.worldSize);e.cb(g,g);const v=[],y=[];let x=0;for(const r of f){const n=i.getFeatureState("",r.id),s={type:"Unknown",id:r.id,properties:r.featureProperties},c=o.paint.get("model-rotation").evaluate(s,n),h=o.paint.get("model-scale").evaluate(s,n),d=o.paint.get("model-translation").evaluate(s,n),u=o.paint.get("model-opacity").evaluate(s,n);Fo(o,r.id,n,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),zo(o,r.id,n,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,h,d,l,a,!1);const _=e.bR([],g),f=e.cc(r.position.lat,t.transform.zoom),m=e.aF([],[1,1,1/f]);p.push({zScaleMatrix:m,negCameraPosMatrix:_});for(const e of r.nodes)Po(t,e,r.matrix,t.transform.expandedFarZProjMatrix,x,v,y,r.materialOverrides,u,void 0,r.lightOverrides);x++;}if(v.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass){if(t._debugParams.show3DModelFootprints){const i=t.transform.projMatrix,o=new Map,r=(t,r)=>{if(t.footprint){const n=t.id||t.name||"footprint";if(!o.has(n)){const s=e.aP([],i,r);o.set(n,{node:t,mvp:s});}}};for(const e of y)r(e.node,e.modelMatrix);for(const e of v)r(e.node,e.modelMatrix);const n=Array.from(o.keys()).sort();for(const e of n){const{node:i,mvp:r}=o.get(e);Mo(t,0,i,r);}}Bo(t,o,v,y,p),u();}else {for(const e of y)Oo(e.mesh,e.nodeModelMatrix,t,o);for(const e of v)Oo(e.mesh,e.nodeModelMatrix,t,o);u();}},prepare:function(e,t,i){const o=t.getSource();if(!o.loaded())return;if("vector"===o.type||"geojson"===o.type)return void(i.modelManager&&i.modelManager.upload(i,Lo(i,e)));if("batched-model"===o.type)return;if("model"!==o.type)return;const r=o.getModels();for(const e of r)e.upload(i.context);},shaders:xr,programUniforms:wr,ShadowRenderer:class{constructor(e){this.painter=e,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Rr,this._depthMode=new xi(e.context.gl.LEQUAL,xi.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(t,i){const o=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity"),n=i.properties.get("shadow-draw-before-layer");if(!i.shadowsEnabled()||r<=0)return;let s=-1,a=0;for(const e of o.style.order){const i=o.style._mergedLayers[e];i.hasShadowPass()&&!i.isHidden(t.zoom)&&(s=a),!n||n!==e&&n!==i.slot||(this._drawShadowAfterLayer=a>0?a-1:0),a+=1;}if(this._enabled=s>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=s);const l=o.context,c=this._shadowParameters.shadowMapResolution,h=this._shadowParameters.shadowMapResolution;if(0===this._cascades.length||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.dem).forEach(e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);}),1e4!==i[0]&&(d=(i[1]-i[0])*e.exaggeration());}const u=1.5*t.cameraToCenterDistance,_=3*u,f=new Float64Array(16);for(let i=0;i=0)return {};const n=function(t,i,o){const r=o/(1<0&&(e.cz(n[1],n[1],[r[0]*s,0,0]),e.cz(n[2],n[2],[r[0]*s,0,0])),r[1]<0?(e.cz(n[0],n[0],[0,r[1]*s,0]),e.cz(n[1],n[1],[0,r[1]*s,0])):r[1]>0&&(e.cz(n[2],n[2],[0,r[1]*s,0]),e.cz(n[3],n[3],[0,r[1]*s,0]));const a={};return a.vertices=n,a.planes=[Dr(n[1],n[0],n[4]),Dr(n[2],n[1],n[5]),Dr(n[3],n[2],n[6]),Dr(n[0],n[3],n[7])],a}addShadowReceiver(t,i,o){this._receivers.add(t,e.ca.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}},drawGroundEffect:Yi},Pr=Lr;async function Or(){return Promise.resolve()}function Mr(t,i,o,r,n,s,a,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,d=t.transform,u=o.paint.get("fill-extrusion-pattern"),_=o.paint.get("fill-extrusion-pattern-cross-fade"),f=u.constantOr(null),p=u.constantOr(1),m=o.paint.get("fill-extrusion-opacity"),g=t.style.enable3dLights(),v=o.paint.get(g&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),v],x=o.layout.get("fill-extrusion-edge-radius"),b=x>0&&!o.paint.get("fill-extrusion-rounded-roof"),w=b?0:x,T="globe"===d.projection.name?e.cC():0,E="globe"===d.projection.name,S=E?e.ah(d.zoom):0,I=[e.a_(d.center.lng),e.a$(d.center.lat)],C="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),R=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(C?null:o.lut).toArray01().slice(0,3),D=o.paint.get("fill-extrusion-flood-light-intensity"),A=o.paint.get("fill-extrusion-vertical-scale"),L=0!==o.paint.get("fill-extrusion-line-width").constantOr(1),P=o.paint.get("fill-extrusion-height-alignment"),O=o.paint.get("fill-extrusion-base-alignment"),M=Zi(t,o.paint.get("fill-extrusion-cutoff-fade-range")),F=o.paint.get("fill-extrusion-front-cutoff"),z=zr(d.pitch,F,!!t.terrain),B=z[2]<1;B&&(t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,F[0]));const k=[];let N;E&&k.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&k.push("FAUX_AO"),b&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),D>0&&k.push("FLOOD_LIGHT"),M.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),B&&k.push("RENDER_FRONT_CUTOFF"),L&&k.push("RENDER_WALL_MODE");const U="shadow"===t.renderPass,j=t.shadowRenderer,G=U&&!!j,V=U?yi.disabled:yi.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let q=[0,0,0];if(j){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(q=lo(t.style,e,i)),U||(k.push("RENDER_SHADOWS"),j.useNormalOffset&&k.push("NORMAL_OFFSET")),N=k.concat(["SHADOWS_SINGLE_CASCADE"]);}const H=G?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",Z=o.getLayerRenderingStats();for(const u of r){const r=i.getTile(u),g=r.getBucket(o);if(!g||g.projection.name!==d.projection.name)continue;let v=!1;j&&(v=0===j.getMaxCascadeForTile(u.toUnwrapped()));const x=t.isTileAffectedByFog(u),b=g.programConfigurations.get(o.id);let C=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.cD.from(f),o=i.getPrimary().scaleSelf(e.r.devicePixelRatio).toString(),n=i.getSecondary(),s=t.patternPositions.get(o),a=n?t.patternPositions.get(n.scaleSelf(e.r.devicePixelRatio).toString()):null;C=!!s&&!!a,s&&b.setConstantPatternPositions(s,a);}_>0&&(C||b.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const F=t.getOrCreateProgram(H,{config:b,defines:v?N:k,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(r,F,{useMeterToDem:!0}),!g.centroidVertexBuffer){const e=F.getAttributeLocation(h,"a_centroid_pos");-1!==e&&h.vertexAttribI4ui(e,0,0,0,0);}!U&&j&&j.setupShadows(r.tileID.toUnwrapped(),F,"vector-tile"),p&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers());const B=o.paint.get("fill-extrusion-vertical-gradient"),G=1/g.tileToMeter;let W;if(U&&j){if(jr(r.tileID,g.maxHeight,t))continue;const e=j.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());W=no(e,w,G,A,P,O);}else {const e=t.translatePosMatrix(u.expandedProjMatrix,r,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=d.projection.createInversionMatrix(d,u.canonical),n=F.fixedDefines.includes("LIGHTING_3D_MODE");W=p?so(e,t,B,m,y,w,G,u,r,T,P,O,S,I,i,R,A,_,n):ro(e,t,B,m,y,w,G,u,T,P,O,S,I,i,R,A,D,q,z,n);}t.uploadCommonUniforms(c,F,u.toUnwrapped(),null,M);let $=g.segments;if("mercator"===d.projection.name&&!U&&($=g.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!$.get().length))continue;if(Z)if(U)for(const e of $.get())Z.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of $.get())Z.numRenderedVerticesInTransparentPass+=e.primitiveLength;const X=[];(t.terrain||l)&&X.push(g.centroidVertexBuffer),E&&X.push(g.layoutVertexExtBuffer),L&&X.push(g.wallVertexBuffer),F.draw(t,c.gl.TRIANGLES,n,s,a,V,W,o.id,g.layoutVertexBuffer,g.indexBuffer,$,o.paint,t.transform.zoom,b,X);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}class Fr{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0;}}function zr(e,t,i){if(!(t[2]<1)||i)return [0,0,1];const o=180*e/Math.PI;if(o<15)return [-.5,t[1],t[2]];const r=Math.min(1,Math.max(0,(o-15)/5)),n=r*r*(3-2*r);return [-.5*(1-n)+t[0]*n,t[1],t[2]]}function Br(t,i,o,r,n,s,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=s?s.findDEMTileFor(o):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=(t,i)=>{(t.flags|i.flags)&e.cE?(t.flags|=e.cE,i.flags|=e.cE):(t.flags&=~e.cE,i.flags&=~e.cE);},h=t=>new e.P(Math.ceil((t+e.cF)*e.cG),0),d=(t,i,o)=>{const r=Math.ceil((t+e.cF)*e.cG),n=Math.floor(Math.max(0,Math.min(e.aj-1,o))/4);return new e.P(r,n<<5|(3&i)<<3|7)},u=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(n)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(_[0]=Math.min(t.min.y,i.min.y),_[1]=Math.max(t.max.y,i.max.y),_[2]=e.aj-i.min.x>t.max.x?i.min.x-e.aj:t.max.x,_),p=(t,i)=>(_[0]=Math.min(t.min.x,i.min.x),_[1]=Math.max(t.max.x,i.max.x),_[2]=e.aj-i.min.y>t.max.y?i.min.y-e.aj:t.max.y,_),m=[(e,t)=>f(e,t),(e,t)=>f(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],g=(t,i,r,n,a,c,h)=>{if(!s)return 0;const d=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],u=h<0?e.aj+h:h,_=[c?u:(t+i)/2,c?(t+i)/2:u,0];return 0===r&&h<0||0!==r&&h>0?s.getForTilePoints(a,[_],!0,n):d.push(_),s.getForTilePoints(o,d,!0,l),Math.max(d[0][2],d[1][2],_[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const n=e.c0[t](o),l=u(n);if(!(l&&l instanceof e.cB))continue;const _=s?s.findDEMTileFor(n):null;if(!(_&&_.dem||a))continue;if(s&&_&&_.dem&&r.borderDEMTileTimestamp[t]!==_.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=_.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const f=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[f]!==r.canonical.z,v=l.borderFeatureIndices[f];let y=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(p)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;continue}const x=new Map,b=new Set,w=new Set;for(let e=0;e1||u.intersectsCount()>1;{let i=0;if(_&&_.dem&&!S){const o=m[t](s,p),r=t%2?e.aj-1:0;i=g(o[0],Math.min(e.aj-1,o[1]),r,_,n,t<2,o[2]);}s.centroidXY=d(i,t,E),p.centroidXY=d(i,f,E);}if(r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(p),void 0!==i.buildingId){for(const e of r.centroidData)e.buildingId===i.buildingId&&e!==s&&(e.centroidXY=s.centroidXY,r.writeCentroidToBuffer(e));for(const e of l.centroidData)e.buildingId===i.buildingId&&e!==p&&(e.centroidXY=p.centroidXY,l.writeCentroidToBuffer(e));}}for(const o of i){if(b.has(o))continue;const i=r.featuresOnBorder[o],s=r.centroidData.get(i.centroidDataIndex),d=i.borders[t];let u;for(;yd[0]+3||e[0]>d[0]-3)break;l.showCentroid(u),y++;}if(u&&yd[1]-3)break;if(p++,++y===v.length)break;u=l.featuresOnBorder[v[y]];}for(;o=v.length){r.showCentroid(i);continue}u=l.featuresOnBorder[v[o]];let x=!1;if(p>=1){const e=u.borders[f];Math.abs(d[0]-e[0])<3&&Math.abs(d[1]-e[1])<3&&(p=1,x=!0,y=o+1);}else if(0===p){r.showCentroid(i);continue}const b=l.centroidData.get(u.centroidDataIndex);a&&x&&c(s,b);const T=i.intersectsCount()>1||u.intersectsCount()>1;if(p>1)y=o,s.centroidXY=b.centroidXY=new e.P(0,0);else if(_&&_.dem&&!T){const i=m[t](s,b),o=t%2?e.aj-1:0,r=g(i[0],Math.min(e.aj-1,i[1]),o,_,n,t<2,i[2]);s.centroidXY=b.centroidXY=h(r);}else T?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(u));r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=r.canonical.z;}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const kr=[1,0,0],Nr=[0,1,0],Ur=[0,0,1];function jr(t,i,o){const r=o.transform,n=o.shadowRenderer;if(!n)return !0;const s=o.frameCounter,a=o.currentShadowCascade;let l=o._shadowCullCache;if(!l||l.frame!==s||l.cascade!==a){const t=r.tileSize*n._cascades[a].scale,i=r.scaleZoom(t),c=n.shadowDirection,h=[c[0],c[1],-c[2]],d=[kr,Nr,Ur,h,[h[0],0,h[2]],[0,h[1],h[2]]];l={frame:s,cascade:a,cameraFrustum:e.bs.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,i,!("globe"===r.projection.name)),edges:d,shadowDir:h,ws:t,zoom:i},o._shadowCullCache=l;}const{cameraFrustum:c,edges:h,shadowDir:d,ws:u,zoom:_}=l;let f=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(f+=e.max);}f/=e.cc(r.center.lat,_);const p=n.computeSimplifiedTileShadowVolume(t.toUnwrapped(),f,u,d);if(!p)return !1;const{vertices:m,planes:g}=p;return 0===c.intersectsPrecise(m,g,h)||0===n.getCurrentCascadeFrustum().intersectsPrecise(m,g,h)}const Gr=new Float32Array(16),Vr=new Float32Array(16);function qr(t){const{painter:i,source:o,layer:r,coords:n}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,h=i.shadowRenderer,d=e.cc(i.transform.center.lat,i.transform.zoom),u=Zi(i,r.paint.get("building-cutoff-fade-range"));u.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF"));const _=r.paint.get("building-front-cutoff"),f=_[2]<1&&!i.terrain,p=zr(i.transform.pitch,_,!!i.terrain);f&&(s=s.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,_[0])),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const _ of n){const n=o.getTile(_),f=n.getBucket(r);if(!f)continue;h&&0===h.getMaxCascadeForTile(_.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=f.programConfigurations.get(r.id);let g,v;const y=i.translatePosMatrix(_.expandedProjMatrix,n,[0,0],"map");e.bL(Gr,y,[1,1,t.verticalScale]);const x=Gr;let b;if(l&&h){if(jr(n.tileID,f.maxHeight*d,i))continue;const o=h.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());e.bL(o,o,[1,1,t.verticalScale]),b=mi(o),g=v=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1});}else if(c)g=v=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),b=pi(x);else {const o=i.transform.calculatePosMatrix(_.toUnwrapped(),i.transform.worldSize);e.bL(o,o,[1,1,t.verticalScale]),e.bL(Vr,o,[1,-1,1/d]),e.aE(Vr,Vr),e.cl(Vr,Vr);const r=Vr,n=i.transform.getFreeCameraOptions().position,l=1<<_.canonical.z;if(b=fi(x,r,t.opacity,t.facadeAOIntensity,[((n.x-_.wrap)*l-_.canonical.x)*e.aj,(n.y*l-_.canonical.y)*e.aj,n.z*l*e.aj],f.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity,p),v=i.getOrCreateProgram("building",{config:m,defines:s,overrideFog:!1}),!0===t.depthOnly)g=v;else {const e=s.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);g=i.getOrCreateProgram("building",{config:m,defines:e,overrideFog:!1});}h&&(h.setupShadowsFromMatrix(o,v,!0),g!==v&&g.setShadowUniformValues(a,h.getShadowUniformValues()));}const w=(e,o)=>{if(c){const n=e.entranceBloom;o.draw(i,a.gl.TRIANGLES,t.depthMode,$i.disabled,t.blendMode,yi.disabled,b,r.id,n.layoutVertexBuffer,n.indexBuffer,n.segmentsBucket,r.paint,i.transform.zoom,m,[n.layoutAttenuationBuffer,n.layoutColorBuffer]);}else {const n=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),o.draw(i,a.gl.TRIANGLES,t.depthMode,$i.disabled,t.blendMode,l?yi.disabled:yi.backCW,b,r.id,e.layoutVertexBuffer,e.indexBuffer,n,r.paint,i.transform.zoom,m,s);}};i.uploadCommonUniforms(a,v,_.toUnwrapped(),null,u),f.buildingWithoutFacade&&w(f.buildingWithoutFacade,v),f.buildingWithFacade&&(g!==v&&i.uploadCommonUniforms(a,g,_.toUnwrapped(),null,u),w(f.buildingWithFacade,g));}}function Hr(t,i,o,r,n,s,a,l,c,h,d,u,_,f){const p=t.context.gl,m=t.depthModeForSublayer(1,xi.ReadOnly,p.LEQUAL,!0),g=e.ai(.1,3,d),v=t._showOverdrawInspector,y=u,x=new Fr;v||Yi(x,t,i,o,r,m,new $i({func:p.ALWAYS,mask:255},255,255,p.KEEP,p.KEEP,p.REPLACE),new Ji([p.ONE,p.ONE,p.ONE,p.ONE],e.C.transparent,[!1,!1,!1,!0],p.MIN),yi.disabled,n,"sdf",s,a,l,c,h,g,y,!1,void 0);{const d=v?$i.disabled:new $i({func:p.EQUAL,mask:255},255,255,p.KEEP,p.DECR,p.DECR),u=v?t.colorModeForRenderPass():new Ji([p.ONE_MINUS_DST_ALPHA,p.DST_ALPHA,p.ONE,p.ONE],e.C.transparent,[!0,!0,!0,!0]);Yi(x,t,i,o,r,m,d,u,yi.disabled,n,"color",s,a,l,c,h,g,y,!1,void 0);}}class Zr{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16;}findClosestBuilding(e,t,i,o,r){if(ia*this._hysteresisRatio&&(n=this._previousClosestBuildingId):l&&!n&&(n=this._previousClosestBuildingId),this._previousClosestBuildingId=n,n}_calculateDistance(e,t){if(!t.center)return Number.MAX_VALUE;const i=e.lat-t.center[1],o=e.lng-t.center[0];return i*i+o*o}_isBuildingVisible(t,i,o){if(!o)return !1;for(const i of t.floorIds){const r=t.floors[i];if(!r.geometry)continue;const n=r.geometry;if("Polygon"===n.type){const t=this._convertRingToPoints(n.coordinates[0]);if(e.cJ(t,o))return !0}else if("MultiPolygon"===n.type){const t=this._convertMultiPolygonToPoints(n.coordinates);if(e.cK(o,t))return !0}}return !1}_convertRingToPoints(t){return t.map(t=>new e.P(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new e.P(t[0],t[1])))}}const Wr=.05,$r=(e,t,i,o,r,n,s,a,l,c,h,d)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:r,u_tl_parent:n,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Xr=(e,t,i,o,r,n,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:o,u_color_ramp:n,u_velocity_res:r,u_max_speed:s,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Wr,Wr]}),Yr=(e,t,i,o,r,n,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:o,u_max_speed:r,u_speed_factor:n,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Wr,Wr]});function Kr(e,[t,i,o,r],[n,s]){if(n===s)return [0,0,0,0];const a=255*(e-1)/(e*(s-n));return [t*a,i*a,o*a,r*a]}function Qr(e,t,[i,o]){return i===o?0:.5/e+(t-i)*(e-1)/(e*(o-i))}function Jr(e,t){const i={};if(!t)return i;for(const o of e){const e=o.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){o.layers=e,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0])),o.updateExpressions&&o.updateExpressions(e);for(const t of e)i[t.fqid]=o;}}return i}const en=32,tn=33,on=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,o=0,r=0,n=0,s=0,a=0;for(1&t?r=n=s=en:i=o=a=en;(t>>=1)>1;){const e=i+r>>1,l=o+n>>1;1&t?(r=i,n=o,i=s,o=a):(i=r,o=n,r=s,n=a),s=e,a=l;}const l=4*e;on[l+0]=i,on[l+1]=o,on[l+2]=r,on[l+3]=n;}const rn=new Uint16Array(2178),nn=new Uint8Array(1089),sn=new Uint16Array(1089);function an(e){return 0===e?-.03125:32===e?.03125:0}var ln=e.cR([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);const cn=(()=>({type:2,extent:e.aj,loadGeometry:()=>[[new e.P(0,0),new e.P(e.aj+1,0),new e.P(e.aj+1,e.aj+1),new e.P(0,e.aj+1),new e.P(0,0)]]}))();let hn=0;class dn{constructor(t,i,o,r,n,s){this.tileID=t,this.uid=e.am(),this.uses=0,this.tileSize=i,this.tileZoom=o,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=s,this._hasAppearances=null;}registerFadeDuration(t){const i=t+this.timeAdded;i0&&(this.frcCoveragePolygons=t.frcCoveragePolygons),this.hasDeferredRoadStructure=!!t.hasDeferredRoadStructure,void 0!==t.parsedElevationFeatures&&(this.parsedElevationFeatures=t.parsedElevationFeatures,this.parsedElevationGeneration=++hn),this.hasDeferredElevationFeatures=!!t.hasDeferredElevationFeatures,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!t.hasTunnelGeometry;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.cT){if(this.hasSymbolBuckets=!0,!o)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.cT&&i.hasRTLText){this.hasRTLText=!0,e.cU();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],o=i.style.getOwnLayer(e);if(!o)continue;const r=o.queryRadius(t)||0;this.queryPadding=Math.max(this.queryPadding,r);}t.imageAtlas&&(this.imageAtlas=i.style.imageManager.imageAtlasCache.getOrCache(t.imageAtlas)),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness;}else this.collisionBoxArray=new e.cS;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=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";}}loadModelData(e,t,i){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets={...this.buckets,...Jr(e.buckets,t.style)},e.featureIndex&&(this.latestFeatureIndex=e.featureIndex));}getBucket(e){return this.buckets[e.fqid]}upload(t,i){for(const e in this.buckets){const o=this.buckets[e];if(o.uploadPending()){let e={},r=[],n={zoom:0,pitch:0,brightness:0,worldview:""};if(i){if(i.style){r=i.style.listImages();const t=o.layers[0],n=t.sourceLayer||"_geojsonTileLayer",s=i.style.getLayerSourceCache(t);s&&(e=s._state.getState(n,void 0));}n={zoom:i.transform.zoom||0,pitch:i.transform.pitch||0,brightness:i.style.getBrightness()||0,worldview:i.worldview||""};}o.upload(t,this.tileID.canonical,e,r,n);}}const o=t.gl,r=this.imageAtlas;r&&i&&(this.imageAtlasTexture=i.style.imageManager.imageAtlasCache.getTextureForAtlas(r,t,o.RGBA8),r.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,o.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,o.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&t){const o=t.style.getLut(i);this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i,o);}if(!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const o=t.style.getBrightness(),r=t.style.listImages(),n=r.length,s=t.style._changes.getUpdatedPaintProperties(),a=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>s.has(e.fqid))),l=Object.keys(this.buckets).some(e=>this.buckets[e].layers.some(e=>e.hasTransition&&e.hasTransition())),c=this._firstPrepareComplete&&n!==this._lastAvailableImagesCount;null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(t));const h=this._lastUpdatedBrightness!==o;this._lastAvailableImagesCount=n,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||o||this._hasAppearances||a||l||c)&&(!(this._hasAppearances||a||l||c)&&this._lastUpdatedBrightness&&o&&Math.abs(this._lastUpdatedBrightness-o)<.001||(this.updateBuckets(t,h,void 0,c||a||l,s,r),this._lastUpdatedBrightness=o));}evaluateQueryRenderedFeaturePadding(){let e=0;for(const t in this.buckets){const i=this.buckets[t];i.evaluateQueryRenderedFeaturePadding&&(e=Math.max(e,i.evaluateQueryRenderedFeaturePadding()));}return e}queryRenderedFeatures(t,i,o,r,n,s,a){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return {};const l=this.evaluateQueryRenderedFeaturePadding(),c=function(t,i){const o=e.aF([],[.5*t.width,.5*-t.height,1]);return e.aG(o,o,[1,-1,0]),e.aP(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}(n,this.tileID);return this.latestFeatureIndex.query(t,{tilespaceGeometry:i,pixelPosMatrix:c,transform:r,availableImages:o,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:l,scope:a})}querySourceFeatures(t,i){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const r=o.loadVTLayers(),n=i?i.sourceLayer:"",s=r._geojsonTileLayer||r[n];if(!s)return;const a=e.cV(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,d={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTimee.appearances&&e.appearances.length>0))return !0;return !1}updateBuckets(t,i,o,r,n,s){if(!this.latestFeatureIndex)return;if(!t.style)return;const a=s||t.style.listImages(),l=t.style.getBrightness(),c=n||new Set;for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const s=this.buckets[n],h=s.layers[0],d=h.sourceLayer||"_geojsonTileLayer",u=t.style.getLayerSourceCache(h),_=s.layers.some(e=>c.has(e.fqid)),f=(r||_)&&s instanceof e.cT?t.style.getOwnLayer(n):void 0;let p=o&&o[d]||{};u&&!o&&(p=u._state.getState(d,void 0));const m=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},g=Object.keys(p).length>0&&!i;s.hasAppearances=s.layers.some(e=>e.appearances&&e.appearances.length>0);const v=g?s.stateDependentLayers:s.layers;if(g&&0!==s.stateDependentLayers.length||i||_||r){const o=this.latestFeatureIndex.loadVTLayers()[d];if(s.update(p,o,a,m,v,i,l,this.tileID.canonical),(r||_)&&(!i||i&&s instanceof e.cT&&(!s.text.uboBinder||s.text.uboBinder.isLightConstant||!s.icon.uboBinder||s.icon.uboBinder.isLightConstant))&&s instanceof e.cT&&f&&"symbol"===f.type){const e=s;e.text&&e.text.uboBinder&&e.text.uboBinder.updateDynamicExpressions(f,o,this.tileID.canonical,a,p,l),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.updateDynamicExpressions(f,o,this.tileID.canonical,a,p,l);}if(s instanceof e.cT){const e=s,i=t.context;e.text&&e.text.uboBinder&&e.text.uboBinder.upload(i),e.icon&&e.icon.uboBinder&&e.icon.uboBinder.upload(i);}}if(g&&0!==s.stateDependentLayers.length||i||s.hasAppearances){const i={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview},o=s.updateAppearances(this.tileID.canonical,p,a,i,t.imageManager,g&&0!==s.stateDependentLayers.length);if(o&&o.hasUboChanges){const i=t.context;s instanceof e.cT&&s.text&&s.text.uboBinder&&s.text.uboBinder.upload(i),s instanceof e.cT&&s.icon&&s.icon.uboBinder&&s.icon.uboBinder.upload(i);}}(s instanceof e.cZ||s instanceof e.c_)&&t._terrain&&t._terrain.enabled&&u&&s.uploadPending()&&t._terrain._clearRenderCacheForTile(u.id,this.tileID);const y=t&&t.style&&t.style.getOwnLayer(n);y&&(this.queryPadding=Math.max(this.queryPadding,y.queryRadius(s)||0));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,i=on[t+0],o=on[t+1],r=on[t+2],n=on[t+3],s=i+r>>1,a=o+n>>1,l=s+a-o,c=a+i-s,h=o*tn+i,d=n*tn+r,u=a*tn+s,_=Math.hypot((rn[2*h+0]+rn[2*d+0])/2-rn[2*u+0],(rn[2*h+1]+rn[2*d+1])/2-rn[2*u+1])>=16;nn[u]=nn[u]||(_?1:0),e<1022&&(nn[u]=nn[u]||nn[(o+c>>1)*tn+(i+l>>1)]||nn[(n+c>>1)*tn+(r+l>>1)]);}const n=new e.cQ,s=new e.cp;let a=0;function l(t,i){const o=i*tn+t;return 0===sn[o]&&(n.emplaceBack(rn[2*o+0],rn[2*o+1],t*e.aj/en,i*e.aj/en),sn[o]=++a),sn[o]-1}function c(e,t,i,o,r,n){const a=e+i>>1,h=t+o>>1;if(Math.abs(e-r)+Math.abs(t-n)>1&&nn[h*tn+a])c(r,n,e,t,a,h),c(i,o,r,n,a,h);else {const a=l(e,t),c=l(i,o),h=l(r,n);s.emplaceBack(a,c,h);}}return c(0,0,en,en,en,0),c(en,en,0,0,0,en),{vertices:n,indices:s}}(this.tileID.canonical,i);r=t.vertices,n=t.indices;}else {r=new e.cQ,n=new e.cp;for(const{x:e,y:t}of o)r.emplaceBack(e,t,0,0);const t=e.d1(r.int16.subarray(0,4*r.length),void 0,4);for(let e=0;e0&&(l=e.aE(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,r,i,s,l,a);}_globePoint(t,i,o,r,n,s,a){let l=e.d4(t,i,o);if(s){const n=1<.5?u=-1:d<-.5&&(u=1);let _=(t/e.aj+o.x)/n+u,f=(i/e.aj+o.y)/n;_=(_-c)*r._pixelsPerMercatorPixel+c,f=(f-h)*r._pixelsPerMercatorPixel+h;const p=[_*r.worldSize,f*r.worldSize,0];e.ad(p,p,s),l=e.d5(l,p,a);}return e.ad(l,l,n)}_makeGlobeTileDebugBorderBuffer(t,i,o,r,n,s){const a=new e.co,l=new e.d0,c=new e.d6,h=(e,t,h,d,u)=>{const _=(h-e)/(u-1),f=(d-t)/(u-1),p=a.length;for(let h=0;hd*e+t;for(let e=0;e{try{const n=o.getHeaderLength(e);if(n>t)return void(this.request=this.fetchHeader(n,i));o.parseHeader(e),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(o.layers))s=Math.max(s,e.dataIndex.at(-1).lastByte);e.byteLength>=s&&(this.entireBuffer=e),i(null,this.entireBuffer||e,r);}catch(e){i(e);}}).catch(e=>{n.signal.aborted||i(e);}),this.request}fetchBandForRender(e,t,i,o){this.fetchBand(e,t,i,r=>{if(r)return void o(r);this.updateTextureDescriptor(e,t,i);const n=this.textureDescriptorPerLayer.get(t);o(null,n?n.img:null);});}fetchBand(t,i,o,r){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void r(new Error("Tile header is not ready"));const s=this.actor;if(!s)return void r(new Error("Can't fetch tile band without an actor"));let a;const l=e.y(String(o),e.y(this.tileID.key,t));let c=this._taskQueue.get(l);c?c.add(r):(c=new Set,c.add(r),this._taskQueue.set(l,c));const h=(e,t)=>{a.complete(e,t),e?r(e):(c.forEach(e=>e(null,t)),this._taskQueue.delete(l));},d=(e,t)=>{if(e)return r(e);const o=s.sendCancelable("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:a},{},h);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{o.abort(),a.cancel();}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e);}};let u;try{u=n.getLayer(t);}catch(e){if("reloading"===this.state)return;throw e}if(!u)return void r(new Error(`Unknown sourceLayer "${t}"`));if(u.hasDataForBand(o))return c.forEach(e=>e(null,null)),void this._taskQueue.delete(l);const _=u.getDataRange([o]);if(a=n.createDecodingTask(_),!a||a.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(_.firstByte,_.lastByte+1));else {const t={...this.requestParams,headers:{Range:`bytes=${_.firstByte}-${_.lastByte}`}},o=new AbortController;if(e.da(t,o.signal).then(({data:e})=>d(null,e)).catch(e=>{o.signal.aborted||d(e);}),null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{o.abort(),a.cancel();}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e);}}}updateNeeded(e,t){return (!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,o){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(o)||!r.hasDataForBand(o))return;const{bytes:n,tileSize:s,buffer:a,offset:l,scale:c}=r.getBandView(o),h=s+2*a,d=new e.t({width:h,height:h},n),u=this.texturePerLayer.get(i);u&&u instanceof e.T&&u.update(d,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:o,img:d,buffer:a,offset:l,tileSize:s,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]});}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1;}}function _n(t,i){const o=Math.pow(2,i.z),r=Math.floor(e.a_(t.getWest())*o),n=Math.floor(e.a$(t.getNorth())*o),s=Math.ceil(e.a_(t.getEast())*o),a=Math.ceil(e.a$(t.getSouth())*o);return i.x>=r&&i.x=n&&i.ythis.maxzoom||e.z{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.A(i)):o&&(Object.assign(this,o),o.raster_layers&&(this.rasterLayers=o.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=fn.fromTileJSON(o),q(o.tiles),this.fire(new e.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.B("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i);};this.provider="string"==typeof this._options.provider?this._options.provider:void 0,this._tileProvider=void 0;const r=e.db(this._options);return r instanceof Error?(this._loaded=!0,this.fire(new e.A(r)),void(t&&t())):this.provider&&!r?(this._loaded=!0,this.fire(new e.A(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=r?this.loadTileJSONWithProvider(r,o):e.dc(this._options,this.map._requestManager,null,i,o))}loadTileJSONWithProvider(t,i){this.provider=t.name;const o=new AbortController;return (async()=>{const{request:r,options:n}=await e.df(this._options,this.map._requestManager,o.signal);if(o.signal.aborted)return;const s=await e.dg(t.name,t.url);if(o.signal.aborted)return;const a=new s(n);let l=null;if(a.load&&r&&(l=await a.load({request:r}),o.signal.aborted))return;this._tileProvider=a;const c=e.dh(this._options,l,this.map._requestManager);c instanceof Error?i(c):i(null,c);})().catch(e=>{o.signal.aborted||i(new Error(`Could not load tile provider ${t.name}`,{cause:e}));}),{cancel:()=>o.abort()}}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.y(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return {...this._options}}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(t,i){const o=e.r.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize),n=new AbortController;if(t.request=n,this._tileProvider)this.loadTileWithProvider(t,this._tileProvider,r,n,i);else try{const o=await this.map._requestManager.transformRequest(r,e.R.Tile,n.signal);if(n.signal.aborted)return delete t.request,i(null);const{data:s,headers:a}=await e.q(o,n.signal);if(delete t.request,t.aborted)return i(null);const l=e.dd(a);this.map._refreshExpiredTiles&&t.setExpiryData(l),t.setTexture(s,this.map.painter),t.state="loaded",e.de(this.dispatcher),i(null);}catch(e){if(delete t.request,n.signal.aborted)return i(null);t.state="errored",i(e);}}async loadTileWithProvider(t,i,o,r,n){const{z:s,x:a,y:l}=t.tileID.canonical;try{const c=await this.map._requestManager.transformRequest(o,e.R.Tile,r.signal);if(r.signal.aborted)return n(null);const h=await i.loadTile({z:s,x:a,y:l},{request:c,signal:r.signal});if(r.signal.aborted)return n(null);if(null==h){const e=new Error("Tile not found");return e.status=404,t.state="errored",n(e)}if(null==h.data)return t.state="loaded",n(null);const d=h.data instanceof ImageBitmap?h.data:await createImageBitmap(new Blob([h.data]));if(r.signal.aborted)return n(null);t.setTexture(d,this.map.painter),t.state="loaded",this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:h.cacheControl,expires:h.expires}),n(null);}catch(e){if(r.signal.aborted)return n(null);t.state="errored",n(new Error(`Could not load tile from ${o}`,{cause:e}));}finally{delete t.request;}}abortTile(e,t){e.request&&(e.request.abort(),delete e.request),t&&t();}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function mn([t,i],o,r,{scaled:n=!0}={}){const{tileSize:s,buffer:a}=r,{x:l,y:c,z:h}=o;if(!isFinite(l)||!isFinite(c)||!isFinite(h))throw new Error("Invalid MRT header");const d=2**h,u=d*e.a_(t),_=d*e.a$(i);return function([e,t],i,{scaled:o=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:n,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>n+s||t<-s||t>n+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${n}, buffer=${s}`);const h=(t+s)*(n+2*s)+(e+s);if(4294967295===new Uint32Array(r.buffer)[h])return null;let d=[];d=o?[]:new(0,i.data.constructor)(c);for(let e=0;e{if(delete t.request,t.aborted)return i(null);if(o)return t.state="errored",i(o);if(this.map._refreshExpiredTiles&&r&&t.setExpiryData(e.dd(n)),this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r;}i(null);};try{const s=await this.map._requestManager.transformRequest(o,e.R.Tile,r.signal);if(r.signal.aborted)return i(null);t.requestParams=s;const a={request:s,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};t.request=this.partial?t.fetchHeader(void 0,(e,t,i)=>{n(e,t,i);}):t.actor.sendCancelable("loadTile",a,{},(e,t)=>e?n(e):t?void n(null,t.mrt,t.headers):n(null,null));}catch(e){if(r.signal.aborted)return i(null);t.state="errored",i(e);}}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!1);for(const e of i.values())this.map.painter.saveTileTexture(e);}else e.destroy();}prepareTile(t,i,o,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,o,r,(i,r)=>{i?(t.state="errored",this.fire(new e.A(i))):r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(o,r,this.map.painter),t.state="loaded"),this.triggerRepaint(t);}));}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let n=null;i instanceof e.di?n=i.paint.get("raster-array-band"):i instanceof e.dj&&(n=i.paint.get("raster-particle-array-band"));const s=n||this.getInitialBand(r);if(null!=s)if(t.textureDescriptorPerLayer.get(i.id)){if(!t.updateNeeded(i.id,s)||o)return {...t.textureDescriptorPerLayer.get(i.id),texture:t.texturePerLayer.get(i.id)}}else this.prepareTile(t,r,i.id,s);}getImages(t,i){const o=new Map;for(const r of t)for(const t of i){const[i,n]=t.split("/"),s=r.getLayer(i);if(!s)continue;if(!s.hasBand(n)||!s.hasDataForBand(n))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(n),h=l+2*c,d={data:new e.t({width:h,height:h},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};o.set(t,d);}return o}queryRasterArrayValueByBandId(t,i,o){const r=i._mrt;return new Promise(n=>{const s={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(o.layerName&&l!==o.layerName)continue;const h={};s[l]=h;for(const{bands:d}of c.dataIndex)for(const u of d)o.bands&&!o.bands.includes(u)||(a.add(e.y(l,u)),i.fetchBand(l,null,u,i=>{e.r.frame(()=>{h[u]=i?null:mn([t.lng,t.lat],r,c.getBandView(u)),a.delete(e.y(l,u)),0===a.size&&n(s);});}));}0===a.size&&n(s);})}_loadTileForQuery(e){if(this._loadTileLoaded[e.uid])return Promise.resolve(e._mrt);if(e.uid in this._loadTilePending)return this._loadTilePending[e.uid];const t=this._fetchTileForQuery(e);return this._loadTilePending[e.uid]=t,t}async _fetchTileForQuery(t){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);try{const o={request:await this.map._requestManager.transformRequest(i,e.R.Tile),uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},r=await t.actor.send("loadTile",o);if(!r)return null;const n=r.mrt;return this.map._refreshExpiredTiles&&t.setExpiryData(e.dd(r.headers)),t._mrt=n,t._isHeaderLoaded=!0,t.state="loaded",this._loadTileLoaded[t.uid]=!0,n}finally{delete this._loadTilePending[t.uid];}}async queryRasterArrayValueByAllBands(e,t,i){return await this._loadTileForQuery(t)?this.queryRasterArrayValueByBandId(e,t,i):null}queryRasterArrayValue(t,i){const o=e.b4.convert(t),r=this.findLoadedParent(o);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(o,r,i):this.queryRasterArrayValueByAllBands(o,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ac.fromLngLat(t,this.map.transform.tileSize),o=this.maxzoom+1,r=1<=r||a<0||a>=r)return null;const l=this.map.style.getSourceCache(this.id),c=new e.br(o,n,o,s,a);return l.findLoadedParent(c,this.minzoom)}}var vn=e.cR([{name:"a_index",type:"Int16",components:1}]);class yn{constructor(t,i,o,r){const n={width:o[0],height:o[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,n,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,n,s.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,r),this.lastInvalidatedAt=0;}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const o=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1});const n=new e.dk;n.reserve(r);for(let e=0;e0){const s=e.r.now(),a=(s-t.timeAdded)/n,l=i?(s-i.timeAdded)/n:-1,c=o.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),u=d&&t.refreshedUponExpiration?1:e.as(d?a:1-l,0,1);return i?{opacity:1,mix:1-u,isFading:a<1}:{opacity:u,mix:0,isFading:a<1}}return {opacity:1,mix:0,isFading:!1}}function bn(t,i,o){if(!t)return null;const r=i.getTextureDescriptor(t,o,!0);if(!r)return null;let{texture:n,mix:s,offset:a,tileSize:l,buffer:c,format:h}=r;if(!n||!h)return null;let d=!1;return "uint32"===h&&(d=!0,s[3]=0,s=Kr(e.dr,s,[0,o.paint.get("raster-particle-max-speed")]),a=Qr(e.dr,a,[0,o.paint.get("raster-particle-max-speed")])),{texture:n,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:d,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function wn(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,n=t+r;return [t,i,(n-r-t)/o,(n-t)/o]}var Tn="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}";lr["_prelude_raster_particle.glsl"]||(lr["_prelude_raster_particle.glsl"]=Tn);var En={building:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nhighp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);\n#ifdef BUILDING_FAUX_FACADE\nvec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);\n#endif\n#endif\n}'),buildingBloom:yr("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:yr("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_pos0.y=1.0-v_pos0.y;\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:yr("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:yr("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;\n#ifdef VIEWPORT_ORIGIN_TOP_LEFT\nv_tex_pos.y=1.0-v_tex_pos.y;\n#endif\ngl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:yr('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:yr("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:yr("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:yr("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),elevatedStructuresDepth:yr("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructures:yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_indicator_cutout.fragment.glsl"\n#include "_prelude_feature_cutout.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;uniform float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,v_height);\n#endif\nout_color*=u_opacity_multiplier;glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),elevatedStructuresDepthReconstruct:yr('#include "_prelude_feature_cutout.fragment.glsl"\n#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}',"in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}")};yr(Tn,"");const Sn=e.cR([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),In=e.cR([{type:"Float32",name:"a_pos_2f",components:2}]);class Cn{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy();}draw(t,i){const o=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.ds,o=new e.cp;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,In.members),this.vignetteIdx=t.context.createIndexBuffer(o);}const r=e.cr.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,o);const e={u_vignetteShape:(n={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:n.vignetteColor};o.draw(t,t.context.gl.TRIANGLES,xi.disabled,$i.disabled,Ji.alphaBlended,yi.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r);}var n;}}class Rn{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;}update(t,i){const o=t.getFreeCameraOptions().position,r=o.toAltitude(),n=o.toLngLat(),s=e.al(n.lng),a=e.al(n.lat),l=t.pixelsPerMeter/i,c=s*e.du,h=e.du*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else {const e=-this._offsetYPrev+h,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=h,this._elevationPrev=r;}}getPosition(){return [this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Dn(e,t){return [-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function An(t){const i=e.dt(1323123451230),o=[];for(let r=0;r({u_matrix:e,u_depth_bias:t}),Fn=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t,u_opacity_multiplier:1}),zn=(e,t,i,o,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:o,u_reset_depth:r}),Bn={building:t=>({u_matrix:new e.ap(t),u_normal_matrix:new e.ap(t),u_opacity:new e.ar(t),u_faux_facade_ao_intensity:new e.ar(t),u_camera_pos:new e.aq(t),u_tile_to_meter:new e.ar(t),u_facade_emissive_chance:new e.ar(t),u_flood_light_color:new e.aq(t),u_flood_light_intensity:new e.ar(t),u_front_cutoff_params:new e.aq(t)}),buildingBloom:t=>({u_matrix:new e.ap(t)}),buildingDepth:t=>({u_matrix:new e.ap(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.ap(t),u_depth_bias:new e.ar(t)}),elevatedStructures:t=>({u_matrix:new e.ap(t),u_ground_shadow_factor:new e.aq(t),u_opacity_multiplier:new e.ar(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.ap(t),u_camera_pos:new e.aq(t),u_depth_bias:new e.ar(t),u_height_scale:new e.ar(t),u_reset_depth:new e.ar(t)}),rasterParticle:t=>({u_matrix:new e.ap(t),u_normalize_matrix:new e.ap(t),u_globe_matrix:new e.ap(t),u_merc_matrix:new e.ap(t),u_grid_matrix:new e.cN(t),u_tl_parent:new e.b$(t),u_scale_parent:new e.ar(t),u_fade_t:new e.ar(t),u_opacity:new e.ar(t),u_image0:new e.b_(t),u_image1:new e.b_(t),u_raster_elevation:new e.ar(t),u_zoom_transition:new e.ar(t),u_merc_center:new e.b$(t),u_cutoff_params:new e.bZ(t)}),rasterParticleTexture:t=>({u_texture:new e.b_(t),u_opacity:new e.ar(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.b_(t),u_particle_texture_side_len:new e.ar(t),u_tile_offset:new e.b$(t),u_velocity:new e.b_(t),u_color_ramp:new e.b_(t),u_velocity_res:new e.b$(t),u_max_speed:new e.ar(t),u_uv_offset:new e.b$(t),u_data_scale:new e.b$(t),u_data_offset:new e.ar(t),u_particle_pos_scale:new e.ar(t),u_particle_pos_offset:new e.b$(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.b_(t),u_particle_texture_side_len:new e.ar(t),u_velocity:new e.b_(t),u_velocity_res:new e.b$(t),u_max_speed:new e.ar(t),u_speed_factor:new e.ar(t),u_reset_rate:new e.ar(t),u_rand_seed:new e.ar(t),u_uv_offset:new e.b$(t),u_data_scale:new e.b$(t),u_data_offset:new e.ar(t),u_particle_pos_scale:new e.ar(t),u_particle_pos_offset:new e.b$(t)}),snowParticle:t=>({u_modelview:new e.ap(t),u_projection:new e.ap(t),u_time:new e.ar(t),u_cam_pos:new e.aq(t),u_velocityConeAperture:new e.ar(t),u_velocity:new e.ar(t),u_horizontalOscillationRadius:new e.ar(t),u_horizontalOscillationRate:new e.ar(t),u_boxSize:new e.ar(t),u_billboardSize:new e.ar(t),u_simpleShapeParameters:new e.b$(t),u_screenSize:new e.b$(t),u_thinningCenterPos:new e.b$(t),u_thinningShape:new e.aq(t),u_thinningAffectedRatio:new e.ar(t),u_thinningParticleOffset:new e.ar(t),u_particleColor:new e.bZ(t),u_direction:new e.aq(t)}),rainParticle:t=>({u_modelview:new e.ap(t),u_projection:new e.ap(t),u_time:new e.ar(t),u_cam_pos:new e.aq(t),u_texScreen:new e.b_(t),u_velocityConeAperture:new e.ar(t),u_velocity:new e.ar(t),u_boxSize:new e.ar(t),u_rainDropletSize:new e.b$(t),u_distortionStrength:new e.ar(t),u_rainDirection:new e.aq(t),u_color:new e.bZ(t),u_screenSize:new e.b$(t),u_thinningCenterPos:new e.b$(t),u_thinningShape:new e.aq(t),u_thinningAffectedRatio:new e.ar(t),u_thinningParticleOffset:new e.ar(t),u_shapeDirectionalPower:new e.ar(t),u_shapeNormalPower:new e.ar(t),u_mode:new e.ar(t)}),vignette:t=>({u_vignetteShape:new e.aq(t),u_vignetteColor:new e.bZ(t)})};function kn(t,i){const o=1<0;--t){const i=Math.floor(e.x/(1<0;--e){const r=Math.floor(t.x/(1<a[t]!=_>a[t]&&s[t]o&&(f|=2),dr&&(f|=8),uo&&(p|=2),_r&&(p|=8),!(f&p)){if(0===f||0===p)return !1;if(Gn(e,d,u,_,t,i,o,r))return !1}}}for(let e=0;e<4;++e)if(!(1&n[e]))return !1;return !0}function Gn(e,t,i,o,r,n,s,a){const l=(e,t,i,o,r,n,s,a)=>{const l=(i-e)*(n-t)-(o-t)*(r-e),c=(i-e)*(a-t)-(o-t)*(s-e);if(l>0&&c>0||l<0&&c<0)return !1;const h=(s-r)*(t-n)-(a-n)*(e-r),d=(s-r)*(o-n)-(a-n)*(i-r);return !(h>0&&d>0||h<0&&d<0)};return !!(l(e,t,i,o,r,n,s,n)||l(e,t,i,o,s,n,s,a)||l(e,t,i,o,r,a,s,a)||l(e,t,i,o,r,n,r,a))}class Vn{constructor(){this._tileCoverages=[],this._snapshot=new Un;}clear(){this._tileCoverages=[];}addTileCoverage(e,t){this._tileCoverages.push({tileId:e,polygons:t,frcMask:Nn(t)});}empty(){return 0===this._tileCoverages.length}updateSnapshotIfNeeded(){if(this._snapshot.equals(this._tileCoverages))return this._snapshot;const e=this._tileCoverages.map(e=>({tileId:e.tileId,polygons:e.polygons,frcMask:e.frcMask}));return this._snapshot=new Un(e),this._snapshot}}class qn{constructor(e,t){this.max=e,this.onRemove=t,this.reset();}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const o=e.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r);},i)),this.data[o].push(r),this.order.push(o),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,o=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][o];return this.data[i].splice(o,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const o of this.data[i])e(o.value)||t.push(o);for(const e of t)this.remove(e.value.tileID,e);}}class Hn{constructor(){this.state=Object.create(null),this.stateChanges=Object.create(null),this.deletedStates=Object.create(null);}updateState(e,t,i){const o=String(t);if(this.stateChanges[e]=this.stateChanges[e]||Object.create(null),this.stateChanges[e][o]=this.stateChanges[e][o]||Object.create(null),Object.assign(this.stateChanges[e][o],i),null===this.deletedStates[e]){this.deletedStates[e]=Object.create(null);for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]=Object.create(null);for(const t in this.state[e][o])i[t]||(this.deletedStates[e][o][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const o=String(t);if(this.deletedStates[e]=this.deletedStates[e]||Object.create(null),i&&void 0!==t)null!==this.deletedStates[e][o]&&(this.deletedStates[e][o]=this.deletedStates[e][o]||Object.create(null),this.deletedStates[e][o][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]=Object.create(null),this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null;}getState(e,t){const i=this.state[e]||Object.create(null),o=this.stateChanges[e]||Object.create(null),r=this.deletedStates[e];if(null===r)return Object.create(null);if(void 0!==t){const e=String(t),n=Object.assign(Object.create(null),i[e],o[e]);if(r){const e=r[t];if(null===e)return Object.create(null);for(const t in e)delete n[t];}return n}const n=Object.assign(Object.create(null),i,o);if(r)for(const e in r)delete n[e];return n}initializeTileState(e,t){e.refreshFeatureState(t);}coalesceChanges(e,t){const i=Object.create(null);for(const e in this.stateChanges){this.state[e]=this.state[e]||Object.create(null);const t=Object.create(null);for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]=Object.create(null)),Object.assign(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||Object.create(null);const t=Object.create(null);if(null===this.deletedStates[e])for(const i in this.state[e])t[i]=Object.create(null),this.state[e][i]=Object.create(null);else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]=Object.create(null);else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||Object.create(null),Object.assign(i[e],t);}if(this.stateChanges=Object.create(null),this.deletedStates=Object.create(null),0!==Object.keys(i).length)for(const o in e)e[o].refreshFeatureState(t,i);}}class Zn extends e.E{constructor(e,t,i){super(),this.id=e,this._renderSourceType=i,this._maxzoomOverride=null,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));}),t.on("error",()=>{this._sourceErrored=!0;}),this._source=t,this._tiles={},this._cache=new qn(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Hn,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles)if(!this._tiles[e].loaded())return !1;return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform);}setMaxzoomOverride(e){this._maxzoomOverride=e;}_loadTile(e,t){return e.renderSourceType=this._renderSourceType,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Wn).map(e=>e.key)}getRenderableIds(t,i){const o=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&o.push(this._tiles[e]);return t?o.sort((t,i)=>{const o=t.tileID,r=i.tileID,n=new e.P(o.canonical.x,o.canonical.y)._rotate(this.transform.angle),s=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-r.overscaledZ||s.y-n.y||s.x-n.x}).map(e=>e.tileID.key):o.map(e=>e.tileID).sort(Wn).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(t,i,o,r,n){if(r){if(t.state="errored",e.dy(r)){if(this._source.fire(new e.B("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else this._source.fire(new e.A(r,{tile:t}));return}t.timeAdded=e.r.now(),"expired"===o&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let s=new Headers;n&&n.headers&&(s=n.headers),this._source.fire(new e.B("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}));}_hasTunnelGeometry(){for(const e in this._tiles){const t=this._tiles[e];if(t&&t.hasTunnelGeometry)return !0}return !1}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,o),e.neighboringTiles&&e.neighboringTiles[n]&&(e.neighboringTiles[n].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,o){for(const r in this._tiles){let n=this._tiles[r];if(o[r]||!n.hasData()||n.tileID.overscaledZ<=t||n.tileID.overscaledZ>i)continue;let s=n.tileID;for(;n&&n.tileID.overscaledZ>t+1;){const e=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[e.key],n&&n.hasData()&&(s=e);}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){o[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),o=this._getLoadedTile(t);if(o)return o}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,o=Math.ceil(e.height/t)+1,r=Math.floor(i*o*5),n="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),e[o.tileID.key]=o;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(t,i,o,r,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;null!==this._maxzoomOverride&&(l=Math.min(l,this._maxzoomOverride));const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t);}const h=null===this._maxzoomOverride&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.br(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.br(1,0,1,0,0)),a.push(new e.br(1,0,1,1,0)),a.push(new e.br(1,0,1,0,1)),a.push(new e.br(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:h,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t));}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),c=Math.min(e,l);if(s){const e=t.extendTileCover(a,c);for(const t of e)a.push(t);}else if(n){const e=this.transform.getFrustum(c),i=t.extendTileCoverToNearPlane(a,e,c);for(const e of i)a.push(e);if(c>=18&&this._hasTunnelGeometry()){const i=t.extendTileCoverForTunnels(a,e,c,20);for(const e of i)a.push(e);}}else if(this.castsShadows&&r){const e=t.extendTileCover(a,c,r,16);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}const d=this._updateRetainedTiles(a);if(this._supportsFading&&0!==a.length){const t={},i={},o=e.r.now(),r=Object.keys(d);for(const e of r){const r=d[e],n=this._tiles[e];if(!n||void 0!==n.fadeEndTime&&n.fadeEndTime<=o)continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-Zn.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[e]=r;}const n=a.at(-1).overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(d[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>n;){o=o.scaledTo(o.overscaledZ-1);const r=this._tiles[o.key];if(r&&r.hasData()&&i[o.key]){d[e]=t.tileID;break}}}for(const e in t)d[e]||(this._coveredTiles[e]=!0,d[e]=t[e]);}for(const e in d)this._tiles[e].clearFadeHold();const u=e.dz(this._tiles,d);for(const e of u){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._renderSourceType===e.dA.Symbol&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},o=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,n=Math.max(r-Zn.maxOverzooming,this._source.minzoom),s=Math.max(r+Zn.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=o.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=o.overscaledZ-1;s>=n;--s){const n=o.scaledTo(s);if(i[n.key])break;if(i[n.key]=!0,e=this.getTile(n),!e&&r&&(e=this._addTile(n)),e&&(t[n.key]=n,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}t.push(o.key);const e=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;o=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return !0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const o=Boolean(i);if(!o){const e=this.map?this.map.painter:null,o=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new un(t,o,this.transform.tileZoom,e,this._isRaster):new dn(t,o,this.transform.tileZoom,e,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.B("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e];},i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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,i,o){const r=[],n=this.transform;if(!n)return r;const s="globe"===n.projection.name,a=e.a_(n.center.lng),l=n.getFreeCameraOptions().position||new e.ac(0,0,0);for(const c in this._tiles){const h=this._tiles[c];if(o&&h.clearQueryDebugViz(),h.holdingForFade())continue;let d;if(s){const t=h.tileID.canonical;if(0===t.z){const i=[Math.abs(e.as(a,...$n(t,-1))-a),Math.abs(e.as(a,...$n(t,1))-a)];d=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.as(a,...$n(t,-1))-a),Math.abs(e.as(a,...$n(t,0))-a),Math.abs(e.as(a,...$n(t,1))-a)];d=[i.indexOf(Math.min(...i))-1];}}else d=[0];for(const e of d){const o=t.containsTile(h,n,i,e,l);o&&r.push(o);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){if(!this.transform)return [];const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),o="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=o?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){if(!this.transform)return e.slice();const t=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return !0;if(this._supportsFading){const t=e.r.now();for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t)return !0}}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const o=this._tiles[e];o&&o.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,t));}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i));};return void this._source.on("data",e)}const o=new Map,r=Array.isArray(t)?t:[t],n=this.map.painter.terrain,s=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)o.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const a=Array.from(o.values());e.dB(a,(e,t)=>{const i=new dn(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);});},i);}}function Wn(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),o=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||o-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function $n(e,t){const i=1<>i===e.x&&t.y>>i===e.y}const i=e.z-t.z;return e.x>>i===t.x&&e.y>>i===t.y}function Yn(e,t){return e.sourceFQID!==t.sourceFQID?e.sourceFQID{return !!e.hasDeferredElevationFeatures||s&&(t=r,Jn(o,i=e.tileID.canonical)!==Jn(t,i));var t,i;});}const fs=e=>({u_matrix:e});function ps(e,t){const i=e.context.gl;return new $i({func:i.EQUAL,mask:255},e._tileClippingMaskIDs[t.key]||0,0,i.KEEP,i.KEEP,i.KEEP)}function ms(e,t){const i=e.context.gl;return new $i({func:i.EQUAL,mask:255},255&~(e._tileClippingMaskIDs[t.key]||0),0,i.KEEP,i.KEEP,i.KEEP)}function gs(t,i){if(!t.frcCoverageSnapshot||!t.frcCoverageRenderer)return null;const o=t.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!o||0===o.frcMask)return null;const r=t.frcCoverageRenderer.getBuffers(o.tileId);if(!r)return null;const n=new e.bu(o.tileId.z,o.tileId.x,o.tileId.y),s=new e.bd(i.wrap,n);return {buffers:r,projMatrix:t.transform.calculateProjMatrix(s),coverageTile:o}}function vs(e,t,i){if(!e.frcCoverageSnapshot)return;const o=e.context,r=o.gl,n=e.getOrCreateProgram("clippingMask");o.setColorMode(Ji.disabled),o.setDepthMode(xi.disabled);for(const o of t){const t=gs(e,o);if(!t)continue;const s=t.buffers.frcLevelSegments[i];s&&n.draw(e,r.TRIANGLES,xi.disabled,new $i({func:r.EQUAL,mask:255},e._tileClippingMaskIDs[o.key]||0,255,r.KEEP,r.KEEP,r.INVERT),Ji.disabled,yi.disabled,fs(t.projMatrix),`$frc_coverage_${i}`,t.buffers.vertexBuffer,t.buffers.indexBuffer,s);}}function ys(e,t,i){if(!e.frcCoverageSnapshot)return;const o=e.context,r=o.gl,n=e.getOrCreateProgram("clippingMask");o.setColorMode(Ji.disabled),o.setDepthMode(xi.disabled);for(const o of t){const t=gs(e,o);if(!t)continue;const s=t.buffers.frcLevelSegments[i];s&&n.draw(e,r.TRIANGLES,xi.disabled,new $i({func:r.EQUAL,mask:255},255&~(e._tileClippingMaskIDs[o.key]||0),255,r.KEEP,r.KEEP,r.INVERT),Ji.disabled,yi.disabled,fs(t.projMatrix),`$frc_coverage_restore_${i}`,t.buffers.vertexBuffer,t.buffers.indexBuffer,s);}}function xs(e,t,i,o,r){if(0===t.length)return;let n=0;for(const e of t)n|=e.frcMask;const s=t.map(e=>e.coord);for(let a=0;a<9;++a)if(n&1<0&&r)for(const i of t)i.frcMask&1<0&&t.rings[0].length>0)return !0;return !1}function ws(e){const t=e.frcCoverageFadeRange;return !t||t[1]<=t[0]?0:1-Math.max(0,Math.min(1,(e.transform.zoom-t[0])/(t[1]-t[0])))}const Ts={loaded:!0,drawBuilding:function(e,t,i,o){e.currentLayer0&&n>0,c=!0;const h=i.paint.get("building-vertical-scale");if(h<=0)return;e.shadowRenderer||(c=!1);const d=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),u=e.style.order.indexOf(i.fqid);if(function(e,t,i,o,r,n){for(const s of n){const n=t.getTile(s).getBucket(i);n&&(r&&n.updateReplacement(s,e.replacementSource,o),n.uploadUpdatedIndexBuffer(e.context));}}(e,t,i,u,d,o),function(e,t,i,o){for(const r of o){const o=t.getTile(r).getBucket(i);o&&o.needsEvaluation()&&o.uploadUpdatedColorBuffer(e.context);}}(e,t,i,o),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=[],n=e.shadowRenderer.getShadowPassDepthMode();qr({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:Ji.disabled,depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}else if("translucent"===e.renderPass){let u=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(u=u.concat("RENDER_SHADOWS")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(u=u.concat("NORMAL_OFFSET"));const _=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),p=i.paint.get("building-flood-light-intensity"),m="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),g=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(m?null:i.lut).toArray01().slice(0,3),v=i.paint.get("building-flood-light-ground-attenuation"),y=p>0,x=new xi(e.context.gl.LEQUAL,xi.ReadWrite,e.depthRangeFor3D);a<1&&qr({painter:e,source:t,layer:i,coords:o,defines:u,blendMode:Ji.disabled,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:_,facadeAOIntensity:f,floodLightIntensity:p,floodLightColor:g,depthOnly:!0});const b=e.colorModeForRenderPass();qr({painter:e,source:t,layer:i,coords:o,defines:u,blendMode:b,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:_,facadeAOIntensity:f,floodLightIntensity:p,floodLightColor:g});const w=i.paint.get("building-front-cutoff");zr(e.transform.pitch,w,!!e.terrain),l&&Hr(e,t,i,o,!0,a,r,n,p,g,s,d),y&&Hr(e,t,i,o,!1,a,r,n,p,g,v,d);}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],n=new xi(e.context.gl.LEQUAL,xi.ReadOnly,e.depthRangeFor3D);qr({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:Ji.alphaBlended,depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks();},BuildingTileBorderManager:class{constructor(){this.visibleTiles=[];}updateBorders(t,i){const o=[],r=[],n=t._getRenderableCoordinates(!1,!0);for(const e of n){const n=t.getTile(e);if(!n.hasData())continue;const s=n.getBucket(i);s&&(s.isEmpty()||(o.push(e.key),r.push({bucket:s,tileID:e.canonical})));}let s=o.length!==this.visibleTiles.length;if(!s){o.sort();for(let e=0;ee.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,o=new Array,r=t.bucket;for(const t of r.featuresOnBorder)r.footprints[t.footprintIndex].hiddenFlags&e.cH||(a.has(t.featureId)?o.push(t.footprintIndex):(a.add(t.featureId),i.push(t.footprintIndex)));r.updateFootprintHiddenFlags(i,e.cI,!1),r.updateFootprintHiddenFlags(o,e.cI,!0);}}},drawRasterParticle:function(t,i,o,r,n,s){"offscreen"===t.renderPass&&function(t,i,o,r){if(!r.length)return;const n=t.context,s=n.gl,a=i.getSource();if(!(a instanceof gn))return;const l=Math.ceil(Math.sqrt(o.paint.get("raster-particle-count")));let c=o.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(t){const i=t*t,o=new Uint8Array(4*i),r=.9090909090909091;for(let t=0;te.c0[t](r));f.push(r);const p=r.canonical.x,m=r.canonical.y;for(const e of f){const n=i.getTile(l?e.wrapped():e);if(!n)continue;const a=n.rasterParticleState;if(!a)continue;const h=e.canonical.x+(1<t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,n)&&o.prepareTile(t,r,e.id,n);},Rain:class extends Pn{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null;}destroy(){super.destroy();}update(t){const i=t.context;if(!this.particlesVx){const t=An(this.particlesCount),o=new e.dv,r=new e.cp;let n=0;const s=e.dt(1323123451230);for(let e=0;ea)return;const l=Ln(0,1,r.revealStart,r.revealStart+r.revealRange,a);if(!this.particlesVx||!this.particlesIdx)return;s.strength*=l;const c=this.updateOnRender(t,o.timeFactor),h=t.context,d=h.gl,u=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(h,{width:t.width,height:t.height,data:null},d.RGBA8)),o.distortionStrength>0&&(h.activeTexture.set(d.TEXTURE0),this.screenTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),d.copyTexSubImage2D(d.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const _=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(h,_),h.activeTexture.set(d.TEXTURE0),this.screenTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE);const f=[o.color.r,o.color.g,o.color.b,o.color.a],p=(i,r)=>{const s=Dn(this._movement.getPosition(),i),a=o.dropletSizeX,l=o.dropletSizeX*o.dropletSizeYScale,h=t.width/2,p=t.height/2,m=Ln(0,o.screenThinning.start,0,1,o.screenThinning.intensity),g=Ln(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),v=Ln(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(x={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[a,l],distortionStrength:o.distortionStrength,rainDirection:n,color:f,screenSize:[u.width,u.height],thinningCenterPos:[h,p],thinningShape:[m,g,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:v,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:r?0:1},{u_modelview:Float32Array.from(x.modelview),u_projection:Float32Array.from(x.projection),u_time:x.time,u_cam_pos:x.camPos,u_texScreen:0,u_velocityConeAperture:x.velocityConeAperture,u_velocity:x.velocity,u_boxSize:x.boxSize,u_rainDropletSize:x.rainDropletSize,u_distortionStrength:x.distortionStrength,u_rainDirection:x.rainDirection,u_color:x.color,u_screenSize:x.screenSize,u_thinningCenterPos:x.thinningCenterPos,u_thinningShape:x.thinningShape,u_thinningAffectedRatio:x.thinningAffectedRatio,u_thinningParticleOffset:x.thinningParticleOffset,u_shapeDirectionalPower:x.shapeDirectionalPower,u_shapeNormalPower:x.shapeNormalPower,u_mode:x.mode});var x;const b=Math.round(o.intensity*this.particlesCount),w=e.cr.simpleSegment(0,0,4*b,2*b);_.draw(t,d.TRIANGLES,xi.disabled,$i.disabled,Ji.alphaBlended,yi.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,w);};o.distortionStrength>0&&p(o.boxSize,!0),p(o.boxSize,!1),this._vignette.draw(t,s);}},Snow:class extends Pn{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null;}destroy(){super.destroy();}update(t){const i=t.context;if(!this.particlesVx){const t=An(this.particlesCount),o=new e.dw,r=new e.cp;let n=0;const s=e.dt(1323123451230);for(let e=0;ea)return;const l=Ln(0,1,r.revealStart,r.revealStart+r.revealRange,a);s.strength*=l;const c=this.updateOnRender(t,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const h=t.context,d=h.gl,u=t.transform,_=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(h,_),((i,o,r)=>{const s=Dn(this._movement.getPosition(),i),a=u.width/2,l=u.height/2,h=Ln(0,r.screenThinning.start,0,1,r.screenThinning.intensity),f=Ln(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),p=Ln(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),m=(g={modelview:c.modelviewMatrix,projection:c.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,horizontalOscillationRadius:r.horizontalOscillationRadius,horizontalOscillationRate:r.horizontalOscillationRate,boxSize:i,billboardSize:1*r.billboardSize,simpleShapeParameters:[r.shapeFadeStart,r.shapeFadePower],screenSize:[u.width,u.height],thinningCenterPos:[a,l],thinningShape:[h,f,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:p,color:[r.color.r,r.color.g,r.color.b,r.color.a],direction:n},{u_modelview:Float32Array.from(g.modelview),u_projection:Float32Array.from(g.projection),u_time:g.time,u_cam_pos:g.camPos,u_velocityConeAperture:g.velocityConeAperture,u_velocity:g.velocity,u_horizontalOscillationRadius:g.horizontalOscillationRadius,u_horizontalOscillationRate:g.horizontalOscillationRate,u_boxSize:g.boxSize,u_billboardSize:g.billboardSize,u_simpleShapeParameters:g.simpleShapeParameters,u_screenSize:g.screenSize,u_thinningCenterPos:g.thinningCenterPos,u_thinningShape:g.thinningShape,u_thinningAffectedRatio:g.thinningAffectedRatio,u_thinningParticleOffset:g.thinningParticleOffset,u_particleColor:g.color,u_direction:g.direction});var g;const v=Math.round(r.intensity*this.particlesCount),y=e.cr.simpleSegment(0,0,4*v,2*v);this.particlesVx&&this.particlesIdx&&_.draw(t,d.TRIANGLES,xi.disabled,$i.disabled,Ji.alphaBlended,yi.disabled,m,"snow_particles",this.particlesVx,this.particlesIdx,y);})(o.boxSize,0,o),this._vignette.draw(t,s);}},shaders:En,programUniforms:Bn,drawElevatedStructures:function(e){const{painter:t,sourceCache:i,layer:o,coords:r,colorMode:n}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new xi(t.context.gl.LEQUAL,xi.ReadOnly,t.depthRangeFor3D);let h=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(h=lo(t.style,e,i));}const d=e=>{for(const d of r){const r=i.getTile(d),u=r.getBucket(o);if(!u)continue;const _=u.hdExt?u.hdExt.elevatedStructures:void 0;if(!_)continue;let f,p;if(e?(f=_.renderableBridgeSegments,p=_.bridgeProgramConfigurations.get(o.id)):(f=_.renderableTunnelSegments,p=_.tunnelProgramConfigurations.get(o.id)),!f||0===f.segments[0].primitiveLength)continue;p.updatePaintBuffers(),t.prepareDrawTile();const m=t.isTileAffectedByFog(d),g=[];l&&g.push("RENDER_SHADOWS","NORMAL_OFFSET");const v=t.getOrCreateProgram("elevatedStructures",{config:p,overrideFog:m,defines:g}),y=t.translatePosMatrix(d.projMatrix,r,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),v,"vector-tile");const x=Fn(y,h);t.uploadCommonUniforms(t.context,v,d.toUnwrapped()),v.draw(t,s.TRIANGLES,c,$i.disabled,n,yi.backCCW,x,o.id,_.vertexBuffer,_.indexBuffer,f,o.paint,t.transform.zoom,p,[_.vertexBufferNormal]);}};d(!0),d(!1);},drawElevatedFillShadows:function(e){const{painter:t,sourceCache:i,layer:o,coords:r}=e,n=t.context.gl,s=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(o);if(!a)continue;const l=a.hdExt?a.hdExt.elevatedStructures:void 0;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(o.id),h=t.isTileAffectedByFog(e),d=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:h}),u=s.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,d,e.toUnwrapped());const _=Mn(u,0);d.draw(t,n.TRIANGLES,s.getShadowPassDepthMode(),$i.disabled,Ji.disabled,yi.disabled,_,o.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,o.paint,t.transform.zoom,c);}},drawDepthPrepass:function(t,i,o,r,n){if(!i)return;if(!o.layout||"none"===o.layout.get("fill-elevation-reference")||0===o.paint.get("fill-opacity").constantOr(1))return;const s=t.context.gl,a=new xi(t.context.gl.LEQUAL,xi.ReadWrite,t.depthRangeFor3D),l=new xi(t.context.gl.GREATER,xi.ReadWrite,t.depthRangeFor3D),c=function(t){let i=.01;return t.isOrthographic&&(i=e.ai(1e-4,i,e.bW(t.pitch>=qi?1:t.pitch/qi))),2*i}(t.transform),h=t.transform.getFreeCameraOptions().position,d="elevatedStructuresDepthReconstruct",u=t.getOrCreateProgram(d,{defines:["DEPTH_RECONSTRUCTION"]}),_=t.getOrCreateProgram(d);for(const e of r){const r=i.getTile(e),d=r.getBucket(o);if(!d)continue;if(!d.hdExt)continue;const f=d.hdExt.elevatedStructures,p=d.hdExt.elevationBufferData;if(!f||!f.depthSegments||!p)continue;const m=p.heightRange,g=kn(e.toUnwrapped(),h),v=t.translatePosMatrix(e.projMatrix,r,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));let y,x,b,w;if("initialize"===n){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;y=zn(v,g,c,1,0),x=a,b=f.depthSegments,w=u;}else if("reset"===n){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;y=zn(v,g,0,0,1),x=l,b=f.maskSegments,w=u;}else if("geometry"===n){if(0===f.depthSegments.segments[0].primitiveLength)continue;y=zn(v,g,c,1,0),x=a,b=f.depthSegments,w=_;}w.draw(t,s.TRIANGLES,x,$i.disabled,Ji.disabled,yi.disabled,y,o.id,f.vertexBuffer,f.indexBuffer,b,o.paint,t.transform.zoom);}},drawGroundShadowMask:function(e,t,i,o){if(!t)return;if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,n=new xi(r.LEQUAL,xi.ReadOnly,e.depthRangeFor3D),s=new $i({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of o){const o=t.getTile(c),h=o.getBucket(i);if(!h)continue;const d=h.hdExt?h.hdExt.elevatedStructures:void 0;if(!d||!d.depthSegments||0===d.depthSegments.segments[0].primitiveLength)continue;const u=kn(c.toUnwrapped(),a),_=e.translatePosMatrix(c.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=zn(_,u,0,1,0);l.draw(e,r.TRIANGLES,n,s,Ji.disabled,yi.disabled,f,i.id,d.vertexBuffer,d.indexBuffer,d.depthSegments,i.paint,e.transform.zoom);}},IndoorManager:class extends e.E{constructor(t,i=!1){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Zr,this._initialLoadDone=!1,e.cL(["_updateUI"],this);const o=()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI();}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI));};i?(this._initialLoadDone=!0,o()):this._style.on("style.load",o);}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null;}selectFloor(e){e===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=e,this._recalculateActiveFloors());}setActiveFloorsVisibility(e){this._updateActiveFloors(e),this._updateIndoorSelector();}setIndoorData(e){let t=!1;for(const[i,o]of Object.entries(e.buildings))if(this._buildings[i])for(const e of o.floorIds)this._buildings[i].floorIds.add(e),this._buildings[i].floors[e]?this._mergeFloors(this._buildings[i].floors[e],o.floors[e]):(this._buildings[i].floors[e]=o.floors[e],t=!0);else this._buildings[i]=o,t=!0;t&&this._recalculateActiveFloors();}getIndoorTileOptions(e,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(e,t),indoorState:this._indoorState}:null}getControlState(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return {selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let o=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){o=e;break}const r=Array.from(i.floorIds).map(e=>({id:e,name:i.floors[e].name,zIndex:i.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex).filter((e,t,i)=>0===t||e.zIndex!==i[t-1].zIndex);return {selectedFloorId:o,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:r}}_updateUI(){this._initialLoadDone=!0;const e=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,e.center,e.zoom,e.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const e=this._closestBuildingId;this._closestBuildingId=t,this._onBuildingTransition(e,t),this._updateIndoorSelector();}}_onBuildingTransition(e,t){if(!this._indoorState)return;const i=!!t&&!e;!t&&e?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):i&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0));}_updateIndoorSelector(){this.fire(new e.B("selector-update",this.getControlState()));}_updateActiveFloors(e){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:e,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0;}_recalculateActiveFloors(){if(!this._buildings)return;const t=e.cM.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(e,t){if(e===t)return !0;if(!e||!t)return !1;if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector());}_mergeFloors(e,t){t.geometry&&(e.geometry?("Polygon"===e.geometry.type&&(e.geometry={type:"MultiPolygon",coordinates:[e.geometry.coordinates]}),"Polygon"===t.geometry.type?e.geometry.coordinates.push(t.geometry.coordinates):"MultiPolygon"===t.geometry.type&&e.geometry.coordinates.push(...t.geometry.coordinates)):e.geometry=t.geometry);}_makeViewportPolygon(){const t=this._style.map.transform,i=t.width,o=t.height;return [t.pointLocation(new e.P(0,0)),t.pointLocation(new e.P(i,0)),t.pointLocation(new e.P(i,o)),t.pointLocation(new e.P(0,o))].map(t=>new e.P(t.lng,t.lat))}},HdCoverageState:class{constructor(){this.coverageSourceCaches={},this.manager=new Vn;}},updateFrcCoverage:function(e,t){t.manager.clear();for(const i in e._mergedHdRoadCoverageSourceCaches){const o=e._mergedHdRoadCoverageSourceCaches[i]._tiles;for(const e in o){const i=o[e];if(!i||!i.loaded())continue;const r=i.frcCoveragePolygons;t.manager.addTileCoverage(i.tileID.canonical,r&&r.length>0?r:[]);}}const i=t.manager.updateSnapshotIfNeeded();if(e.map.painter&&(e.map.painter.frcCoverageSnapshot=i.empty()?null:i),!i.empty()){const t=[e._mergedOtherSourceCaches,e._mergedSymbolSourceCaches];for(const e of t)for(const t in e){const i=e[t];for(const e in i._tiles){const t=i._tiles[e];t&&t.hasDeferredRoadStructure&&(t.hasDeferredRoadStructure=!1,i._reloadTile(+e,"reloading"));}}}},updateHdCoverageSourceCache:function(t,i,o){if("fill"!==o.type||o.sourceLayer!==e.dC)return;if(i.coverageSourceCaches[o.source])return;const r=t.getOwnSource(o.source);if(!r||"vector"!==r.type)return;const n=`hd-road-coverage:${o.source}`,s=e.y(n,t.scope),a=t._sourceCaches[n]=new Zn(s,r,e.dA.HdRoadCoverage);i.coverageSourceCaches[o.source]=a,a.setMaxzoomOverride(14),a.onAdd(t.map);const l=t._otherSourceCaches[o.source];l&&l._sourceLoaded&&(a._sourceLoaded=!0);},updateFrcCoverageFadeRange:function(t,i){let o=null,r=null;const n={globals:{zoom:0}};t.forEachFragmentStyle(i=>{if(o)return;const s=i.stylesheet?i.stylesheet.schema:null;if(!s||!s.sdCoverageFadeRange)return;const a=e.y("sdCoverageFadeRange",i.scope),l=i.options?i.options.get(a):void 0,c=l?l.value||l.default:null;if(c){const e=c.evaluate(n);Array.isArray(e)&&2===e.length&&(e[0]>0||e[1]>0)&&(o=[e[0],e[1]]);}const h=e.y("sdCoverageSourceLayers",i.scope),d=i.options?i.options.get(h):void 0,u=d?d.value||d.default:null;if(u){const e=u.evaluate(n);Array.isArray(e)&&e.length>0&&(r=e);}else {const e=t.stylesheet&&t.stylesheet.imports||[];for(const t of e)if(t.id===i.scope){const e=t.config?t.config.sdCoverageSourceLayers:void 0;Array.isArray(e)&&e.length>0&&(r=e);break}}}),i.frcCoverageFadeRange=o,i.frcCoverageSourceLayers=null!=o?r||["road","structure"]:[];},HdElevationState:cs,setupAndUpdateElevationCoverage:function(t){if(!function(e){for(const t in e._mergedLayers)if(os(e._mergedLayers[t]))return !0;return !1}(t))return void ds(t);const i=Wt(t,t.map&&t.map.transform);t._hdElevation||(t._hdElevation=new cs);const o=t._hdElevation._terrainActiveLast;if(t._hdElevation._terrainActiveLast=i,void 0!==o&&o!==i&&ls(t,void 0,!0),i)return void(t.map.painter&&(t.map.painter.elevationCoverageSnapshot=null));if(!ss(t))return void ds(t);void 0===o&&ls(t,void 0,!0);const r=t._hdElevation;r._needsCrossSourceElevation=!0,t._crossSourceElevationActive=!0,r._ingestFQIDs=as(t);const n=ns(t);t.forEachFragmentStyle(t=>{for(const i of n){if(!es(i,t.scope))continue;const o=e.dD(i);if(t._otherSourceCaches[o]||t._symbolSourceCaches[o])continue;const r=t.getOwnSource(o);r&&"vector"===r.type&&(t._hdElevation||(t._hdElevation=new cs),us(t,t._hdElevation,r));}}),t.mergeSources(),_s(t,r);},updateElevationCoverage:_s,updateHdElevationSourceCache:us,markElevationIngestSourceCachesUsed:function(e){if(!e._hdElevation||!e._hdElevation._needsCrossSourceElevation)return;const t=e._hdElevation._ingestFQIDs;if(t)for(const i of t){const t=ts(e,i);t&&(t.used=!0);}},updateCrossSourceElevationGate:function(e){e._crossSourceElevationActive=ss(e);const t=e._mergedHdRoadElevationSourceCaches;t&&0!==Object.keys(t).length&&(e._hdElevation||(e._hdElevation=new cs),e._hdElevation._needsCrossSourceElevation=e._crossSourceElevationActive);},buildElevationRequestParams:function(t,i,o){if(i.renderSourceType===e.dA.HdRoadElevation)return null;if(Wt(t.style,t.transform))return null;if(!o)return null;const r=t.painter?t.painter.elevationCoverageSnapshot:null,n=!(!t.painter||!t.painter.elevationProvidersReady);return r?function(e,t,i){const o=e.getTilesIntersecting(t);if(0===o.length)return {registry:[],hasCoveringTile:!1,allProvidersReady:i};const r=[];for(const e of o)for(const t of e.features)r.push({tileId:e.tileId,feature:t});return r.sort((e,t)=>e.feature.id-t.feature.id),{registry:r,hasCoveringTile:!0,allProvidersReady:i}}(r,i.tileID.canonical,n):{registry:[],hasCoveringTile:!1,allProvidersReady:n}},FrcCoverageRenderer:class{constructor(){this.tileBuffers=new Map,this._context=null;}update(e,t){this._context=e;const i=new Set;for(const o of t){if(0===o.frcMask)continue;let t=!1;for(const e of o.polygons)if(e.hasGeometry()){t=!0;break}if(!t)continue;const r=`${o.tileId.z}/${o.tileId.x}/${o.tileId.y}`;if(i.add(r),!this.tileBuffers.has(r)){const t=this._createBuffers(e,o);t&&this.tileBuffers.set(r,t);}}for(const e of this.tileBuffers.keys())if(!i.has(e)){const t=this.tileBuffers.get(e);t.vertexBuffer.destroy(),t.indexBuffer.destroy();for(const e of t.frcLevelSegments)e&&e.destroy();this.tileBuffers.delete(e);}}getBuffers(e){return this.tileBuffers.get(`${e.z}/${e.x}/${e.y}`)||null}destroy(){for(const e of this.tileBuffers.values()){e.vertexBuffer.destroy(),e.indexBuffer.destroy();for(const t of e.frcLevelSegments)t&&t.destroy();}this.tileBuffers.clear();}_createBuffers(t,i){const o=new e.co,r=new e.cp,n=[];for(const t of i.polygons){if(!t.hasGeometry()||0===t.rings.length)continue;const i=o.length,s=r.length,a=o.length,l=[],c=[];let h=0;for(let e=0;e0&&c.push(h);for(const e of i)o.emplaceBack(e.x,e.y),l.push(e.x,e.y),h++;}}const d=e.d1(l,c.length>0?c:void 0);for(let e=0;e0&&e.program.draw(t,e.drawMode,e.depthMode,e.stencilMode,e.colorMode,yi.disabled,e.uniformValues,e.layer.id,e.bufferData.layoutVertexBuffer,e.indexBuffer,l.frcNonRoadSegments,e.layer.paint,o,e.programConfiguration,e.dynamicBuffers),"drawn"}return "fallthrough"},drawFillFrcCoverageSecondPass:function(e,t,i,o,r){if(0===i.length)return;const n=ws(e),s=e.transform.zoom,a=(i,n,a)=>{1!==a&&(i.uniformValues.u_opacity_multiplier=a),i.program.draw(e,o,i.depthMode,n,r,yi.disabled,i.uniformValues,t.id,i.bufferData.layoutVertexBuffer,i.indexBuffer,i.segments,t.paint,s,i.programConfiguration,i.dynamicBuffers),1!==a&&(i.uniformValues.u_opacity_multiplier=1);};xs(e,i,n,(e,t,i)=>a(e,i,1),(e,t,i)=>a(e,i,n));},drawLineFrcCoverageDetect:function(e,t,i,o,r,n,s,a,l,c){const h=t.hdExt&&t.hdExt.frcData;if(!h||0===h.frcPerLevel.size)return null;if(!e.frcCoverageSnapshot||o)return null;const d=e.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!d||0===d.frcMask)return null;const u=bs(d.polygons),_=e.frcCoverageFadeRange,f=null!=_&&e.transform.zoom>=_[0];if(u&&f){let e=!1;for(const t of h.frcPerLevel.keys())if(d.frcMask&1<0&&o(i,s);},drawLineFrcFadePass:function(e,t,i,o,r,n,s){if(o.hasPolygonGeometry)return;const a=t.hdExt&&t.hdExt.frcData;if(!a||!e.frcCoverageFadeRange)return;const[l,c]=e.frcCoverageFadeRange;if(l>=c)return;const h=1-Math.max(0,Math.min(1,(e.transform.zoom-l)/(c-l)));if(h<=0)return;const d=r?n:e.stencilModeForClipping(i),u=o.frcMask;for(const[e,t]of a.frcPerLevel)u&1<{const l=i.bucket.hdExt&&i.bucket.hdExt.frcData,c=l&&l.frcPerLevel.get(r);c&&0!==c.segments.length&&(1!==a&&(i.uniformValues.u_opacity_multiplier=a),i.program.draw(e,o.TRIANGLES,i.depthMode,s,i.colorMode,yi.disabled,i.uniformValues,t.id,i.bucket.layoutVertexBuffer,i.bucket.indexBuffer,c,t.paint,n,i.programConfiguration,[i.bucket.layoutVertexBuffer2,i.bucket.patternVertexBuffer,i.bucket.zOffsetVertexBuffer,i.bucket.elevationIdColVertexBuffer,i.bucket.elevationGroundScaleVertexBuffer]),1!==a&&(i.uniformValues.u_opacity_multiplier=1));};xs(e,i,r,(e,t,i)=>s(e,t,i,1),(e,t,i)=>s(e,t,i,r));}},Es=Ts;async function Ss(){return Promise.resolve()}class Is{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.P||"number"==typeof t[0]){const n=e.P.convert(t);o=[n],r=i.isPointAboveHorizon(n);}else {const n=e.P.convert(t[0]),s=e.P.convert(t[1]),a=n.add(s)._div(2);o=[n,s],r=e.dF(n,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a);}return new Is(o,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.dF(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.dF(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.dG(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.dF(i,o,t),n=this.cameraPoint.clone(),s=Number(n.x>i.x)+Number(n.x>o.x);switch(3*(Number(n.y>i.y)+Number(n.y>o.y))+s){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(t,i,o,r=0,n){const s=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,a=o?this._bufferedCameraMercator(s,i):this._bufferedScreenMercator(s,i);let l=t.tileID.wrap+(a.unwrapped?r:0);const c=a.polygon.map(i=>e.dH(t.tileTransform,i,l));if(!e.bp(c,0,0,e.aj,e.aj))return;l=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const h=this.screenGeometryMercator.polygon.map(i=>e.dI(t.tileTransform,i,l)),d=h.map(t=>new e.P(t[0],t[1])),u=e.dI(t.tileTransform,n,l),_=h.map(t=>{const i=e.aW(t,t,u);return e.au(i,i),new e.bC(u,i)}),f=e.c1(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:d,tilespaceRays:_,bufferedTilespaceGeometry:c,bufferedTilespaceBounds:(p=e.dJ(c),p.min.x=e.as(p.min.x,0,e.aj),p.min.y=e.as(p.min.y,0,e.aj),p.max.x=e.as(p.max.x,0,e.aj),p.max.y=e.as(p.max.y,0,e.aj),p),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var p;}_bufferedScreenMercator(e,t){const i=Ds(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=Ds(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.aP([],i.pixelMatrix,i.globeMatrix),r=[0,-e.dK,0,1],n=[0,e.dK,0,1],s=[0,0,0,1];e.aO(r,r,o),e.aO(n,n,o),e.aO(s,s,o);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(n[0]/n[3],n[1]/n[3]),c=e.dL(t,a)&&r[3]1?Cs(t.slice(0,u),i):[],p=unew e.P(Rs(t.x),t.y)),p=p.map(t=>new e.P(Rs(t.x),t.y));const m=[...f];0===m.length&&m.push(p.at(-1));const g=m.at(-1),v=e.ai(g.y,(0===p.length?f[0]:p[0]).y,_);let y;return y=c?[new e.P(0,v),new e.P(0,0),new e.P(1,0),new e.P(1,v)]:[new e.P(1,v),new e.P(1,1),new e.P(0,1),new e.P(0,v)],m.push(...y),0===p.length?m.push(f[0]):m.push(...p),{polygon:m.map(t=>new e.ac(t.x,t.y)),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,n=0;for(let e=0;er&&(r=t[e].x,n=e);for(let e=0;e.5&&(r.x{e.x-=1;}),{polygon:t,unwrapped:o}}(Cs(t,i).map(t=>new e.P(Rs(t.x),t.y)),i);return {polygon:r.polygon.map(t=>new e.ac(t.x,t.y)),unwrapped:r.unwrapped}}}function Cs(t,i){return e.dM(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;},1/256)}function Rs(e){return e<0?1+e%1:e%1}function Ds(e){return 100*e|0}class As extends e.E{constructor(t,i,o,r){if(super(),this.id=t,this.dispatcher=o,this.type="vector",this.provider=i.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,e.b5(i,["url","scheme","tileSize","promoteId"])),this._options={type:"vector",...i},this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.dN;}load(t){this._loaded=!1,this.fire(new e.B("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview(),r=(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.A(r))):n&&(this._setTileJSON(n),Es.updateCrossSourceElevationGate&&this.map.style&&Es.updateCrossSourceElevationGate(this.map.style),q(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.B("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);};this.provider=this._options.provider;const n=e.db(this._options);return n instanceof Error?(this._loaded=!0,this.fire(new e.A(n)),void(t&&t())):this.provider&&!n?(this._loaded=!0,this.fire(new e.A(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=n?this.loadTileJSONWithProvider(n,r):e.dc(this._options,this.map._requestManager,i,o,r))}loadTileJSONWithProvider(t,i){this.provider=t.name;const o=new AbortController;return (async()=>{const{request:r,options:n}=await e.df(this._options,this.map._requestManager,o.signal);if(o.signal.aborted)return;const s=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:n,request:r},{signal:o.signal});if(o.signal.aborted)return;const a=s?s.find(e=>null!=e):null,l=e.dh(this._options,a,this.map._requestManager);l instanceof Error?i(l):i(null,l);})().catch(e=>{o.signal.aborted||i(e);}),{cancel:()=>o.abort()}}_setTileJSON(e){if(Object.assign(this,e),this.hasWorldviews=!!e.worldview_options,e.worldview_default&&(this.worldviewDefault=e.worldview_default),e.vector_layers){this.vectorLayers=e.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const t of e.vector_layers)this.vectorLayerIds.push(t.id),e.worldview&&e.worldview[t.source]&&this.localizableLayerIds.add(t.id);}this.tileBounds=fn.fromTileJSON(e);}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.y(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest();}serialize(){return {...this._options}}async loadTile(t,i){const o=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(o),n=!t.actor||"expired"===t.state;if(!n&&"loading"===t.state)return void(t.reloadCallback=i);n&&(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor());const s=new AbortController;t.request=s;try{const a=await this.map._requestManager.transformRequest(r,e.R.Tile,s.signal);if(s.signal.aborted)return i(null);this.dispatchTile(t,r,o,a,s,n,i);}catch(e){if(s.signal.aborted)return i(null);i(e);}}dispatchTile(t,i,o,r,n,s,a){const l=this.map.style?this.map.style.getLut(this.scope):null,c=l?{image:l.image.clone()}:null,h=!(!this.map.style||!this.map.style._crossSourceElevationActive),d=!(!this.map.style||!h),u={request:r,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:c,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.r.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,frcCoverage:(()=>{const e=this.map.painter,i=e?e.frcCoverageFadeRange:null;if(null==i)return null;const o=e?e.frcCoverageSnapshot:null,r=this.map.transform.zoom=Math.ceil(i[1]),a=o&&s?o.getFullCoverageMask(t.tileID.canonical):null;return {frcMask:s&&null!=a?a:null,resolved:r||null!=o,polygons:n&&0!==n.frcMask?n.polygons:null,tileZoom:n&&0!==n.frcMask?n.tileId.z:null,sourceLayers:e?e.frcCoverageSourceLayers:["road","structure"]}})(),terrainEnabled:Wt(this.map.style,this.map.transform),crossSourceElevationEnabled:d,elevation:Es.buildElevationRequestParams?Es.buildElevationRequestParams(this.map,t,h):null,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&e.e(o)&&(u.localizableLayerIds=this.localizableLayerIds),u.request.collectResourceTiming=this._collectResourceTiming,s)if(this.dispatcher.ready||this.provider)t.request=t.actor.sendCancelable("loadTile",u,{},_.bind(this));else {const i=e.dO.call({deduped:this._deduped},u,(e,i)=>{t.aborted||(e||!i?_.call(this,e):(u.data={rawData:i.rawData.slice(0),headers:i.headers},t.actor&&(t.request=t.actor.sendCancelable("loadTile",u,{},_.bind(this)))));},!0);n.signal.addEventListener("abort",i,{once:!0});}else t.request=t.actor.sendCancelable("reloadTile",u,{},_.bind(this));function _(i,o){return delete t.request,t.aborted?a(null):i?a(i):(o&&o.resourceTiming&&(t.resourceTiming=o.resourceTiming),this.map._refreshExpiredTiles&&o&&t.setExpiryData(e.dd(o.headers)),void function(){if(t.aborted)return a(null);t.loadVectorData(o,this.map.painter),e.de(this.dispatcher),a(null,o),t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null);}.call(this))}}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,t){e.actor&&e.actor.notify("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function Ls(t,i,o,r,n,s,a,l){const c=[t,i,1,o,r,1,n,s,1],h=[a,l,1],d=e.dT([],c),[u,_,f]=e.c4(h,h,d);return e.dU(c,c,[u,0,0,0,_,0,0,0,f])}function Ps(t,i,o,r,n,s,a,l){const c=function(t,i,o,r,n,s,a,l){const c=Ls(0,0,1,0,1,1,0,1),h=Ls(t,i,o,r,n,s,a,l),d=e.dT([],c);return e.dU(h,h,d)}(t,i,o,r,n,s,a,l);return [c[2]/c[8]/e.aj,c[5]/c[8]/e.aj]}function Os(t){return [t[0],Math.min(Math.max(t[1],-e.bA),e.bA)]}class Ms extends e.E{constructor(e,t,i,o){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(o),this.options=t,this._dirty=!1;}async load(t,i){if(this._loaded=i||!1,this.fire(new e.B("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();const o=new AbortController;this._imageRequest=o;try{const i=await this.map._requestManager.transformRequest(this.url,e.R.Image,o.signal),{data:r}=await e.q(i,o.signal);this._imageRequest=null,this._loaded=!0,this.image=r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading();}catch(t){if(o.signal.aborted)return;this._imageRequest=null,this._loaded=!0,this.fire(new e.A(t));}}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.abort(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new e.dP(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.B("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(t){this._imageRequest&&(this._imageRequest.abort(),this._imageRequest=null),!this.texture||this.texture instanceof e.dP||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let i=t[0][1],o=t[0][1];for(const e of t)e[1]>o&&(o=e[1]),e[1]e.bA?this.onNorthPole=!0:r<-e.bA&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const i=t.map(e.ac.fromLngLat);this.tileID=function(t){let i=1/0,o=1/0,r=-1/0,n=-1/0;for(const e of t)i=Math.min(i,e.x),o=Math.min(o,e.y),r=Math.max(r,e.x),n=Math.max(n,e.y);const s=Math.max(r-i,n-o),a=Math.max(0,Math.floor(-Math.log2(s))),l=Math.pow(2,a);let c=Math.floor((i+r)/2*l);return c>1&&(c-=1),new e.bu(a,c,Math.floor((o+n)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new e.B("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof e.dP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=e.cO(new e.bu(0,0,0),this.map.transform.projection),o=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,o=e[2].x-e[1].x,r=e[2].y-e[1].y,n=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*r-o*i,h=o*s-n*r,d=n*l-a*s,u=a*i-t*l;return c>0&&h>0&&d>0&&u>0||c<0&&h<0&&d<0&&u<0}(o))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const r=e.cO(this.tileID,this.map.transform.projection),[n,s,a,l]=this.coordinates.map(t=>{const i=r.projection.project(t[0],t[1]);return e.dH(r,i)._round()});this.perspectiveTransform=Ps(n.x,n.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new e.cQ;c.emplaceBack(n.x,n.y,0,0),c.emplaceBack(s.x,s.y,e.aj,0),c.emplaceBack(l.x,l.y,0,e.aj),c.emplaceBack(a.x,a.y,e.aj,e.aj),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(c,ln.members),this.boundsSegments=e.cr.simpleSegment(0,0,4,2);const h=e.dS,d=h+1,u=h+1,_=d*u,f=h*h*2,p=[],m=function(e){return [Os(e[0]),Os(e[1]),Os(e[2]),Os(e[3])]}(this.coordinates),[g,v,y,x]=function(e){let t=e[0][0],i=t,o=e[0][1],r=o;for(let n=1;ni&&(i=e[n][0]),e[n][1]r&&(r=e[n][1]);return [t,o,i-t,r-o]}(m);{const r=new e.cQ,[n,s,a,l]=function(e){let t=e[0].x,i=t,o=e[0].y,r=o;for(let n=1;ni&&(i=e[n].x),e[n].yr&&(r=e[n].y);return [t,o,i-t,r-o]}(o),c=e=>[(e.x-n)/a,(e.y-s)/l],[_,f,m,b]=o.map(c),w=function(t,i,o,r,n,s,a,l){const c=Ls(0,0,1,0,1,1,0,1),h=Ls(t,i,o,r,n,s,a,l),d=e.dT([],h);return e.dU(c,c,d)}(_[0],_[1],f[0],f[1],m[0],m[1],b[0],b[1]);this.elevatedGlobePerspectiveTransform=Ps(_[0],_[1],f[0],f[1],m[0],m[1],b[0],b[1]);const T=(t,i)=>{p.push(t.lng);const o=Math.round((t.lng-g)/y*e.aj),n=Math.round((t.lat-v)/x*e.aj),s=c(i),a=e.c4([],[s[0],s[1],1],w),l=Math.round(a[0]/a[2]*e.aj),h=Math.round(a[1]/a[2]*e.aj);r.emplaceBack(o,n,l,h);},E=o[3].x-o[0].x,S=o[3].y-o[0].y,I=o[2].x-o[1].x,C=o[2].y-o[1].y;for(let e=0;e{o.emplaceBack(e,t,r);const n=p[e],s=p[t],a=p[r],l=Math.min(Math.min(n,s),a),c=Math.max(Math.max(n,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),i.push(l+c/2);};for(let e=0;et);o.sort((e,i)=>t[e]-t[i]);const r=[],n=new e.cp;for(let e=0;e{s.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:i.segments[0].vertexLength,primitiveLength:t,sortKey:void 0,vaos:{}});},l=.51*this.maxLongitudeTriangleSize;if(Math.abs(o[0]-r)<=l){const t=e.dQ(o,0,o.length,r+l);return t===o.length||a(t,e.dR(o,t+1,o.length,r+360-l)-t),s}r{const{request:r,options:n}=await e.df(this._options,this.map._requestManager,o.signal);if(o.signal.aborted)return;const s=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.type,options:n,request:r},{signal:o.signal});if(o.signal.aborted)return;const a=s?s.find(e=>null!=e):null,l=e.dh(this._options,a,this.map._requestManager);l instanceof Error?i(l):i(null,l);})().catch(e=>{o.signal.aborted||i(e);}),{cancel:()=>o.abort()}}async loadTile(t,i){if(t.actor&&"expired"!==t.state)return;const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.actor=this.dispatcher.getActor();const r=new AbortController;t.request=r;try{const n=await this.map._requestManager.transformRequest(o,e.R.Tile,r.signal);if(r.signal.aborted)return i(null);t.request=t.actor.sendCancelable("loadTile",{uid:t.uid,tileID:t.tileID,source:this.id,type:this.type,scope:this.scope,request:n,encoding:this.encoding},{},function(o,r){return delete t.request,t.aborted?i(null):o?(t.state="errored",i(o)):(r&&(this.map._refreshExpiredTiles&&t.setExpiryData(e.dd(r.headers)),r.borderReady||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID)),t.dem=r.dem,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0),t.state="loaded",void i(null))}.bind(this));}catch(e){if(r.signal.aborted)return i(null);t.state="errored",i(e);}}abortTile(e,t){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),t&&t();}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,n=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+o)%o,a=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.br(t.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},l[new e.br(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.br(t.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1},l[new e.br(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.br(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1t(null,e)).catch(e=>t(e)),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope}).then(e=>t(null,e)).catch(e=>t(e)),this}getClusterLeaves(e,t,i,o){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i}).then(e=>o(null,e)).catch(e=>o(e)),this}async _updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.B("dataloading",{dataType:"source"})),this._loaded=!1;const i={append:t,...this.workerOptions};i.scope=this.scope;const o=this._data,r=new AbortController;this._pendingLoad=r;try{if("string"==typeof o){if(i.request=await this.map._requestManager.transformRequest(e.r.resolveURL(o),e.R.Source,r.signal),r.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);i.request.collectResourceTiming=this._collectResourceTiming;}else i.data=JSON.stringify(o);const n=await this.actor.send(`${this.type}.loadData`,i,{signal:r.signal});this._loaded=!0,this._pendingLoad=null;const s={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(s.resourceTiming=n.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.B("data",s)),this._partialReload=!1,this._metadataFired=!0;}catch(t){if(r.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);this._loaded=!0,this._pendingLoad=null,this.fire(new e.A(t));}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);}loaded(){return this._loaded}reload(){const t=e.y(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData();}loadTile(t,i){const o=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,n=r?{image:r.image.clone()}:null,s=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:n,scope:this.scope,pixelRatio:e.r.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.sendCancelable(o,a,{},(e,r)=>s&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===o),void i(null))));}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.aborted=!0;}unloadTile(e,t){this.actor.notify("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(e){this._pendingLoad&&this._pendingLoad.abort();}serialize(){return {...this._options,type:this.type,data:this._data}}hasTransition(){return !1}},video:class extends Ms{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type="video",this.options=t;}async load(){this._loaded=!1;const t=this.options,i=new AbortController;this._imageRequest=i;try{const o=await Promise.all(t.urls.map(async t=>(await this.map._requestManager.transformRequest(t,e.R.Source,i.signal)).url));if(i.signal.aborted)return;this.urls=o;const r=await e.dV(o);if(i.signal.aborted)return;this._imageRequest=null,this.video=r,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint();}),this.map&&this.video.play(),this._finishLoading();}catch(t){if(i.signal.aborted)return;this.fire(new e.A(t));}finally{this._loaded=!0;}}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.A(new $e(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.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 e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:"video",urls:this.options.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ms,model:e.dW,"batched-model":class extends e.E{constructor(e,t,i,o){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(o);}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.y(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}load(t){this._loaded=!1,this.fire(new e.B("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=e.dc(this._options,this.map._requestManager,i,o,(r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.A(r))):n&&(Object.assign(this,n),n.bounds&&(this.tileBounds=new fn(n.bounds,this.minzoom,this.maxzoom)),q(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.B("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r);});}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}async loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r=!t.actor||"expired"===t.state;if(r)t.actor=this.dispatcher.getActor();else {if("loading"===t.state)return void(t.reloadCallback=i);if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}}const n=r?"loadTile":"reloadTile",s=new AbortController;t.request=s;const a=(o,r)=>(delete t.request,t.aborted?i(null):o&&!e.dy(o)?i(o):(this.map._refreshExpiredTiles&&r&&t.setExpiryData(e.dd(r.headers)),t.loadModelData(r,this.map.painter),t.state="loaded",i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null))));try{const r=await this.map._requestManager.transformRequest(o,e.R.Tile,s.signal);if(s.signal.aborted)return i(null);const l={request:r,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.r.devicePixelRatio,promoteId:this.promoteId};t.request=t.actor.sendCancelable(n,l,{},a);}catch(e){if(s.signal.aborted)return i(null);i(e);}}abortTile(e){e.request&&(e.request.abort(),delete e.request),e.actor&&e.actor.notify("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}serialize(){return {...this._options}}},canvas:class extends Ms{constructor(t,i,o,r){super(t,i,o,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.A(new $e(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.A(new $e(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.A(new $e(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.A(new $e(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.A(new $e(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}async load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.A(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(e){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.dP||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.E{constructor(t,i,o,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.A(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.A(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new fn(this._implementation.bounds,this.minzoom,this.maxzoom));const n=i;n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.b5(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.b5(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.B("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.B("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.B("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}async loadTile(e,t){const{x:i,y:o,z:r}=e.tileID.canonical,n=new AbortController;e.request=n;try{const s=await this._implementation.loadTile({x:i,y:o,z:r},{signal:n.signal});if(delete e.request,e.aborted)return e.state="unloaded",t(null);if(void 0===s)return e.state="errored",t(null);if(null===s)return this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null);if(!function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(s))return e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`));this.loadTileData(e,s),e.state="loaded",t(null);}catch(i){if(n.signal.aborted)return;e.state="errored",t(i);}}loadTileData(e,t){e.setTexture(t,this.map.painter);}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}i&&i();}abortTile(e,t){e.request&&(e.request.abort(),delete e.request),t&&t();}hasTransition(){return !1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){const t=e.y(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.B("data",{dataType:"source",sourceDataType:"content"}));}}},zs=function(t,i,o,r){const n=Bs(i.type);if(!n)throw new Error(`Unknown source type "${i.type}"`);const s=new n(t,i,o,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return e.cL(["load","abort","unload","serialize","prepare"],s),s},Bs=function(e){return Object.hasOwn(Fs,e)?Fs[e]:void 0};function ks(e,t,i=""){return `${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return `layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return `featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function Ns(e,t,i,o=""){if(e.uniqueFeatureID){const r=ks(e,t,o);if(i.has(r))return !0;i.add(r);}return !1}function Us(e,t,i,o,r=!1,n=void 0){const s=t.sourceCache.transform,a=t.sourceCache.tilesIn(e,t.has3DLayers,r);a.sort(Vs);const l=[];for(const e of a){const a=e.tile.queryRenderedFeatures(t,e,i,o,s,r,n);Object.keys(a).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:a});}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,o);Object.keys(i).length&&l.push({wrappedTileID:0,queryResults:i});}}return 0===l.length?{}:function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,n=i[r]=i[r]||{};for(const i in e){const o=e[i],r=n[i]=n[i]||{},s=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e));}}return t}(l)}function js(e,t,i,o,r,n){const s={},a=o.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(Vs);for(const e of l){const o=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,n);for(const t in o){const i=s[t]=s[t]||[],r=o[t];r.sort((t,i)=>{const o=e.featureSortOrder;if(o){const e=o.indexOf(t.featureIndex);return o.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e);}}return s}function Gs(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),o=[],r={};for(let e=0;e0:"building"===i.type?o=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let n=o?o.getTile(t):null;if(!n&&o)for(const e in o._tiles){const i=o._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){n=i;break}}this.currentBuildingBuckets.push({bucket:n?n.getBucket(i):null,tileID:n?n.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o{e in n&&(s[e]=n[e]);}),o}function $s(e){e=e.slice();const t=Object.create(null);for(const i of e)t[i.id]=i;for(let i=0;ie.collisionGroupID===t};}return this.collisionGroups[e]}}function ua(t,i,o,r,n){const{horizontalAlign:s,verticalAlign:a}=e.d$(t),l=-(s-.5)*i,c=-(a-.5)*o,h=e.e0(t,r);return new e.P(l+h[0]*n,c+h[1]*n)}function _a(t,i,o,r,n){const s=new e.P(t,i);return o&&s._rotate(r?n:-n),s}function fa(t,i,o,r){const{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=o,h=e.e1(i),d=r===e.b0.vertical?l:"left"===h?n:"center"===h?s:"right"===h?a:-1;n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=d>=0&&n!==d?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=d>=0&&s!==d?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=d>=0&&a!==d?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=d>=0&&l!==d?0:c);}function pa(t,i,o){const r=i===e.b0.horizontal||i===e.b0.horizontalOnly?i:0,n=i===e.b0.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;s>=0&&(h.get(s).placedOrientation=r),a>=0&&(h.get(a).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=n);}class ma{constructor(e,t,i,o,r,n,s,a){this.transform=e.clone(),this.projection=e.projection.name,this.algorithm=o,this.collisionIndex=this.algorithm.createCollisionDetector(this.transform,n,a),this.buildingIndex=s,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new da(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0;}getBucketParts(t,i,o,r,n=1){const s=o.getBucket(i),a=o.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,h=o.collisionBoxArray,d=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),u=o.tileSize/e.aj,_=o.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(p=o.tileID,m=s.getProjection(),g=this.transform,m.name===this.projection?g.calculateProjMatrix(p.toUnwrapped()):oa(g,m,p));var p,m,g;const v="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const x=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(o),E=Di(f,o.tileID.canonical,v,y,this.transform,s.getProjection(),T);let S=null;const I=s.getProjection().createInversionMatrix(this.transform,o.tileID.canonical);if(v){const t=Ai(f,o.tileID.canonical,v,y,this.transform,s.getProjection(),T);S=e.aP([],this.transform.labelPlaneMatrix,t);}let C=null;x&&o.latestFeatureIndex&&(C={unwrappedTileID:_,dynamicFilter:x,dynamicFilterNeedsFeature:b,needGeometry:w}),this.retainedQueryData[s.bucketInstanceId]=new ha(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,o.tileID);const[R,D]=s.layers[0].layout.get("text-size-scale-range"),A=e.as(n,R,D),[L,P]=l.get("icon-size-scale-range"),O=e.as(n,L,P),M={bucket:s,layout:l,paint:c,posMatrix:f,invMatrix:I,mercatorCenter:[e.a_(this.transform.center.lng),e.a$(this.transform.center.lat)],textLabelPlaneMatrix:E,labelToScreenMatrix:S,clippingData:C,scale:d,textPixelRatio:u,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.aZ(s.textSizeData,this.transform.zoom,A),partiallyEvaluatedIconSize:e.aZ(s.iconSizeData,this.transform.zoom,O),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:o.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:M});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:M});}placeLayerBucketPart(e,t,i,o,r=1){this.algorithm.placeLayerBucketPart(this,e,t,i,o,r);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},n=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],n=r[e];n?(this.opacities[e]=new aa(n,o,t.text,t.icon,null,t.clipped),i=i||t.text!==n.text.placed||t.icon!==n.icon.placed):(this.opacities[e]=new aa(null,o,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new aa(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in n)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=n[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){o&&(this.lastReplacementSourceUpdateTime=o.updateTime);const r=new Set;for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,n,n.collisionBoxArray,i,o,n.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,n.tileID),"road"===t.elevationType&&t.hdExt&&t.hdExt.updateRoadElevation(t,n.tileID.canonical),t.updateZOffset());}}updateBucketOpacities(t,i,o,r,n,s,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,h=t.layers[0].paint,d=!!t.layers[0].dynamicFilter(),u=new aa(null,0,!1,!1,!0),_=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),p=c.get("text-variable-anchor"),m="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),v=h.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),x=!v.isConstant(),b=new aa(null,0,_&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(_||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const w=(e,t,i)=>{for(let o=0;o0||_>0,O=E>0,M=this.placedOrientations[f],F=M===e.b0.vertical,z=M===e.b0.horizontal||M===e.b0.horizontalOnly;!P&&!O||L.isHidden()||T++;let B=!1;if((P||O)&&s)for(const i of t.activeReplacements){if(e.dY(i,n,e.dZ.Symbol,l))continue;if(i.min.x>S||S>i.max.x||i.min.y>I||I>i.max.y)continue;const t=e.d_(S,I,a.canonical,i.footprintTileId.canonical);if(B=e.cm(t,i.footprint),B)break}if(B&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,c.featureIndex),P){const e=B?Ia:Sa(L.text);w(t.text,h,F?Ia:e),w(t.text,_,z?Ia:e);const i=L.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||F?1:0;o>=0&&(a.get(o).hidden=l),r>=0&&(a.get(r).hidden=l),n>=0&&(a.get(n).hidden=l),s>=0&&(a.get(s).hidden=i||z?1:0);const d=this.variableOffsets[f];d&&fa(t,d.anchor,c,M);const u=this.placedOrientations[f];u&&(fa(t,"left",c,u),pa(t,u,c));}if(O){const e=B?Ia:Sa(L.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=c,r=t.icon.placedSymbolArray,n=L.icon.isHidden()?1:0;i>=0&&(w(t.icon,E,F?Ia:e),r.get(i).hidden=n),o>=0&&(w(t.icon,c.numVerticalIconVertices,z?Ia:e),r.get(o).hidden=n);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let o=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(p){const e=this.variableOffsets[f];e?(o=ua(e.anchor,e.width,e.height,e.textOffset,e.textScale),m&&o._rotate(g?this.transform.angle:-this.transform.angle)):r=!1;}d&&(r=!L.clipped),i.textBox&&ga(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||F,D,y,o.x,o.y),i.verticalTextBox&&ga(t.textCollisionBox.collisionVertexArray,L.text.placed,!r||z,D,y,o.x,o.y);}const n=r&&Boolean(!z&&i.verticalIconBox);i.iconBox&&ga(t.iconCollisionBox.collisionVertexArray,L.icon.placed,n,D,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0),i.verticalIconBox&&ga(t.iconCollisionBox.collisionVertexArray,L.icon.placed,!n,D,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return e-this.lastPlacementChangeTimee}isStale(){return this.stale}setStale(){this.stale=!0;}}function ga(e,t,i,o,r,n,s){e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,r?1:0);}const va=Math.pow(2,25),ya=Math.pow(2,24),xa=Math.pow(2,17),ba=Math.pow(2,16),wa=Math.pow(2,9),Ta=Math.pow(2,8),Ea=Math.pow(2,1);function Sa(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*va+t*ya+i*xa+t*ba+i*wa+t*Ta+i*Ea+t}const Ia=0;class Ca{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}const Ra=100;class Da{constructor(e,t){this.gridRightBoundary=0,this.gridBottomBoundary=0,this.clippedSymbols=new Map,this.reset(e,t);}reset(t,i){const o=t.width+200,r=t.height+200;o!==this.gridRightBoundary||r!==this.gridBottomBoundary?(this.grid=new e.e2(o,r,25),this.ignoredGrid=new e.e2(o,r,25)):(this.grid.clear(),this.ignoredGrid.clear()),this.transform=t,this.fogState=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+Ra,this.screenBottomBoundary=t.height+Ra,this.gridRightBoundary=o,this.gridBottomBoundary=r,this.clippedSymbols.clear();}clearClippedSymbolsForBucket(e){this.clippedSymbols.delete(e);}markSymbolAsClipped(e,t){let i=this.clippedSymbols.get(e);i||(i=new Set,this.clippedSymbols.set(e,i)),i.add(t);}placeCollisionBox(t,i,o,r,n,s,a,l,c,h,d){let u=o.projectedAnchorX,_=o.projectedAnchorY,f=o.projectedAnchorZ;const p=o.tileAnchorX,m=o.tileAnchorY,g=o.elevation,v=o.tileID,y=t.getProjection();if(g&&v){const[e,t,i]=y.upVector(v.canonical,o.tileAnchorX,o.tileAnchorY),r=y.upVectorScale(v.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;u+=e*g*r,_+=t*g*r,f+=i*g*r;}const x="globe"===t.projection.name,b="globe"===t.projection.name?e.ah(this.transform.zoom):0;if(v&&x&&b<1&&!s){const t=1<0,y),T=c*w.perspectiveRatio,E=(o.x1*i+a.x-o.padding)*T+w.point.x,S=(o.y1*i+a.y-o.padding)*T+w.point.y,I=(o.x2*i+a.x+o.padding)*T+w.point.x,C=(o.y2*i+a.y+o.padding)*T+w.point.y,R=w.perspectiveRatio<=.55||w.occluded;return !this.isInsideGrid(E,S,I,C)||!l&&this.grid.hitTest(E,S,I,C,d)||R?{box:[],offscreen:!1,occluded:w.occluded}:{box:[E,S,I,C],offscreen:this.isOffscreen(E,S,I,C),occluded:!1}}placeCollisionCircles(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m){const g=[],v=this.transform.elevation,y=t.getProjection(),x="road"===t.elevationType,b=!!v||x,w=e.e7.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y),T=new e.P(o.tileAnchorX,o.tileAnchorY),E=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:S,y:I,z:C}=y.projectTilePoint(E.x,E.y,m.canonical),R=null;if(b){R=x&&t.hdExt?t.hdExt.makeRoadSymbolElevationParams(t,t.text,r,m,w,v,y,this.transform.center.lat,this.transform.worldSize):{getElevation:w,elevation:v,elevationFeature:null};const[e,i,o]=R.getElevation(T,v,R.elevationFeature);S+=e,I+=i,C+=o;}const D="globe"===y.name,A=this.projectAndGetPerspectiveRatio(l,S,I,C,m,D||!!v||this.transform.pitch>0,y),{perspectiveRatio:L}=A,P=(u?a/L:a*L)/e.e9,O=Li(S,I,C,c),M=o.lineOffsetX*P,F=o.lineOffsetY*P,z=e.al(t.layers[0].layout.get("text-max-angle")),B=Math.cos(z),k=A.signedDistanceFromCamera>0?Fi(P,s,M,F,x&&1===o.flipState,O,E,o,n,c,{},b&&!u?R:null,u&&b,y,m,u,B):null;let N=!1,U=!1,j=!0;if(k&&!A.occluded){const t=.5*f*L+p,o=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),n=new Ca,{first:s,last:a}=k,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e(b&&!D&&(i=R.getElevation(oe[3]<=0)&&(c=[]));let m=[];if(c.length>0){let t=1/0,i=-1/0,n=1/0,s=-1/0;for(const e of c)t=Math.min(t,e[0]),n=Math.min(n,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=o.x&&t<=r.x&&s>=o.y&&n<=r.y&&(m=[c.map(t=>new e.P(t[0],t[1]))],(tr.x||nr.y)&&(m=e.e8(m,o.x,o.y,r.x,r.y)));}for(const e of m){n.reset(e,.25*t);let o=0;o=n.length<=.5*t?1:Math.ceil(n.paddedLength/u)+1;for(let e=0;e0){if(e.aO(l,l,t),this.fogState&&n&&"globe"!==a.name){const t=function(t,i,o,r,n,s){const a=s.calculateFogTileMatrix(n),l=[i,o,r];return e.ad(l,l,a),Xt(t,e.ae(l),s.pitch)}(this.fogState,i,o,r,n.toUnwrapped(),this.transform);c=t>.9;}}else Vi(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+Ra,(-l[1]/h+1)/2*this.transform.height+Ra),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:s&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&t2}placeLayerBucketPart(t,i,o,r,n,s=1){const{bucket:a,layout:l,paint:c,posMatrix:h,textLabelPlaneMatrix:d,labelToScreenMatrix:u,clippingData:_,textPixelRatio:f,mercatorCenter:p,invMatrix:m,holdingForFade:g,collisionBoxArray:v,partiallyEvaluatedTextSize:y,partiallyEvaluatedIconSize:x,collisionGroup:b,latestFeatureIndex:w}=i.parameters,T=l.get("text-optional"),E=l.get("icon-optional"),S=l.get("text-allow-overlap"),I=l.get("icon-allow-overlap"),C="map"===l.get("text-rotation-alignment"),R="map"===l.get("icon-rotation-alignment"),D="map"===l.get("text-pitch-alignment"),A=c.get("symbol-z-offset"),L="sea"===l.get("symbol-elevation-reference"),P=l.get("symbol-placement"),[O,M]=l.get("text-size-scale-range"),[F,z]=l.get("icon-size-scale-range"),B=e.as(s,O,M),k=e.as(s,F,z),N=l.get("text-variable-anchor"),U=C&&"point"!==P,j=R&&"point"!==P,G=N&&a.hasTextData(),V=a.hasIconTextFit()&&G&&a.hasIconData();t.transform.setProjection(a.projection);const q=G||U,H=j||V;let Z=S&&(I||!a.hasIconData()||E),W=I&&(S||!a.hasTextData()||T);const $=!A.isConstant();!a.collisionArrays&&v&&a.deserializeCollisionBoxes(v),r&&n&&a.updateCollisionDebugBuffers(t.transform.zoom,v,B,k);const X=(i,n,s)=>{const{crossTileID:c,numVerticalGlyphVertices:v}=i;let R=null;if(_&&_.dynamicFilterNeedsFeature||$){const o=t.retainedQueryData[a.bucketInstanceId],r=w.loadFeature({featureIndex:i.featureIndex,bucketIndex:o.bucketIndex,sourceLayerIndex:o.sourceLayerIndex,layoutVertexArrayOffset:0}),n=r.properties?r.properties.worldview:null;if(a.localizable&&a.worldview&&"string"==typeof n)if("all"===n)r.properties.$localized=!0;else {if(!n.split(",").includes(a.worldview))return;r.properties.$localized=!0,r.properties.worldview=a.worldview;}R=_&&_.needGeometry?e.cW(r,!0):r;}if(_&&!(0,_.dynamicFilter)({zoom:t.transform.zoom,pitch:t.transform.pitch,worldview:a.worldview},R,t.retainedQueryData[a.bucketInstanceId].tileID.canonical,new e.P(i.tileAnchorX,i.tileAnchorY),t.transform.calculateDistanceTileData(_.unwrappedTileID)))return t.placements[c]=new la(!1,!1,!1,!0),void o.add(c);const P=A.evaluate(R,{});if((i.zOffset||0)+(P||0)>0&&t.frontCutoffStart>0){const r=2*t.frontCutoffStart-1,n=[i.tileAnchorX,i.tileAnchorY,0,1],s=e.aO(e.cw(),n,h);if(s[1]/s[3]{o.tileID=t.retainedQueryData[a.bucketInstanceId].tileID;const r=t.transform.elevation;if("road"===a.elevationType)o.elevation=L?P:P+e.e7.getAtTileOffset(o.tileID,new e.P(o.tileAnchorX,o.tileAnchorY),r,null);else {const t=a.hdExt?a.hdExt.elevationFeatures[i.elevationFeatureIndex]:void 0;o.elevation=L?P:P+e.e7.getAtTileOffset(o.tileID,new e.P(o.tileAnchorX,o.tileAnchorY),r,t);}o.elevation+=i.zOffset;},ee=s.textBox;if(ee){J(ee);const o=o=>{let r=e.b0.horizontal;if(a.allowVerticalPlacement&&!o&&t.prevPlacement){const e=t.prevPlacement.placedOrientations[c];e&&(t.placedOrientations[c]=e,r=e,pa(a,r,i));}return r},r=(t,i)=>{if(a.allowVerticalPlacement&&v>0&&s.verticalTextBox){for(const o of a.writingModes)if(o===e.b0.vertical?(U=i(),j=U):U=t(),U&&U.box&&U.box.length)break}else U=t();};if(N){let l=N;if(t.prevPlacement&&t.prevPlacement.variableOffsets[c]){const e=t.prevPlacement.variableOffsets[c];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor),l.unshift(e.anchor));}const d=(e,o,r)=>{const s=a.getSymbolInstanceTextSize(y,i,t.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,d=(e.y2-e.y1)*s+2*e.padding,u=i.hasIconTextFit&&!I?o:null;u&&J(u);let _={box:[],offscreen:!1,occluded:!1};const g=S?2*l.length:l.length;for(let o=0;o=l.length,i,n,a,r,u,y,x);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){O=!0,k=g.shift;break}}return _};r(()=>d(ee,s.iconBox,e.b0.horizontal),()=>{const t=s.verticalTextBox;return t&&J(t),a.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&v>0&&t?d(t,s.verticalIconBox,e.b0.vertical):{box:null,offscreen:null,occluded:null}}),U&&(O=U.box,F=U.offscreen,z=U.occluded);const u=o(!(!U||!U.box));if(!O&&t.prevPlacement){const e=t.prevPlacement.variableOffsets[c];e&&(t.variableOffsets[c]=e,fa(a,e.anchor,i,u));}}else {const l=(o,r)=>{const s=a.getSymbolInstanceTextSize(y,i,t.transform.zoom,n),l=t.collisionIndex.placeCollisionBox(a,s,o,p,m,q,new e.P(0,0),S,f,h,b.predicate);return l&&l.box&&l.box.length&&(pa(a,r,i),t.placedOrientations[c]=r),l};r(()=>l(ee,e.b0.horizontal),()=>{const t=s.verticalTextBox;return a.allowVerticalPlacement&&v>0&&t?(J(t),l(t,e.b0.vertical)):{box:null,offscreen:null,occluded:null}}),o(!!(U&&U.box&&U.box.length));}}if(G=U,O=G&&G.box&&G.box.length>0,F=G&&G.offscreen,z=G&&G.occluded,i.useRuntimeCollisionCircles){const o=i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex,n=a.text.placedSymbolArray.get(o),s=e.b1(a.textSizeData,y,n),c=l.get("text-padding");V=t.collisionIndex.placeCollisionCircles(a,S,n,o,a.lineVertexArray,a.glyphOffsetArray,s,h,d,u,r,D,b.predicate,i.collisionCircleDiameter*s/e.e9,c,t.retainedQueryData[a.bucketInstanceId].tileID),O=S||V.circles.length>0&&!V.collisionDetected,F=F&&V.offscreen,z=V.occluded;}if(s.iconFeatureIndex&&(Q=s.iconFeatureIndex),s.iconBox){const o=o=>{J(o);const r=i.hasIconTextFit&&k?_a(k.x,k.y,C,D,t.transform.angle):new e.P(0,0),n=a.getSymbolInstanceIconSize(x,t.transform.zoom,i.placedIconSymbolIndex);return t.collisionIndex.placeCollisionBox(a,n,o,p,m,H,r,I,f,h,b.predicate)};j&&j.box&&j.box.length&&s.verticalIconBox?(X=o(s.verticalIconBox),M=X.box.length>0):(X=o(s.iconBox),M=X.box.length>0),F=F&&X.offscreen,B=X.occluded;}const te=T||0===i.numHorizontalGlyphVertices&&0===v,ie=E||0===i.numIconVertices;if(te||ie?ie?te||(M=M&&O):O=M&&O:M=O=M&&O,O&&G&&G.box&&t.collisionIndex.insertCollisionBox(G.box,l.get("text-ignore-placement"),a.bucketInstanceId,j&&j.box&&K?K:Y,b.ID),M&&X&&t.collisionIndex.insertCollisionBox(X.box,l.get("icon-ignore-placement"),a.bucketInstanceId,Q,b.ID),V&&(O&&t.collisionIndex.insertCollisionCircles(V.circles,l.get("text-ignore-placement"),a.bucketInstanceId,Y,b.ID),r)){const e=a.bucketInstanceId;let i=t.collisionCircleArrays[e];void 0===i&&(i=t.collisionCircleArrays[e]=new ca);for(let e=0;e=0;--e){const t=i[e];X(a.symbolInstances.get(t),t,a.collisionArrays[t]);}a.hasAnyZOffset&&e.w(`${a.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(a.hasAnyZOffset){const e=a.getSortedIndexesByZOffset();for(let t=0;t0){let i;return e.prevPlacement&&e.prevPlacement.variableOffsets[E]&&e.prevPlacement.placements[E]&&e.prevPlacement.placements[E].text&&(i=e.prevPlacement.variableOffsets[E].anchor),e.variableOffsets[E]={textOffset:S,width:s,height:a,anchor:t,textScale:l,prevAnchor:i},fa(g,t,p,v),g.allowVerticalPlacement&&(pa(g,v,p),e.placedOrientations[E]=v),{shift:I,placedGlyphBoxes:C}}}}};class La{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,o,r,n){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this.isFullPlacementRequested()&&0!==this._fadeDuration&&this.placement.algorithm.shouldPause(e.r.now()-s);for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&"none"!==s.visibility&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),h="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),d=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),u=h&&d,_=this._inProgressLayer=this._inProgressLayer||new La(t),f=e.y(s.source,s.scope);if(_.continuePlacement(i||u?r[f]:o[f],this.placement,this._showCollisionBoxes,s,a,n))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._forceFullPlacement=!1,this._done=!0;}commit(e){return this._retiredCI=this.placement.prevPlacement?this.placement.prevPlacement.collisionIndex:null,this.placement.commit(e),this.placement}}const Oa=512/e.aj/2;class Ma{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.ea(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.aj,n=t.canonical.y*e.aj;for(let e=0;ee-t);for(const e of _){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!o.has(t)){o.add(t),i.crossTileID=t;break}}}}}class Fa{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class za{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],o={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),o[r.tileID.key]=r;}this.indexes[e]=o;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;ee.overscaledZ)for(const i in r){const n=r[i];n.tileID.isChildOf(e)&&n.findMatches(t.symbolInstances,e,o);}else {const n=r[e.scaledTo(Number(i)).key];n&&n.findMatches(t.symbolInstances,e,o);}}for(let e=0;e{t[e]=!0;});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}class ka extends e.E{constructor(e){super(),this.requestManager=e,this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null);}async loadModel(t,i){try{const o=await this.requestManager.transformRequest(i,e.R.Model);if(!this.modelByURL[i])return null;const r=await e.eb(o.url),n=e.ec(r),s=new e.ed(t,i,void 0,void 0,n);return s.computeBoundsAndApplyParent(),s}catch(o){if(404===o.status)return null;this.fire(new e.A(new Error(`Could not load model ${t} from ${i}`,{cause:o})));}}load(t,i,o={forceReload:!1}){this.models[i]||(this.models[i]=Object.create(null));const r=Object.keys(t),n=[],s=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!o.forceReload||(this.modelByURL[r]={modelId:e,scope:i},n.push(this.loadModel(e,r)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1});}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(n).then(t=>{for(let e=0;e{this.fire(new e.A(new Error(`Could not load models: ${t.message}`)));});}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t,i={exactIdMatch:!1}){return !!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]=Object.create(null)),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||Object.create(null)}addModel(e,t,i){this.models[i]||(this.models[i]=Object.create(null)),this.modelUris[i]||(this.modelUris[i]=Object.create(null));const o=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===o)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(o)){const{scope:e,modelId:t}=this.modelByURL[o];this.models[e][t].numReferences++;}else this.modelUris[i][e]=o,this.load({[e]:this.modelUris[i][e]},i);}addModelURLs(e,t){this.models[t]||(this.models[t]=Object.create(null)),this.modelUris[t]||(this.modelUris[t]=Object.create(null));const i=this.modelUris[t];for(const t of Object.keys(e))i[t]=this.requestManager.normalizeModelURL(e[t]);}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0});}addModelsFromBucket(e,t){this.models[t]||(this.models[t]=Object.create(null)),this.modelUris[t]||(this.modelUris[t]=Object.create(null));const i=Object.create(null);for(const o of e)this.hasModel(o,t,{exactIdMatch:!0})||this.hasURLBeenRequested(o)?this.models[t][o].numReferences++:this.modelUris[t][o]&&!this.hasURLBeenRequested(o)?i[o]=this.modelUris[t][o]:!this.hasURLBeenRequested(o)&&mt(o,!1)&&(this.modelUris[t][o]=this.requestManager.normalizeModelURL(o),i[o]=this.modelUris[t][o]);this.load(i,t);}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,o=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||o)){const o=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[o];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy();}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy();}this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null);}listModels(e){return this.models[e]||(this.models[e]=Object.create(null)),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]=Object.create(null));for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}const Na=["RENDER_SHADOWS","NORMAL_OFFSET"],Ua=new Set(["symbol","circle"]),ja=class t{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null;}needsBuild(){return this._needsBuild}buildQueue(e,t,i){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;const o=!!i.fog,r=i.hasTerrain(),n=!(!i.projection||"globe"!==i.projection.name),s=r||n,a=!(!i.directionalLight||!i.directionalLight.shadowsEnabled()),l=i.map&&i.map.painter,c=!l||!l.context.extParallelShaderCompile,h=!!l&&"mrt-fallback"===l.emissiveMode,d=(e,t=[],i={})=>{this._queue.push({programId:e,params:{...i.params,defines:t,overrideFog:!!i.fog,overrideTerrain:!!i.terrain,overrideGlobe:!!i.globe,overrideRtt:!!i.rtt,precompiled:!0}});};for(const u of e){if("none"===u.visibility)continue;const e=u.getProgramIds();if(e)for(const _ of e){if(Ua.has(_))continue;const e=u.getDefaultProgramParams(_,t.zoom,i._styleColorTheme.lut);if(!e)continue;const f=l?l.getShaderSource(_):null,p=s&&(!f||f.usedDefines.has("RENDER_TO_TEXTURE")),m=h&&p?(e.defines||[]).concat("USE_MRT1"):e.defines;if(c){d(_,e.defines,{params:e}),p&&d(_,m,{params:e,rtt:!0});continue}const g=o&&(!f||f.usedDefines.has("FOG")),v=r&&!u.isDraped()&&(!f||f.usedDefines.has("TERRAIN")),y=n&&(!f||f.usedDefines.has("GLOBE")),x=a&&u.hasElevation()&&(!f||f.usedDefines.has("RENDER_SHADOWS"));for(const t of x?[!1,!0]:[!1]){const i=t?(e.defines||[]).concat(Na):e.defines||[];for(const t of v?[!1,!0]:[!1])for(const o of y?[!1,!0]:[!1])for(const r of g?[!1,!0]:[!1])d(_,i,{params:e,fog:r,terrain:t,globe:o});}p&&d(_,m,{params:e,rtt:!0});}}if(d("clippingMask"),r)for(const e of [!1,!0])d("terrainRaster",e?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:o});if(!c){if(e.some(e=>"hillshade"===e.type)&&d("hillshadePrepare"),a)for(const e of [!1,!0])for(const t of [!1,!0]){const i=[];e&&i.push("RENDER_CUTOFF"),i.push("RENDER_SHADOWS"),t&&i.push("NORMAL_OFFSET"),d("groundShadow",i),o&&d("groundShadow",i,{fog:!0});}if(n){for(const e of [[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(const t of [!1,!0]){const i=[...e,"PROJECTION_GLOBE_VIEW"];t&&i.push("CUSTOM_ANTIALIASING"),d("globeRaster",i,{terrain:r,globe:!0,fog:o});}for(const e of [!1,!0]){const t=e?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];d("globeAtmosphere",t,{fog:!0,terrain:r,globe:e}),d("globeAtmosphere",[...t,"ALPHA_PASS"],{fog:!0,terrain:r,globe:e});}d("stars",[],{fog:o,terrain:r,globe:!0});}}}_executeBatch(i,o,r){if(r.map&&r.map.isMoving())return void(this._idleHandle=e.r.requestIdleCallback(e=>this._executeBatch(e,o,r)));o.context.sweepPendingPrograms();const n=o.context.extParallelShaderCompile?t.DEADLINE_MARGIN_KHR_MS:t.DEADLINE_MARGIN_SYNC_MS;let s=0;for(;this._queue.length>0;){const e=this._queue.shift();if(!e)break;if(o.style=r,o._fogVisible=!!e.params.overrideFog,o.getOrCreateProgram(e.programId,e.params),s++,i.timeRemaining()<=n)break}const a=0===this._queue.length||i.timeRemaining()>n;s>0&&a&&o.context.gl.flush(),this._idleHandle=this._queue.length>0||o.context._pendingPrograms.size>0?e.r.requestIdleCallback(e=>this._executeBatch(e,o,r)):null;}processQueue(t,i){0!==this._queue.length&&(null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=e.r.requestIdleCallback(e=>this._executeBatch(e,t,i)));}reset(){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0;}};ja.DEADLINE_MARGIN_KHR_MS=5,ja.DEADLINE_MARGIN_SYNC_MS=25;let Ga=ja;const Va=e.m.colorTheme,qa=new e.a7({data:new e.a8(Va.data)});function Ha(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.r.devicePixelRatio,{left:o,top:r,width:n,height:s}=t.metadata.content_area,a=o*i,l=r*i;return [a,l,a+n*i,l+s*i]}function Za(t){if(t)return t.map(([t,i])=>[t*e.r.devicePixelRatio,i*e.r.devicePixelRatio])}class Wa{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set;}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name);}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const o=this.sourceCache.getSource();if(!(o instanceof gn))return t;const r=i.map(e=>this.sourceCache.getTile(e)),n=o.getImages(r,Array.from(this.pendingRequests));for(const[i,o]of n)t.set(e.I.from({name:i,iconsetId:this.id}),o),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const $a=(e,t)=>jt(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Xa=(t,i)=>{const o=t.type&&!t.array&&Array.isArray(i)?{type:t.type,"property-type":"data-constant"}:void 0;return e.n(i,o)},Ya=e.b5(Xs,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),Ka=e.b5(Xs,["setCenter","setZoom","setBearing","setPitch"]),Qa=new Set(["background","sky","slot","custom"]),Ja={version:8,layers:[],sources:{}},el={duration:300,delay:0};class tl extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition={...el},this._buildingIndex=new qs(this),this.crossTileSymbolIndex=new Ba,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers=Object.create(null),this._mergedIndoor={},this._indoorEnabled=!1,this._mergedSourceCaches={},this._mergedOtherSourceCaches=Object.create(null),this._mergedSymbolSourceCaches=Object.create(null),this._mergedFillExtrusionSourceCaches=Object.create(null),this._mergedHdRoadCoverageSourceCaches=Object.create(null),this._mergedHdRoadElevationSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new ne,this._hasDataDrivenEmissive=!1,this.indoorManager=null,this.dispatcher=i.dispatcher?i.dispatcher:new li(Zs(),this);const o={referrer:e.ef(),config:e.ee()};if(this.map.painter&&this.map.painter.context){const e=this.map.painter.context.maxUniformBufferBindings,t=Math.floor(this.map.painter.context.maxUniformBlockSize/4);o.contextOptions={maxBindingPoints:e,maxUniformBlockSizeDwords:t};}this.isRootStyle()&&this.dispatcher.broadcast("setGlobalParams",o),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new We(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.eg(t._requestManager,i.localFontFamily?e.eh.all:i.localIdeographFontFamily?e.eh.ideographs:e.eh.none,i.localFontFamily||i.localIdeographFontFamily,i.fontstackCompositing),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new ka(t._requestManager),this.modelManager.setEventedParent(this)),this._layers=Object.create(null),this._sourceCaches={},this._otherSourceCaches=Object.create(null),this._symbolSourceCaches=Object.create(null),this._fillExtrusionSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new Ga:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._layerExpressionDependencies=i.layerExpressionDependencies?i.layerExpressionDependencies:new Map,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig;const r=this;this._rtlTextPluginCallback=tl.registerForPluginStateChange(t=>{r.dispatcher.send("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL}).then(t=>{if(e.ei(null),t.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload();}}).catch(t=>{e.ei(t);});}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}});}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.e(t))return t;const i=e.ej(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.ek(JSON.stringify(t))}`}_diffStyle(t,i,o){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,o));}catch(e){t(e,!1);}};if("string"==typeof t){const o=this.map._requestManager.normalizeStyleURL(t),n=new AbortController;this._request={cancel:()=>n.abort()},(async()=>{const t=await this.map._requestManager.transformRequest(o,e.R.Style,n.signal),{data:s}=await e.o(t,n.signal);this._request=null,r(s,i);})().catch(t=>{this._request=null,n.signal.aborted||this.fire(new e.A(t));});}else "object"==typeof t&&r(t,i);}loadURL(t,i={}){this.fire(new e.B("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.e(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,o);const n=new AbortController;this._request={cancel:()=>n.abort()},(async()=>{const i=await this.map._requestManager.transformRequest(t,e.R.Style,n.signal),{data:r}=await e.o(i,n.signal);this._request=null,this.importsCache.set(t,r),this._load(r,o);})().catch(t=>{this._request=null,n.signal.aborted||this.fire(new e.A(t));});}loadJSON(t,i={}){this.fire(new e.B("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.r.frame(()=>{this._request=null,this._load(t,!1!==i.validate);});}loadEmpty(){this.fire(new e.B("dataloading",{dataType:"style"})),this._load(Ja,!1);}_loadImports(t,i,o){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const n of t){const t=this._createFragmentStyle(n),s=new Promise(e=>{t.once("style.import.load",e),t.once("error",e);}).then(()=>{this.mergeAll(),this.fire(new e.B("data",{dataType:"style"}));});if(r.push(s),this.resolvedImports.has(n.url)){t.loadEmpty();continue}const a=n.data||this.importsCache.get(n.url);a?(n.data?(t.fire(new e.B("dataloading",{dataType:"style"})),t.globalId=t._getGlobalId(a),queueMicrotask(()=>t._load(a,i))):t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):n.url?t.loadURL(n.url,{validate:i}):t.loadEmpty();const l={style:t,id:n.id,config:n.config};if(o){const e=this.fragments.findIndex(({id:e})=>e===o);this.fragments=this.fragments.slice(0,e).concat(l).concat(this.fragments.slice(e));}else this.fragments.push(l);}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return [...t.values()]}_createFragmentStyle(t){const i=this.scope?e.y(t.id,this.scope):t.id;let o;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(o={...t.config,...r});const n=new tl(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:o,configOptions:this.options,colorThemeOverride:t["color-theme"],layerExpressionDependencies:this._layerExpressionDependencies});return n.setEventedParent(this.map,{style:n}),n}_reloadImports(e=!1){this.mergeAll(),this._updateMapProjection(),e||this.updateConfigDependencies(),this._updateLayers(this._dependentLayerIds(e=>e.isIndoorDependent)),this.map._triggerCameraUpdate(this.camera),(!e||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(e&&this.isRootStyle()?(this.forEachFragmentStyle(e=>{this.dispatcher.broadcast("setLayers",{layers:e._serializeLayers(e._order),scope:e.scope,options:e.options});}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}));}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e={id:"basemap",data:t,url:""},o={...Ja,imports:[e],...t.center?{center:t.center}:{},...t.bearing?{bearing:t.bearing}:{},...t.pitch?{pitch:t.pitch}:{},...t.zoom?{zoom:t.zoom}:{},...t.light?{light:t.light}:{}};return this._importedAsBasemap=!0,void this._load(o,i)}if(this.updateConfig(this._config,t.schema),i&&$a(this,Ct(t)))return;this._loaded=!0;for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});this.stylesheet=e.el(t);const o=()=>{if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const o=$s(this.stylesheet.layers);if(this._order=o.map(e=>e.id),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new qt(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new qt(this.stylesheet.light)),this._layers=Object.create(null);let r=!1;for(const t of o){const i=e.ep(t,this.scope,this._styleColorTheme.lut,this.options);this._layerExpressionDependencies.set(i.fqid,new se(i)),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._updateHdCoverageSourceCache(i)&&(r=!0);const o=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&n&&(o.castsShadows=!0);}if(r&&Ss().then(()=>{if(!this.map)return;for(const e in this._layers)this._updateHdCoverageSourceCache(this._layers[e]);this.map.style.mergeAll();const e=this.map.transform;for(const t in this.map.style._mergedHdRoadCoverageSourceCaches){const i=this.map.style._mergedHdRoadCoverageSourceCaches[t];i.used=!0,e&&i.update(e);}this.map._update();}),this.glyphManager.url){const e=new Set;for(const t in this._layers){const i=this._layers[t];if("symbol"===i.type&&i.layout){const t=i.layout.get("text-font");t&&t.value&&"constant"===t.value.kind&&e.add(t.value.value.join(","));}}for(const t of e)this.glyphManager.prefetchRange(t,0);}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(n,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.B("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(!0),this.fire(new e.B(s?"style.load":"style.import.load"));}).catch(t=>{this.fire(new e.A(new Error("Failed to load imports",t))),this.fire(new e.B(s?"style.load":"style.import.load"));}):(this._reloadImports(!0),this.fire(new e.B(s?"style.load":"style.import.load")));};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{o();}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),o();});}else this._styleColorTheme.lut=null,o();}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(e=>e.style.hasAppearances())}mergeAll(){let e,t,i,o,r,n,s,a,l,c;const h={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(d.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),null!=d.light&&(e=d.light),d.stylesheet.lights)for(const e of d.stylesheet.lights)"ambient"===e.type&&null!=d.ambientLight&&(t=d.ambientLight),"directional"===e.type&&null!=d.directionalLight&&(i=d.directionalLight);o=this._prioritizeTerrain(o,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(r=d.fog),d.stylesheet.snow&&null!=d.snow&&(n=d.snow),d.stylesheet.rain&&null!=d.rain&&(s=d.rain),null!=d.stylesheet.camera&&(c=d.stylesheet.camera),null!=d.stylesheet.projection&&(a=d.stylesheet.projection),null!=d.stylesheet.transition&&(l=d.stylesheet.transition),h[d.scope]=d._styleColorTheme;}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=n,this.rain=s,this._styleColorThemeForScope=h,null===o?delete this.terrain:this.terrain=o,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition={...el,...l},this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain);}),null===e?delete this.terrain:this.terrain=e,this._programPrecompiler&&this._programPrecompiler.reset();}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);}),this.projection=e||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset();}mergeSources(){const t={},i=Object.create(null),o=Object.create(null),r=Object.create(null),n=Object.create(null),s=Object.create(null);this.forEachFragmentStyle(a=>{for(const i in a._sourceCaches){const o=e.y(i,a.scope);t[o]=a._sourceCaches[i];}for(const t in a._otherSourceCaches){const o=e.y(t,a.scope);i[o]=a._otherSourceCaches[t];}for(const t in a._symbolSourceCaches){const i=e.y(t,a.scope);o[i]=a._symbolSourceCaches[t];}for(const t in a._fillExtrusionSourceCaches){const i=e.y(t,a.scope);r[i]=a._fillExtrusionSourceCaches[t];}if(a._hdCoverage){const t=a._hdCoverage.coverageSourceCaches;for(const i in t)n[e.y(i,a.scope)]=t[i];}if(a._hdElevation){const e=a._hdElevation.elevationSourceCaches;for(const t in e)s[t]=e[t];}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o,this._mergedFillExtrusionSourceCaches=r,this._mergedHdRoadCoverageSourceCaches=n,this._mergedHdRoadElevationSourceCaches=s,Object.keys(n).length>0&&!this._hdCoverage&&Es.HdCoverageState&&(this._hdCoverage=new Es.HdCoverageState),Es.updateCrossSourceElevationGate&&Es.updateCrossSourceElevationGate(this);}mergeIndoor(){this._mergedIndoor={},this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const o=i,r=e.y(o.sourceId,t.scope);this._mergedIndoor[r]=new Set(o.sourceLayers||[]);}}),this._updateIndoorEnabled();}_updateIndoorEnabled(){const t=this._indoorEnabled;if(this._indoorEnabled=!1,Object.keys(this._mergedIndoor).length>0)for(const t of this._mergedOrder){const i=this._mergedLayers[t];if("none"!==i.visibility&&this._mergedIndoor[e.y(i.source,i.scope)]){this._indoorEnabled=!0;break}}!this._indoorEnabled||t||this.indoorManager||Ss().then(()=>{this._initIndoorManager();});}_initIndoorManager(){if(!this.indoorManager&&Es.IndoorManager&&this.isRootStyle()&&0!==Object.keys(this._mergedIndoor).length&&(this.indoorManager=new Es.IndoorManager(this,this._loaded),this._loaded))for(const e of Object.keys(this._mergedIndoor)){const t=this._mergedSourceCaches[e]||this._mergedOtherSourceCaches[e];t&&t.reload();}}mergeLayers(){const t={},i=[],o=Object.create(null);this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(o=>{for(const r of o._order){const n=o._layers[r];if("slot"===n.type){const i=e.dD(r);if(t[i])continue;t[i]=[];}n.slot&&t[n.slot]?t[n.slot].push(n):i.push(n);}}),this._mergedOrder=[];let r=-1;const n=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.dD(s.id);t[i]&&n(t[i]),this._mergedSlots.push(i);}else {const t=e.y(s.id,s.scope);this._mergedOrder.push(t),o[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0);}};if(n(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i]);}this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera={...this.stylesheet.camera,...e},this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const r={...i};for(const e of Object.keys(Va))void 0===r[e]&&(r[e]=Va[e].default);const n=new e.a6(qa,t,new Map(o));return n.setTransitionOrValue(r,o),n.untransitioned().possiblyEvaluate(new e.aa(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((o,r)=>{const n="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void o();let s=t;s.startsWith(n)||(s=n+s);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void o();this._styleColorTheme.lutLoading=!1;const{width:n,height:s,data:c}=e.r.getImageData(l);if(s>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(n!==s*s)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.t({width:n,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const h=this.imageManager.getImage(a,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},o()):r(new Error("Missing LUT image."));};})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.hasTerrain()||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(t){const i=new AbortController;this._spriteRequest=i,function(t,i,o,r){let n,s,a;const l=e.r.devicePixelRatio>1?"@2x":"";function c(t){a||t&&o.aborted||(t&&(a=t),function(){if(a)r(a);else if(n&&s){const t=e.r.getImageData(s),i={};for(const o in n){const{width:r,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:d,stretchY:u,content:_}=n[o],f=new e.t({width:r,height:s});e.t.copy(t,f,{x:a,y:l},{x:0,y:0},{width:r,height:s},null),i[o]={data:f,pixelRatio:void 0!==h?h:1,sdf:void 0!==c&&c,stretchX:d,stretchY:u,content:_,usvg:!1,version:0};}r(null,i);}}());}((async function(){const r=await i.transformRequest(i.normalizeSpriteURL(t,l,".json"),e.R.SpriteJSON,o),{data:s}=await e.o(r,o);a||(n=s);}))().then(()=>c(void 0),e=>c(e)),async function(){const r=await i.transformRequest(i.normalizeSpriteURL(t,l,".png"),e.R.SpriteImage,o),{data:n}=await e.q(r,o);a||(s=n);}().then(()=>c(void 0),e=>c(e));}(t,this.map._requestManager,i.signal,(t,i)=>{if(this._spriteRequest=null,t)this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new e.A(t));else if(i){const t=new Map;for(const o in i)t.set(e.I.from(o),i[o]);this.addImages(t,!0);}this.imageManager.setLoaded(!0,this.scope),this.fire(new e.B("data",{dataType:"style"}));});}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const o=this.getOwnSourceCache(i.source);if(!o)return void this.fire(new e.A(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=o.getSource();if("raster-array"!==r.type)return void this.fire(new e.A(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const n=new Wa(t,this.scope,o);this.imageManager.addImageProvider(n,this.scope);}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope);}_loadIconset(t){if(!e.e(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat,o=new AbortController;this._spriteRequest=o,async function(t,i,o,r){try{const n=await i.transformRequest(i.normalizeIconsetURL(t),e.R.Iconset,o),{data:s}=await e.da(n,o),a={},l=function(e){const t={icons:[]};let i;for(;i=e.nextField(void 0);)1===i&&t.icons.push(he(e,e.readVarint()+e.pos));return t}(new e.d9(s));for(const t of l.icons){const i={version:1,pixelRatio:e.r.devicePixelRatio,content:Ha(t),stretchX:t.metadata?Za(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?Za(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};a[t.name]=i;}r(null,a);}catch(e){o.aborted||r(e);}}(t,this.map._requestManager,o.signal,(o,r)=>{if(this._spriteRequest=null,o)i?this._loadSprite(t):(this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new e.A(o)));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t,!0);}this.imageManager.setLoaded(!0,this.scope),this.fire(new e.B("data",{dataType:"style"}));});}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&("geojson"===i.type||i.vectorLayerIds&&!i.vectorLayerIds.includes(o))&&this.fire(new e.A(new Error(`Source layer "${o}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(this.imageManager.hasPatternsInFlight())return !1;if(!this.modelManager.isLoaded())return !1;if(this._styleColorTheme.lutLoading)return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return !!this.snow&&this.snow.hasTransition()}hasRainTransition(){return !!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;if(this.hasSnowTransition())return !0;if(this.hasRainTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}_updateDataDrivenEmissiveStrength(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];if(t._transitionablePaint&&t._transitionablePaint._values){const e=t._transitionablePaint._values["line-emissive-strength"];if(e&&e.value&&e.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1;}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.A(new Error(`The layer '${t}' does not exist in the map's style.`)));}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.A(new Error(`The source '${t}' does not exist in the map's style.`)));}handleIdle(){const e=this.map.painter;e&&(e.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(e,this));}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset();}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0;let o=!1;i!==this._brightness&&(this._brightness=i,o=!0),t.worldview!==this._worldview&&(this._worldview=t.worldview,o=!0),o&&this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness,worldview:this._worldview});const r=this._changes.isDirty();let n=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&(this._updateWorkerLayers(t,i,o),n=!0);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset();}const s={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];s[e]=t.used,t.used=!1,t.tileCoverLift=0;}const a={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if(("none"!==o.visibility||o.hasTransition())&&o.recalculate(t,this._availableImages),!o.isHidden(t.zoom)){o.mayUse("HD")&&(o.prepare(),Ss()),o.mayUse("Standard")&&(o.prepare(),Or());const e=this.getLayerSourceCache(o);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,o.tileCoverLift()));}if(o.source){const t=e.y(o.source,o.scope),i=this._mergedHdRoadCoverageSourceCaches[t];i&&!i.used&&(i.used=!0);}if("fill-extrusion"===o.type){const t=e.y(o.source,o.scope);if(t in this._mergedFillExtrusionSourceCaches){const e=o.layout&&o.layout.get("source-max-zoom");if(null!=e){const i=a[t];a[t]=null==i?e:Math.min(i,e);}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){const e=this._mergedOrder.map(e=>this._mergedLayers[e]);this._programPrecompiler.buildQueue(e,t,this);}for(const e in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[e].setMaxzoomOverride(null!=a[e]?a[e]:null);this.terrain&&n&&this.mergeLayers();const l=this.imageManager.getPendingImageProviders();for(const e of l)e.sourceCache.used=!0;for(const t in s){const i=this._mergedSourceCaches[t];s[t]!==i.used&&i.getSource().fire(new e.B("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}));}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),r&&this.fire(new e.B("data",{dataType:"style"}));}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e);}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i]);}for(const t in e)this._changes.resetUpdatedImages(t);}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast("updateLayers",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(t,i){if(this._checkLoaded(),$a(this,Ct(t)))return !1;(t=e.el(t)).layers=$s(t.layers);const o=function(t,i){if(!t)return [{command:Xs.setStyle,args:[i]}];let o=[];try{if(!e.b7(t.version,i.version))return [{command:Xs.setStyle,args:[i]}];if(e.b7(t.center,i.center)||o.push({command:Xs.setCenter,args:[i.center]}),e.b7(t.zoom,i.zoom)||o.push({command:Xs.setZoom,args:[i.zoom]}),e.b7(t.bearing,i.bearing)||o.push({command:Xs.setBearing,args:[i.bearing]}),e.b7(t.pitch,i.pitch)||o.push({command:Xs.setPitch,args:[i.pitch]}),e.b7(t.sprite,i.sprite)||o.push({command:Xs.setSprite,args:[i.sprite]}),e.b7(t.glyphs,i.glyphs)||o.push({command:Xs.setGlyphs,args:[i.glyphs]}),e.b7(t.imports,i.imports)||function(t=[],i=[],o){i=i||[];const r=(t=t||[]).map(ta),n=i.map(ta),s=t.reduce(ia,{}),a=i.reduce(ia,{}),l=r.slice();let c,h,d,u;for(c=0,h=0;c{e.source&&r[e.source]?o.push({command:Xs.removeLayer,args:[e.id]}):s.push(e);});let a=t.terrain;a&&r[a.source]&&(o.push({command:Xs.setTerrain,args:[void 0]}),a=void 0),o=o.concat(n),e.b7(a,i.terrain)||o.push({command:Xs.setTerrain,args:[i.terrain]}),function(t,i,o){i=i||[];const r=(t=t||[]).map(ta),n=i.map(ta),s=t.reduce(ia,{}),a=i.reduce(ia,{}),l=r.slice(),c=Object.create(null);let h,d,u,_,f,p,m;for(h=0,d=0;h!(e.command in Ka));if(0===o.length)return !1;const r=o.filter(e=>!(e.command in Ya));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const n=[];return o.forEach(e=>{n.push(this[e.command](...e.args));}),i&&Promise.all(n).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(e=!1){this._availableImages=this.imageManager.listImages(this.scope);const t={scope:this.scope,images:this._availableImages};e&&(t.isSpriteLoaded=!0),this.dispatcher.broadcast("setImages",t);}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels});}addImages(t,i){if(0===t.size)return i&&this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this;for(const[i,o]of t.entries()){if(this.getImage(i))return this.fire(new e.A(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,o),this._changes.updateImage(i,this.scope);}return this._updateWorkerImages(i),this.fire(new e.B("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.A(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.B("data",{dataType:"style"})),this)}updateImage(t,i,o=!1){this.imageManager.updateImage(t,this.scope,i),o&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.B("data",{dataType:"style"})));}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.B("data",{dataType:"style"})),this):this.fire(new e.A(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new e.B("data",{dataType:"style"})),this}addModel(t,i,o={}){return this._checkLoaded(),this._validate(Nt,`models.${t}`,i,null,o)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new e.B("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new e.B("data",{dataType:"style"})),this):this.fire(new e.A(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,o={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);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"].includes(i.type)&&this._validate(Rt,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=zs(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const n=t=>{const i=(t===e.dA.Symbol?"symbol:":t===e.dA.FillExtrusion?"fill-extrusion:":"other:")+r.id,o=e.y(i,this.scope),n=this._sourceCaches[i]=new Zn(o,r,t);t===e.dA.Symbol?this._symbolSourceCaches[r.id]=n:t===e.dA.FillExtrusion?this._fillExtrusionSourceCaches[r.id]=n:this._otherSourceCaches[r.id]=n,n.onAdd(this.map);};n(e.dA.Other),"vector"!==i.type&&"geojson"!==i.type||(n(e.dA.Symbol),"vector"===i.type&&n(e.dA.FillExtrusion)),r.onAdd&&r.onAdd(this.map),o.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.A(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.A(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.A(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.dD(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.B("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this._hdCoverage&&delete this._hdCoverage.coverageSourceCaches[t],this._hdElevation&&delete this._hdElevation.elevationSourceCaches[e.y(t,this.scope)],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty();}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(At,"lights",e))return;switch(e.type){case "ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new ci(e,di(),this.scope,this.options);break;case "directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new ci(e,_i(),this.scope,this.options);}}const o=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.aa(this.z||0,o);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness});}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),n=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.c5(s.x,s.y,s.z)[2]/90,l=o(r)*n*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),h=i.properties.get("intensity"),d=o(c)*h;return Number(((l+d)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.em(t)){const i=e.en(t),o=this.fragments.find(({id:e})=>e===i);if(!o)return;const r=e.dD(t);return o.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const o in t){const r={},n=this._featuresetSelectors[o]=[];for(const s of t[o].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const n=i(t.source,t.sourceLayer);if(n in r&&r[n]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${o}'s selector is not associated to the same source, skip this selector`);continue}r[n]=s.featureNamespace;}let t;if(s.properties)for(const i in s.properties){const o=e.n(s.properties[i]);"success"===o.result&&(t=t||{},t[i]=o.value);}n.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._uniqueFeatureID});}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return [];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const o=this.getFragmentStyle(i),r=o.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.A(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const n=[];for(const e of r[t].selectors){const t=o.getOwnLayer(e.layer);t&&n.push(t);}return n}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const r=e.y(i,o.scope),n=o.options.get(r),s=n?n.value||n.default:null;return s?s.serialize():null}isIndoorEnabled(){return this._indoorEnabled}getIndoorSourceLayers(t,i){const o=e.y(t,i);return this._mergedIndoor[o]}setIndoorData(e,t){this.indoorManager&&this.indoorManager.setIndoorData(t);}updateIndoorDependentLayers(){this._updateLayers(this._dependentLayerIds(e=>e.isIndoorDependent)),this.map._styleDirty=!0,this.map.triggerRepaint();}setConfigProperty(t,i,o){const r=this.getFragmentStyle(t);if(!r)return;const n=r.stylesheet.schema;if(!n||!n[i])return;const s=Xa(n[i],o);if("success"!==s.result)return void $a(this,s.value);const a=s.value.expression,l=e.y(i,r.scope),c=r.options.get(l);if(!c)return;let h;const{minValue:d,maxValue:u,stepValue:_,type:f,values:p}=n[i],m=Xa(n[i],n[i].default);"success"===m.result&&(h=m.value.expression),h?(this.options.set(l,{...c,value:a,default:h,minValue:d,maxValue:u,stepValue:_,type:f,values:p}),this.updateConfigDependencies(i)):this.fire(new e.A(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)));}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const o=i.stylesheet.schema;if(!o)return null;const r={};for(const t in o){const o=e.y(t,i.scope),n=i.options.get(o),s=n?n.value||n.default:null;r[t]=s?s.serialize():null;}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies());}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies());}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const o in i){let r,n;const s=Xa(i[o],i[o].default);if("success"===s.result&&(r=s.value.expression),t&&void 0!==t[o]){const e=Xa(i[o],t[o]);"success"===e.result&&(n=e.value.expression);}const{minValue:a,maxValue:l,stepValue:c,type:h,values:d}=i[o];if(r){const t=e.y(o,this.scope);this.options.set(t,{default:r,value:n,minValue:a,maxValue:l,stepValue:c,type:h,values:d});}else this.fire(new e.A(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.A(new Error("Attempting to set config for a style without schema.")));}_updateLayers(e){for(const t of e){const e=this.getLayer(t);e&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty());}}_dependentLayerIds(e){const t=[];for(const[i,o]of this._layerExpressionDependencies)e(o)&&t.push(i);return t}updateConfigDependencies(e){this._updateLayers(this._dependentLayerIds(t=>e?t.hasConfigDependency(e):t.isConfigDependent)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t);}}),this._updateIndoorEnabled(),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.A(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===t.type){if($a(this,e.eo(t)))return;n=e.ep(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.el(t),t=Object.assign(t,{source:r})),this._validate(Ft,`layers.${r}`,t,{arrayIndex:-1},o))return;n=e.ep(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}});}this._layerExpressionDependencies.set(n.fqid,new se(n));let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.A(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot&&n.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):s=t;}this._order.splice(s,0,r),this._handleLayerOrderChange(),this._layers[r]=n;const a=this.getOwnLayerSourceCache(n),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&n.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(n);if(c&&n.source&&a&&"custom"!==n.type){this._changes.discardLayerRemoval(n);const t=e.y(n.source,n.scope);c.type!==n.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause());}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let n=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.A(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot&&o.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):n=t;}this._order.splice(n,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._handleLayerOrderChange(),this._layerExpressionDependencies.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(t,i,o={}){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(e.b7(r.filter,i))return;const n=this._layerExpressionDependencies.get(r.fqid);if(null==i)return r.filter=void 0,n&&n.invalidateFilter(),void this._updateLayer(r);this._validate(zt,`layers.${r.id}.filter`,i,{layerType:r.type},o)||(r.filter=e.el(i),n&&n.invalidateFilter(),this._updateLayer(r));}getFilter(t){const i=this._checkLayer(t);if(i)return e.el(i.filter)}setLayoutProperty(t,i,o,r={}){this._checkLoaded();const n=this._checkLayer(t);if(n&&!e.b7(n.getLayoutProperty(i),o)){if(null!=o&&(!r||!1!==r.validate)&&$a(n,kt.call(Ct,{key:`layers.${t}.layout.${i}`,layerType:n.type,objectKey:i,value:o,styleSpec:e.m,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(i,o),this._updateLayer(n);}}getLayerProperty(e,t){const i=this._checkLayer(e);if(i){switch(t){case "minzoom":return i.minzoom;case "maxzoom":return i.maxzoom;case "filter":return this.getFilter(e);case "slot":return i.slot;case "appearances":return i.getAppearances().map(e=>e.serialize())}return i.isPaintProperty(t)?this.getPaintProperty(e,t):this.getLayoutProperty(e,t)}}setLayerProperty(e,t,i,o={}){this._checkLoaded();const r=this._checkLayer(e);if(r){switch(t){case "appearances":return r.setAppearances(i),void this._updateLayer(r);case "minzoom":return this.setLayerZoomRange(e,i);case "maxzoom":return this.setLayerZoomRange(e,null,i);case "filter":return this.setFilter(e,i,o);case "slot":return this.setSlot(e,i)}r.isPaintProperty(t)?this.setPaintProperty(e,t,i,o):this.setLayoutProperty(e,t,i,o);}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,o,r={}){this._checkLoaded();const n=this._checkLayer(t);n&&(e.b7(n.getPaintProperty(i),o)||(null==o||r&&!1===r.validate||!$a(n,Bt.call(Ct,{key:`layers.${t}.paint.${i}`,layerType:n.type,objectKey:i,value:o,styleSpec:e.m})))&&(n.setPaintProperty(i,o)&&this._updateLayer(n),this._changes.updatePaintProperties(n)));}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,r=this.getFragmentStyle(o),n=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of n)r.setFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);if(!o)return;const r=this.getFragmentStyle(o.scope);if(!r)return;r.setFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,r=t.sourceLayer,n=this._checkSource(o);if(!n)return;const s=n.type;if("geojson"===s&&r)return void this.fire(new e.A(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.A(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.A(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,r=this.getFragmentStyle(o),n=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of n)r.removeFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);if(!o)return;const r=this.getFragmentStyle(o.scope);if(!r)return;r.removeFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,r=this._checkSource(o);if(!r)return;const n=r.type,s="vector"===n?t.sourceLayer:void 0;if("vector"===n&&!s)return void this.fire(new e.A(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.A(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.removeFeatureState(s,t.id,i);}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:o,importId:r}=t.target,n=this.getFragmentStyle(r),s=n.getFeaturesetLayers(o);for(const{source:o,sourceLayer:r}of s){const s=n.getFeatureState({id:t.id,source:o,sourceLayer:r});if(s&&!i)i=s;else if(!e.b7(i,s))return void this.fire(new e.A(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);if(!o)return;const r=this.getFragmentStyle(o.scope);if(!r)return;i=r.getFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer});}return i}const i=t.source,o=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||o)return void 0===t.id&&this.fire(new e.A(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.A(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(e){return this.stylesheet.transition={...this.stylesheet.transition,...e},this.transition=this.stylesheet.transition,this}getTransition(){return {...this.stylesheet.transition}}setWorldview(e){e!==this._worldview&&(this._worldview=e,this.dispatcher.broadcast("upsertRenderParams",{worldview:this._worldview}),this.reloadSources());}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.eq({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],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:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t);}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.y(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[o]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(o,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,o={},r=[];for(let n=i.length-1;n>=0;n--){const s=i[n];if(t(s)){o[s]=n;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t);}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const n=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&o[t.layer.id]{if(Qa.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=n[t.id]=n[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r});};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.A(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.A(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i);}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,n,o),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dE(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,o){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(zt,"queryRenderedFeatures.filter",i.filter,null,i),r=e.cV(i.filter));const n="mock",s=[];if(i&&i.target)s.push({...i,targetId:n,filter:r});else {const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:n,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:n,filter:r,target:e});}}const a=this.queryRenderedTargets(t,s,o),l=[],c=new Set;for(const t of a)for(const i of t.variants[n])Ns(i,t,c)||l.push(new e.er(t,i));return l}queryRenderedTargets(t,i,o){const r={},n=(e,t,i,o)=>{const n=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(n.layers[e.fqid]=n.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(n.has3DLayers=!0),!o)return i.uniqueFeatureID=!1,void n.layers[e.fqid].targets.push(i);n.layers[e.fqid].targets.push({...i,namespace:o.namespace,properties:o.properties,uniqueFeatureID:o.uniqueFeatureID});};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:o}=t.target,r=this.getFragmentStyle(o);if(!r||!r._featuresetSelectors)continue;const s=r._featuresetSelectors[i];if(!s){this.fire(new e.A(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=r.getOwnLayer(e.layerId);i&&!Qa.has(i.type)&&n(i,r.getOwnLayerSourceCache(i),t,e);}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Qa.has(i.type))continue;n(i,this.getLayerSourceCache(i),t);}const s=this._queryRenderedFeatures(t,r,o);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(t,i,o){const r=[],n=!!this.map._showQueryGeometry,s=Is.createFromScreenPoints(t,o);for(const e in i){const t=Us(s,i[e],this._availableImages,o,n,this.getActualScope());Object.keys(t).length&&r.push(t);}if(this.placement)for(const t in i){if(i[t].sourceCache._renderSourceType!==e.dA.Symbol)continue;const o=js(s.screenGeometry,i[t],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(o).length&&r.push(o);}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(zt,"querySourceFeatures.filter",i,null,t);let o=[];const r=this.getOwnSourceCaches(e);for(const e of r)o=o.concat(Gs(e,t));return o}addSourceType(e,t,i){return tl.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(tl.setSourceType(e,t),i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,o={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const i in t)if(!e.b7(t[i],r[i])){n=!0;break}if(!n)return;const s=this._getTransitionParameters();this.light.setLight(t,i,o),this.light.updateTransitions(s);}hasTerrain(){return !!this.terrain&&1===this.terrain.drapeRenderMode}getTerrain(){return this.hasTerrain()?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.r.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."));}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let o=t;const r=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in o&&"object"==typeof o.source){const t="terrain-dem-src";this.addSource(t,o.source),o=e.el(o),o=Object.assign(o,{source:t});}const t={...o},i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(Lt,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!o)return;this._createTerrain(o,i),this.fire(new e.B("data",{dataType:"style"}));}else {const i=this.terrain,r=i.get();for(const t of Object.keys(e.m.terrain))!Object.hasOwn(o,t)&&e.m.terrain[t].default&&(o[t]=e.m.terrain[t].default);for(const o in t)if(!e.b7(t[o],r[o])){i.set(t,this.options),this.stylesheet.terrain=t;const o=this._getTransitionParameters({duration:0});i.updateTransitions(o),this.fire(new e.B("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new Jt(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createSnow(e){const t=this.snow=new ii(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createRain(e){const t=this.rain=new oi(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity();});}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){const i=this.fog;if(!e.b7(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset();}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.b7(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createSnow(t);this._markersNeedUpdate=!0;}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.b7(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createRain(t);this._markersNeedUpdate=!0;}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const o=this._evaluateColorThemeData(i);this._loadColorTheme(o).then(()=>{this.fire(new e.B("colorthemeset")),t();}).catch(t=>{e.w(`Couldn't set color theme: ${t}`);});}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme();}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme());}_getTransitionParameters(t){return {now:e.r.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new Zt(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(t,i,o,r,n={}){if(n&&!1===n.validate)return !1;const s={...this.serialize()};return $a(this,t.call(Ct,{key:i,style:s,value:o,styleSpec:e.m,...r}))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),e.es.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];t.clearTiles(),t.setEventedParent(null);const i=t.getSource();i&&i.onRemove&&i.onRemove(this.map);}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager&&this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear();}}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope);});}updateSources(e){let t;this.directionalLight&&(t=ao(this.directionalLight));const i=new Set,o=new Set,r=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type?i.add(t.source):"raster"===t.type&&t.paint&&"ground"===t.paint.get("raster-elevation-reference")&&r.add(t.source),t.hasElevation()&&!o.has(t.source)&&o.add(t.source);}this.updateFrcCoverageFadeRange();for(const n in this._mergedSourceCaches){const s=this._mergedSourceCaches[n],a=o.has(s._source.id);s._isRasterElevatedOverTerrain=r.has(s._source.id),i.has(s._source.id)&&(s._source.reparseOverscaled=!1),s.update(e,void 0,void 0,t,a);}this.updateFrcCoverage(),this.updateElevationCoverage(),Es.markElevationIngestSourceCachesUsed&&Es.markElevationIngestSourceCachesUsed(this);}_reloadSources(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}updateFrcCoverageFadeRange(){this.map.painter&&Es.updateFrcCoverageFadeRange&&Es.updateFrcCoverageFadeRange(this,this.map.painter);}updateFrcCoverage(){this._hdCoverage&&Es.updateFrcCoverage&&Es.updateFrcCoverage(this,this._hdCoverage);}updateElevationCoverage(){this.isRootStyle()&&Es.setupAndUpdateElevationCoverage&&Es.setupAndUpdateElevationCoverage(this);}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new e.B("neworder"));}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Pa),this.pauseablePlacement.requestFullPlacement();}_setLabelPlacementStale(){this.placement&&this.placement.setStale();}_updatePlacement(t,i,o,r,n,s){this.pauseablePlacement||(this.pauseablePlacement=new Pa);let a=!1,l=!1;const c={},h={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if("symbol"!==o.type)continue;const r=e.y(o.source,o.scope);let n=c[r];if(!n){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[r]=t.slice(),n=c[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1));}const s=this.crossTileSymbolIndex.addLayer(o,n,t.center.lng,t.projection);a=a||s;}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const d=Boolean(this.placement&&!t.equals(this.placement.transform)),u=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!n||this.placement.lastReplacementSourceUpdateTime!==n.updateTime)),_=d||u||a,f=(_||this.pauseablePlacement.isStale())&&0===o,p=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.r.now(),t.zoom)&&0!==o;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||f||p)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,o,r,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex,s),this.map.painter)){const e=this.map.painter.maxFrontCutoffRawStart;if(e>0){const i=180*t.pitch/Math.PI;if(i>=15){const t=Math.min(1,Math.max(0,(i-15)/5)),o=t*t*(3-2*t);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-o)+e*o;}}}if(this.pauseablePlacement.isDone()?_&&0!==o&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,c,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.r.now()),l=!0),a&&this.pauseablePlacement.setStale()),l||a){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;te===t.id))return void this.fire(new e.A(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0);const r=o.findIndex(({id:e})=>e===i);return -1===r&&this.fire(new e.A(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=o.slice(0,r).concat(t).concat(o.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const o=this.stylesheet.imports||[],r=this.getImportIndex(t);return -1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==o[r].url&&this.setImportUrl(t,i.url),e.b7(i.config,o[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.b7(i.data,o[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const r=this.getImportIndex(t);if(-1===r)return this;const n=i[o],s=this.fragments[o];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(n).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(s).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const r=this.fragments[o];return r.style=this._createFragmentStyle(i[o]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t,i){this._checkLoaded();const o=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===o)return this;t?r[o].config=t:delete r[o].config;const n=this.fragments[o];i&&n.style.stylesheet&&(n.style.stylesheet.schema=i);const s=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports());}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return -1===i&&this.fire(new e.A(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const o=e.y(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.y(t.source,t.scope);return "symbol"===t.type?this._mergedSymbolSourceCaches[i]:"fill-extrusion"===t.type?this._mergedFillExtrusionSourceCaches[i]||this._mergedOtherSourceCaches[i]:"fill"===t.type&&t.sourceLayer===e.dC&&this._mergedHdRoadCoverageSourceCaches[i]?this._mergedHdRoadCoverageSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),this._mergedFillExtrusionSourceCaches[e]&&t.push(this._mergedFillExtrusionSourceCaches[e]),this._mergedHdRoadCoverageSourceCaches[e]&&t.push(this._mergedHdRoadCoverageSourceCaches[e]),this._mergedHdRoadElevationSourceCaches[e]&&t.push(this._mergedHdRoadElevationSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e);}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:"fill-extrusion"===e.type&&this._fillExtrusionSourceCaches[e.source]||this._otherSourceCaches[e.source]}getOwnSourceCaches(t){const i=[];return this._otherSourceCaches[t]&&i.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&i.push(this._symbolSourceCaches[t]),this._fillExtrusionSourceCaches[t]&&i.push(this._fillExtrusionSourceCaches[t]),this._hdCoverage&&this._hdCoverage.coverageSourceCaches[t]&&i.push(this._hdCoverage.coverageSourceCaches[t]),this._hdElevation&&this._hdElevation.elevationSourceCaches[e.y(t,this.scope)]&&i.push(this._hdElevation.elevationSourceCaches[e.y(t,this.scope)]),i}_updateHdCoverageSourceCache(t){return Es.HdCoverageState&&Es.updateHdCoverageSourceCache?(this._hdCoverage||(this._hdCoverage=new Es.HdCoverageState),Es.updateHdCoverageSourceCache(this,this._hdCoverage,t),!1):"fill"===t.type&&t.sourceLayer===e.dC}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.A(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return !1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),o="building"===e.type;if(e.is3D(!!this.terrain)){if(i||o||t&&"batched-model"===t.type)return !0;if("model"===e.type)return !0}else if("symbol"===e.type)return !0;return !1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(e=>{e.style._remove();}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}async getImages(t,i){const o=new Promise((e,t)=>{this.imageManager.getImages(i.icons.concat(i.patterns),i.scope,(i,o)=>{i?t(i):e(o);});});this._updateTilesForChangedImages();const r=i.icons.map(t=>e.I.toString(t)),n=i.patterns.map(t=>e.I.toString(t)),s=e=>{e&&(e.setDependencies(i.tileID.key,"icons",r),e.setDependencies(i.tileID.key,"patterns",n));},a=e.y(i.source,i.scope);return s(this._mergedOtherSourceCaches[a]),s(this._mergedSymbolSourceCaches[a]),(i.icons.some(e=>e.iconsetId)||i.patterns.some(e=>e.iconsetId))&&this.fire(new e.B("data",{dataType:"style"})),o}async rasterizeImages(e,t){return new Promise((e,i)=>{this.imageManager.rasterizeImages(t,(t,o)=>{t?i(t):e(o);});})}async checkAtlasCache(e,t){const i=this.imageManager.imageAtlasCache.findCachedAtlas(t.descriptor);return i&&i.contentDescriptor?{iconPositions:i.iconPositions,patternPositions:i.patternPositions,sourceHash:i.contentDescriptor.hash}:null}async getGlyphs(e,t){return new Promise((e,i)=>{this.glyphManager.getGlyphs(t.stacks,(t,o)=>{t?i(t):e(o);});})}}tl.getSourceType=Bs,tl.setSourceType=function(e,t){Fs[e]=t;},tl.registerForPluginStateChange=e.et;class il{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,r,n,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e{const n=o.paint.get("hillshade-shadow-color"),s="none"===o.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=o.paint.get("hillshade-highlight-color"),l="none"===o.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=o.paint.get("hillshade-accent-color"),h="none"===o.paint.get("hillshade-accent-color-use-theme").constantOr("default"),d=o.paint.get("hillshade-emissive-strength");let u=e.al(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))u-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.c5(i.x,i.y,i.z);u=e.al(o[1]);}const _=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),_),u_image:0,u_latrange:ol(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),u],u_shadow:n.toPremultipliedRenderColor(s?null:o.lut),u_highlight:a.toPremultipliedRenderColor(l?null:o.lut),u_emissive_strength:d,u_accent:c.toPremultipliedRenderColor(h?null:o.lut)}})(t,o,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,_,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(o);_.draw(t,c.TRIANGLES,n,s,a,yi.disabled,f,r.id,p,m,g);}function nl(t,i,o){if(!i.needsDEMTextureUpload)return;const r=t.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const s=o.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(r,s,n.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function sl(t,i,o){const r=t.context,n=r.gl;if(!i.dem)return;const s=i.dem;if(r.activeTexture.set(n.TEXTURE1),nl(t,i,s),!i.demTexture)return;i.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);const a=s.dim;r.activeTexture.set(n.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},n.RGBA8);t.bind(n.LINEAR,n.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,1,"renderbuffer"),l.colorAttachment0.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers(),u=[];t.linearFloatFilteringSupported()&&u.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&u.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:u}).draw(t,n.TRIANGLES,xi.disabled,$i.disabled,Ji.unblended,yi.disabled,((t,i)=>{const o=i.stride,r=e.aS();return e.aK(r,0,e.aj,-e.aj,0,0,1),e.aG(r,r,[0,-e.aj,0]),{u_matrix:r,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,s),o.id,c,h,d),i.needsHillshadePrepare=!1;}class al{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class ll extends al{getDefault(){return e.C.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class cl extends al{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class hl extends al{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class dl extends al{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class ul extends al{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class _l extends al{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class fl extends al{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class pl extends al{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class ml extends al{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class gl extends al{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class vl extends al{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class yl extends al{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class xl extends al{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class bl extends al{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class wl extends al{getDefault(){return e.C.transparent.toNonPremultipliedRenderColor(null)}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Tl extends al{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class El extends al{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class Sl extends al{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Il extends al{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let Cl=class extends al{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class Rl extends al{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class Dl extends al{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class Al extends al{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class Ll extends al{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class Pl extends al{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class Ol extends al{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Ml extends al{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class Fl extends al{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class zl extends al{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class Bl extends al{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class kl extends al{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class Nl extends al{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class Ul extends Nl{constructor(e,t,i=0){super(e,t),this.attachmentPoint=e.gl.COLOR_ATTACHMENT0+i;}setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachmentPoint,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class jl extends Nl{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class Gl extends Nl{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class Vl extends jl{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const ql=(e,t,i,o)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:o}),Hl=(e,t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:n,u_image0:0,u_image1:1,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:d,u_viewport:u,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:_,u_far_z_cutoff:f,u_emissive_texture_available:p});function Zl(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Wl=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,r){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:o,phase:0,duration:r,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}};function $l(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function Xl(e,t){const i=1<{if(t[i.key]="",!this._tiles[i.key]){const t=new dn(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);t.state="loaded",this._tiles[i.key]=t;}return t},{});for(const e in this._tiles)e in o||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class Jl extends e.br{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class ec extends e.e7{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,r,n]=function(){const t=new e.co,i=new e.cp,o=131;t.reserve(17161),i.reserve(33800);const r=e.aj/128,n=e.aj+r/2,s=n+r;for(let i=-r;in||i<0||i>n?24575:0,s=e.as(Math.round(o),0,e.aj),a=e.as(Math.round(i),0,e.aj);t.emplaceBack(s+r,a);}const a=(e,t)=>{const r=t*o+e;i.emplaceBack(r+1,r,r+o),i.emplaceBack(r+o,r+o+1,r+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);}),[t,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(o,e.cq.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.cr.simpleSegment(0,0,o.length,r.length),this.gridNoSkirtSegments=e.cr.simpleSegment(0,0,o.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ql(i.map),this.orthoMatrix=e.aS(),e.aK(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.aj,0,e.aj,0,1);const a=s.gl;this._overlapStencilMode=new $i({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Kl(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null;}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache();});}update(t,i,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,n=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.r.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=n?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.w(`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 t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const r=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const n=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(n);let a=n-this._previousZoom;const l=this._previousUpdateTimestamp;let c=n;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(n-c)>.5&&(a=.5*(n-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const h=s.getExaggeration(c),d=h===s.getExaggeration(Math.max(0,c-.1));if(d&&Math.abs(h-this._exaggeration)<.01)return h;let u=Math.min(.1,.00375*(this._updateTimestamp-l));return (d||h<.1||Math.abs(a)<1e-4)&&(u=Math.min(.2,4*u)),e.ai(this._exaggeration,h,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.ac.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(o.x,o.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={};}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(!i.transform)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],n),i.usedForTerrain)continue;const o=t[e];(i.getSource().reparseOverscaled||i._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=r.map(e=>new Jl(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);});}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const o=this.terrainTileForTile[i],r=o.dem;!r||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),nl(this.painter,o,r));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,n=Math.pow(2,t.tileID.canonical.z-r.z),s=o||"";return i[`u_dem_tl${s}`]=[r.x*n%1,r.y*n%1],i[`u_dem_scale${s}`]=n,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const o=i.dem.tree.minimums[0];return o>0&&e++,t+o},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),r=new e.ex({width:1,height:1},new Float32Array([o]));this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(r,{premultiply:!1}):n=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),n}setupElevationDraw(t,i,o){const r=this.painter.context,n=r.gl,s={u_dem:2,u_dem_prev:4,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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?n.LINEAR:n.NEAREST;let d=null;var u;if(this.enabled?l&&a?(d=a.demTexture,r.activeTexture.set(n.TEXTURE4),l.demTexture.bind(h(l),n.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],d=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):d=this.emptyDEMTexture,r.activeTexture.set(n.TEXTURE2),d&&(s.u_dem_size=1===(u=d).size[0]?1:u.size[0]-2,d.bind(h(a),n.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(o&&o.useDepthForOcclusion,i,s),o&&o.useMeterToDem&&a){const t=(1<{if(c===i)return;const o=[];1===i&&o.push("TERRAIN_VERTEX_MORPHING"),o.push("PROJECTION_GLOBE_VIEW"),d&&o.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:r}),c=i;},_=t.colorModeForRenderPass(),f=new xi(a.LEQUAL,xi.ReadWrite,t.depthRangeFor3D);Wl.update(n);const p=e.dp(h),m=[e.a_(h.center.lng),e.a$(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.r.devicePixelRatio,h.height*e.r.devicePixelRatio],y=Float32Array.from(h.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const h=t.transform,d=$l(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of r){const r=o.getTile(c),w=$i.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];Zl(T,E)&&Wl.newMorphing(c.key,T,E,n,250),Yl(t,r.emissiveTexture),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=Wl.getMorphValuesForProxy(c.key),I=S?1:0;S&&Object.assign(x,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.eu(S.phase)}});const C=e.dl(c.canonical),R=e.dm(C.getCenter().lat),D=e.dq(c.canonical,C,R,h.worldSize/h._pixelsPerMercatorPixel),A=e.d3(e.dn(c.canonical)),L="mrt-fallback"===t.emissiveMode?1:0,P=Hl(h.expandedFarZProjMatrix,y,p,A,e.ah(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,d,h._farZ,L,D);if(u(c,I),l&&(i.setupElevationDraw(r,l,x),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(R,0!==d);l.draw(t,b,f,w,_,yi.backCCW,P,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&n.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:n});for(const n of r){const{x:r,y:c,z:d}=n.canonical,u=0===c,p=c===(1<e.draw(t,a.TRIANGLES,f,$i.disabled,_,yi.disabled,Hl(h.expandedFarZProjMatrix,g,g,E,0,m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ,S),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,x),t.uploadCommonUniforms(s,l,n.toUnwrapped()),u&&t.renderDefaultNorthPole&&I(l,y),p&&t.renderDefaultSouthPole&&(g=e.bL(e.aS(),g,[1,-1,1]),I(l,b));}}}}(t,i,o,r,n);else {const s=t.context,a=s.gl;let l,c;const h=t.shadowRenderer,d=Zi(t,t.longestCutoffRange),u=e=>{if(c===e)return;const i=[];1===e&&i.push("TERRAIN_VERTEX_MORPHING"),d.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),h&&(i.push("RENDER_SHADOWS"),h.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},_=t.colorModeForRenderPass(),f=new xi(a.LEQUAL,xi.ReadWrite,t.depthRangeFor3D);Wl.update(n);const p=t.transform,m=$l(p.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=lo(t.style,e,i));}{c=-1;const v=a.TRIANGLES,[y,x]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=o.getTile(c),b=$i.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Zl(w,T)&&Wl.newMorphing(c.key,w,T,n,250),Yl(t,r.emissiveTexture),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Wl.getMorphValuesForProxy(c.key),S=E?1:0;let I;E&&(I={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.eu(E.phase)}});const C="mrt-fallback"===t.emissiveMode?1:0,R=ql(c.projMatrix,Xl(c.canonical,p.renderWorldCopies)?m/10:m,g,C);if(u(S),!l)continue;i.setupElevationDraw(r,l,I);const D=c.toUnwrapped();h&&h.setupShadows(D,l),t.uploadCommonUniforms(s,l,D,null,d),l.draw(t,v,f,b,_,yi.backCCW,R,"terrain_raster",i.gridBuffer,y,x);}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length));}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,o=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let c=0;for(const h of n){const n=r.getTileByID(h.proxyTileKey),d=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,u=void 0!==d?r.renderCache[d]:this.pool[c++],_=void 0!==d;if(n.texture=u.tex,n.emissiveTexture=u.emissiveTex,_&&!u.dirty){l.push(n.tileID);continue}o.bindFramebuffer.set(u.fb.framebuffer);const f=o.gl;let p;f.drawBuffers("mrt-fallback"===i.emissiveMode?[f.COLOR_ATTACHMENT0,f.COLOR_ATTACHMENT1]:[f.COLOR_ATTACHMENT0]),this.renderedToTile=!1,u.dirty&&(o.clear({color:e.C.transparent,stencil:0}),u.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),n=r?this.proxyToSource[h.key][r.id]:[h];if(!n)continue;const s=n;o.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(u,n,t,r),p=r?r.id:null),i.renderLayer(i,r,t,s);}if(f.drawBuffers([f.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),n=r?this.proxyToSource[h.key][r.id]:[h];if(!n)continue;const s=n;o.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(u,n,t,r),p=r?r.id:null),i.renderLayer(i,r,t,s);}this.renderedToTile?(u.dirty=!0,l.push(n.tileID)):_||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=t;for(let r=0;ri}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0]);}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter(e=>e.dem).map(o=>{const r=o.tileID,n=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of o){if(null==r.t)return null;const o=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:o[0],height:o[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const n=t.createFramebuffer(o[0],o[1],1,null);let s;return n.colorAttachment0.set(r.texture),this._emissiveTexture&&(s=new e.T(t,{width:o[0],height:o[1],data:null},i.R8),s.bind(i.LINEAR,i.CLAMP_TO_EDGE),n.createColorAttachment(t,1),n.colorAttachment1.set(s.texture)),n.depthAttachment=new Vl(t,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:n,tex:r,emissiveTex:s,dirty:!1}}_updateFBOs(e){if(this._emissiveTexture!==e){for(const t of this.pool)this._updateFBO(t,e);for(const t of this.proxySourceCache.renderCache)this._updateFBO(t,e);this._emissiveTexture=e;}}_updateFBO(t,i){const o=t.fb,r=this.painter.context,n=r.gl,s=this.drapeBufferSize;if(i){const i=new e.T(r,{width:s[0],height:s[1],data:null},n.R8);i.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.emissiveTex=i,o.createColorAttachment(r,1),o.colorAttachment1.set(i.texture);}else t.emissiveTex=void 0,o.removeColorAttachment(r,1);t.dirty=!0;}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof As){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=o;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;r--){const n=i[r];if(t.getTileByID(n.key),void 0!==t.proxyCachedFBO[n.key]){const i=e[n.key],r=this.proxyToSource[n.key];let s=0;for(const e in r){const t=r[e],n=i[e];if(!n||n.length!==t.length||t.some((t,i)=>t!==n[i]||o[e]&&Object.hasOwn(o[e],t.key))){s=-1;break}++s;}for(const e in t.proxyCachedFBO[n.key])t.renderCache[t.proxyCachedFBO[n.key][e]].dirty=s<0||s!==Object.values(i).length;}}const r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const o of i){if(t.proxyCachedFBO[o.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,n=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:n.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t.at(-1).overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:n.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+s>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,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):$i.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,r=o.gl;i._tileClippingMaskIDs={},o.setColorMode(Ji.disabled),o.setDepthMode(xi.disabled);const n=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;n.draw(i,r.TRIANGLES,xi.disabled,new $i({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Ji.disabled,yi.disabled,fs(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const o=[t.x,t.y,1,1];e.aO(o,o,i.pixelMatrixInverse),e.bB(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const r=i._camera.position,n=e.aL(1,i.center.lat),s=[r[0],r[1],r[2]/n,0],a=e.cA([],o.slice(0,3),s);e.au(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.aY(s,s,a,l),s[3]=s[2],s[2]*=n,s):null}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof Ms)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const o=this.proxiedCoords[e.id]=[],r=this.proxyCoords;for(let t=0;tt.overscaledZ-e.overscaledZ);}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],n=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<s+c.max.x||r+na+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let n,s,a;r=e.aS();const l=i.tileID.wrap-t.wrap<0?(n=e.aj>>o,s=n*((i.tileID.canonical.x<=r){const o=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.br(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(a=r,s=new e.br(a,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o));}s.key!==t.key&&(c.push(s.key),o=i.getTile(s));}const h=e=>{c.forEach(t=>{r[t]=e;}),c.length=0;};for(a-=1;a>=l&&(!o||!o.hasData());a--){o&&h(o.tileID.key);const e=s.calculateScaledKey(a);if(o=i.getTileByID(e),o&&o.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function tc(t,i,o){const r=function(t,i,o){const r=e.aw(i,t),n=e.aw(o,[.2126,.7152,.0722]),s=1-.3*Math.min(n,1),a=e.ai(s,1,Math.min(r+1,1));return e.ai(.92,1,Math.asin(e.as(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),n=[0,0,0];e.av(n,o.slice(0,3),r);const s=[0,0,0];e.av(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.cz(a,n,s),e.c7(a)}const ic=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],oc=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class rc{static cacheKey(e,t,i,o){const r=[t];o&&r.push(o.cacheKey);for(const t of i)("string"==typeof t&&t.includes(" ")||e.usedDefines.has(t))&&r.push(t);return r.join("/")}constructor(e,t,i,o,r,n,s=!1){const a=e.gl;this.program=a.createProgram(),this._context=e,this._fixedUniformsFn=r,this._pending=!0,this._precompiled=s,this.attributes={},this.configuration=o,this.name=t,this.fixedDefines=[...n],s?e._compileStats.precompiled++:e._compileStats.onDemand++;const l=`#version 300 es\n${(o?o.defines():[]).concat(n.map(e=>`#define ${e}`)).join("\n")}`,c=[l,fr];for(const e of i.fragmentIncludes)c.push(lr[e]);c.push(i.fragmentSource);const h=c.join("\n"),d=[l,pr];for(const e of i.vertexIncludes)d.push(lr[e]);this.forceManualRenderingForInstanceIDShaders=e.forceManualRenderingForInstanceIDShaders&&i.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&d.push("uniform int u_instanceID;"),d.push(i.vertexSource);let u=d.join("\n");this.forceManualRenderingForInstanceIDShaders&&(u=u.replaceAll("gl_InstanceID","u_instanceID"));const _=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);a.shaderSource(_,h),a.compileShader(_),a.attachShader(this.program,_);const f=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);a.shaderSource(f,u),a.compileShader(f),a.attachShader(this.program,f),a.linkProgram(this.program),this._fragmentShader=_,this._vertexShader=f,e.extParallelShaderCompile?e._pendingPrograms.add(this):this._finalize();}_finalize(){if(!this._pending)return;this._pending=!1;const t=this._context,i=t.gl;t._pendingPrograms.delete(this);const o=e.r.now(),r=i.getProgramParameter(this.program,i.LINK_STATUS),n=e.r.now()-o,s=t._compileStats;if(s.totalStallMs+=n,n>s.maxStallMs&&(s.maxStallMs=n),n>1){s.framesMissed+=Math.floor(60*n/1e3);const e=this.fixedDefines.join(",");s.stalls.push({name:`${this.name}${e?"/":""}${e}`,ms:n,timestamp:o});}if(this._fragmentShader&&(r||e.w(`Fragment shader '${this.name}': ${i.getShaderInfoLog(this._fragmentShader)}`),i.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(r||e.w(`Vertex shader '${this.name}': ${i.getShaderInfoLog(this._vertexShader)}`),i.deleteShader(this._vertexShader),this._vertexShader=null),!r)return e.w(`Failed to link program '${this.name}': ${i.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.b_(t)}))(t));const a=this.fixedDefines,l=this.name;(a.includes("TERRAIN")||a.includes("ELEVATED")||l.includes("symbol")||l.includes("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.b_(t),u_dem_prev:new e.b_(t),u_dem_tl:new e.b$(t),u_dem_scale:new e.ar(t),u_dem_tl_prev:new e.b$(t),u_dem_scale_prev:new e.ar(t),u_dem_size:new e.ar(t),u_dem_lerp:new e.ar(t),u_exaggeration:new e.ar(t),u_depth:new e.b_(t),u_depth_size_inv:new e.b$(t),u_depth_range_unpack:new e.b$(t),u_occluder_half_size:new e.ar(t),u_occlusion_depth_offset:new e.ar(t),u_meter_to_dem:new e.ar(t),u_label_plane_matrix_inv:new e.ap(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.aq(t),u_tile_tr_up:new e.aq(t),u_tile_br_up:new e.aq(t),u_tile_bl_up:new e.aq(t),u_tile_up_scale:new e.ar(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.ap(t),u_fog_range:new e.b$(t),u_fog_color:new e.bZ(t),u_fog_horizon_blend:new e.ar(t),u_fog_vertical_limit:new e.b$(t),u_fog_temporal_offset:new e.ar(t),u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_globe_pos:new e.aq(t),u_globe_radius:new e.ar(t),u_globe_transition:new e.ar(t),u_is_globe:new e.b_(t),u_viewport:new e.b$(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.bZ(t)}))(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.aq(t),u_lighting_directional_dir:new e.aq(t),u_lighting_directional_color:new e.aq(t),u_ground_radiance:new e.aq(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.ap(t),u_light_matrix_1:new e.ap(t),u_fade_range:new e.b$(t),u_shadow_normal_offset:new e.aq(t),u_shadow_intensity:new e.ar(t),u_shadow_texel_size:new e.ar(t),u_shadow_map_resolution:new e.ar(t),u_shadow_direction:new e.aq(t),u_shadow_bias:new e.aq(t),u_shadowmap_0:new e.b_(t),u_shadowmap_1:new e.b_(t)}))(t));}maybeFinalize(){if(!this._pending)return;const e=this._context.extParallelShaderCompile;e&&!this._context.gl.getProgramParameter(this.program,e.COMPLETION_STATUS_KHR)||this._finalize();}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms());}getAttributeLocation(e,t){this._ensureReady();let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(this._ensureReady(),!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(this._ensureReady(),!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(this._ensureReady(),!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(this._ensureReady(),!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(this._ensureReady(),!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(t,i,o,r,n,s,a,l,c,h){const d=t.options.wireframe;if(!1===d.terrain&&!1===d.layers2D&&!1===d.layers3D)return;const u=t.context;if(!(()=>!(!d.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!d.layers2D||t._terrain&&t._terrain.renderingToTexture||!ic.includes(this.name))||!(!d.layers3D||!oc.includes(this.name)))())return;const _=u.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,n,u);if(!f)return;const p=[...this.fixedDefines,"DEBUG_WIREFRAME"],m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:p});m._ensureReady(),u.program.set(m.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(m.program,u,m.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,m),g("terrainUniforms",this,m),g("globeUniforms",this,m),g("fogUniforms",this,m),g("lightsUniforms",this,m),g("shadowUniforms",this,m),f.bind(),u.setColorMode(new Ji([_.ONE,_.ONE_MINUS_SRC_ALPHA,_.ZERO,_.ONE],e.C.transparent,[!0,!0,!0,!1])),u.setDepthMode(new xi(i.func===_.LESS?_.LEQUAL:i.func,xi.ReadOnly,i.range)),u.setStencilMode($i.disabled);const v=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=h||1;for(let t=0;t1?_.drawElementsInstanced(_.LINES,v,_.UNSIGNED_SHORT,y,h):_.drawElements(_.LINES,v,_.UNSIGNED_SHORT,y);n.bind(),u.program.set(this.program),u.setDepthMode(i),u.setStencilMode(o),u.setColorMode(r);}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const o of Object.keys(i))if(!i[o].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${o} not set but required by ${t} being defined`)}draw(e,t,i,o,r,n,s,a,l,c,h,d,u,_,f,p){const m=e.context,g=m.gl;if(this._ensureReady(),this.failedToCreate)return;m.program.set(this.program),m.setDepthMode(i),m.setStencilMode(o),m.setColorMode(r),m.setCullFace(n);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,s[e]);_&&_.setUniforms(this.program,m,this.binderUniforms,d,{zoom:u});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=f||[],x=_?_.getPaintVertexBuffers():[],b=t===g.TRIANGLES&&c,w=p&&p>0?1:void 0;for(const n of h.get()){const s=n.vaos||(n.vaos={});if((s[a]||(s[a]=new il)).bind(m,this,l,x,c,n.vertexOffset,y,w),this.forceManualRenderingForInstanceIDShaders){const e=p||1;for(let i=0;i1?g.drawElementsInstanced(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2,p):c?g.drawElements(t,n.primitiveLength*v,g.UNSIGNED_SHORT,n.primitiveOffset*v*2):g.drawArrays(t,n.vertexOffset,n.vertexLength);b&&this._drawDebugWireframe(e,i,o,r,c,n,d,u,_,p);}}}const nc=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i,u_opacity_multiplier:1}),sc=(e,t,i,o,r,n=0)=>Object.assign(nc(e,t,r),eo(i,o,n)),ac=(e,t,i,o)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:o,u_opacity_multiplier:1}),lc=(e,t,i,o,r,n,s=0)=>Object.assign(sc(e,t,i,o,n,s),{u_world:r}),cc=(e,t,i)=>({u_image:e,u_texel_size:t,u_first_pass:i?1:0}),hc=(t,i,o,r,n,s,a,l)=>{const c=e.aj/s.tileSize;return {u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:o.getCameraToCenterDistance(l),u_extrude_scale:[o.pixelsToGLUnits[0]/c,o.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:n}},dc=(e,t,i,o)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(o),u_viewport_size:[i.width,i.height]}),uc=e.aS(),_c=(t,i,o,r,n,s,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.eA(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.c1(o,1,s),d={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:uc,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){d.u_inv_rot_matrix=r,d.u_merc_center=n,d.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:i,u_normalize_matrix:o,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:s,u_tl_parent:a,u_scale_parent:d,u_fade_t:u.mix,u_opacity:u.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:e.eD(_.paint.get("raster-saturation")),u_contrast_factor:e.eC(_.paint.get("raster-contrast")),u_spin_weights:mc(_.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:p,u_zoom_transition:l,u_merc_center:c,u_cutoff_params:h,u_colorization_mix:Kr(e.eB,g,y),u_colorization_offset:Qr(e.eB,v,y),u_color_ramp:m,u_texture_offset:[b/(x+2*b),x/(x+2*b)],u_texture_res:[x+2*b,x+2*b],u_emissive_strength:w,u_zbias_factor:fc(t)});function mc(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const gc=e.aS(),vc=(t,i,o,r,n,s,a,l,c,h,d,u,_,f,p,m,g,v,y,x,b,w,T,E,S)=>{const I=n.transform,C={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:I.getCameraToCenterDistance(x),u_rotate_symbol:+o,u_aspect_ratio:I.width/I.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:+h,u_is_sdf:+d,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:u,u_texsize_icon:_,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:gc,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:gc,u_up_vector:[0,-1,0],u_color_adj_mat:T,u_icon_transition:E||0,u_gamma_scale:d?r?n.transform.getCameraToCenterDistance(x)*Math.cos(n.terrain?0:n.transform._pitch):1:0,u_device_pixel_ratio:e.r.devicePixelRatio,u_is_halo:1,u_scale_factor:S||1,u_ground_shadow_factor:b,u_inv_matrix:e.aE(e.aS(),a),u_normal_scale:w,u_lutTexture:10,u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0],u_spp_fill_color_zoom_factor:0,u_spp_halo_color_zoom_factor:0,u_spp_opacity_zoom_factor:0,u_spp_halo_width_zoom_factor:0,u_spp_halo_blur_zoom_factor:0,u_spp_emissive_strength_zoom_factor:0,u_spp_occlusion_opacity_zoom_factor:0,u_spp_z_offset_zoom_factor:0,u_spp_translate_zoom_factor:0,u_spp_zoom_fraction:0,u_opacity_multiplier:1};return "globe"===x.name&&(C.u_tile_id=[p.canonical.x,p.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),xc=(t,i,o,r,n,s,a,l,c)=>Object.assign(function(t,i,o,r,n,s){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),h=s.tileSize*Math.pow(2,r.transform.tileZoom)/c,d=h*(s.tileID.canonical.x+s.tileID.wrap*c),u=h*s.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[a,l],u_pattern_size:o.displaySize,u_pattern_units_to_pixels:n?[r.transform.width,-1*r.transform.height]:[1/e.c1(s,1,r.transform.tileZoom),1/e.c1(s,1,r.transform.tileZoom)],u_pixel_coord_upper:[d>>16,u>>16],u_pixel_coord_lower:[65535&d,65535&u]}}(0,s,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),bc={fillExtrusion:t=>({u_matrix:new e.ap(t),u_lightpos:new e.aq(t),u_lightintensity:new e.ar(t),u_lightcolor:new e.aq(t),u_vertical_gradient:new e.ar(t),u_opacity:new e.ar(t),u_edge_radius:new e.ar(t),u_width_scale:new e.ar(t),u_ao:new e.b$(t),u_height_type:new e.b_(t),u_base_type:new e.b_(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.ar(t),u_inv_rot_matrix:new e.ap(t),u_merc_center:new e.b$(t),u_up_dir:new e.aq(t),u_height_lift:new e.ar(t),u_flood_light_color:new e.aq(t),u_vertical_scale:new e.ar(t),u_flood_light_intensity:new e.ar(t),u_ground_shadow_factor:new e.aq(t),u_front_cutoff_params:new e.aq(t)}),fillExtrusionPattern:t=>({u_matrix:new e.ap(t),u_lightpos:new e.aq(t),u_lightintensity:new e.ar(t),u_lightcolor:new e.aq(t),u_vertical_gradient:new e.ar(t),u_height_factor:new e.ar(t),u_edge_radius:new e.ar(t),u_width_scale:new e.ar(t),u_ao:new e.b$(t),u_height_type:new e.b_(t),u_base_type:new e.b_(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.ar(t),u_inv_rot_matrix:new e.ap(t),u_merc_center:new e.b$(t),u_up_dir:new e.aq(t),u_height_lift:new e.ar(t),u_image:new e.b_(t),u_texsize:new e.b$(t),u_pixel_coord_upper:new e.b$(t),u_pixel_coord_lower:new e.b$(t),u_tile_units_to_pixels:new e.ar(t),u_opacity:new e.ar(t),u_pattern_transition:new e.ar(t)}),fill:t=>({u_matrix:new e.ap(t),u_emissive_strength:new e.ar(t),u_ground_shadow_factor:new e.aq(t),u_opacity_multiplier:new e.ar(t)}),fillPattern:t=>({u_matrix:new e.ap(t),u_emissive_strength:new e.ar(t),u_image:new e.b_(t),u_texsize:new e.b$(t),u_pixel_coord_upper:new e.b$(t),u_pixel_coord_lower:new e.b$(t),u_tile_units_to_pixels:new e.ar(t),u_ground_shadow_factor:new e.aq(t),u_pattern_transition:new e.ar(t),u_opacity_multiplier:new e.ar(t)}),fillOutline:t=>({u_matrix:new e.ap(t),u_emissive_strength:new e.ar(t),u_world:new e.b$(t),u_ground_shadow_factor:new e.aq(t),u_opacity_multiplier:new e.ar(t)}),fillOutlinePattern:t=>({u_matrix:new e.ap(t),u_emissive_strength:new e.ar(t),u_world:new e.b$(t),u_image:new e.b_(t),u_texsize:new e.b$(t),u_pixel_coord_upper:new e.b$(t),u_pixel_coord_lower:new e.b$(t),u_tile_units_to_pixels:new e.ar(t),u_ground_shadow_factor:new e.aq(t),u_pattern_transition:new e.ar(t),u_opacity_multiplier:new e.ar(t)}),lineBlendComposite:t=>({u_image:new e.b_(t),u_opacity:new e.ar(t),u_blend_mode:new e.b_(t),u_max_density:new e.ar(t)}),lineBlendReduce:t=>({u_image:new e.b_(t),u_texel_size:new e.b$(t),u_first_pass:new e.b_(t)}),circle:e.eH,collisionBox:t=>({u_matrix:new e.ap(t),u_inv_rot_matrix:new e.ap(t),u_camera_to_center_distance:new e.ar(t),u_extrude_scale:new e.b$(t),u_zoom_transition:new e.ar(t),u_merc_center:new e.b$(t),u_tile_id:new e.aq(t)}),collisionCircle:t=>({u_matrix:new e.ap(t),u_inv_matrix:new e.ap(t),u_camera_to_center_distance:new e.ar(t),u_viewport_size:new e.b$(t)}),debug:t=>({u_color:new e.c9(t),u_matrix:new e.ap(t),u_overlay:new e.b_(t),u_overlay_scale:new e.ar(t)}),clippingMask:t=>({u_matrix:new e.ap(t)}),heatmap:t=>({u_extrude_scale:new e.ar(t),u_intensity:new e.ar(t),u_matrix:new e.ap(t),u_inv_rot_matrix:new e.ap(t),u_merc_center:new e.b$(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.ar(t),u_up_dir:new e.aq(t)}),heatmapTexture:t=>({u_image:new e.b_(t),u_color_ramp:new e.b_(t),u_opacity:new e.ar(t)}),hillshade:t=>({u_matrix:new e.ap(t),u_image:new e.b_(t),u_latrange:new e.b$(t),u_light:new e.b$(t),u_shadow:new e.c9(t),u_highlight:new e.c9(t),u_emissive_strength:new e.ar(t),u_accent:new e.c9(t)}),hillshadePrepare:t=>({u_matrix:new e.ap(t),u_image:new e.b_(t),u_dimension:new e.b$(t),u_zoom:new e.ar(t)}),line:e.eG,linePattern:e.eF,raster:t=>({u_matrix:new e.ap(t),u_normalize_matrix:new e.ap(t),u_globe_matrix:new e.ap(t),u_merc_matrix:new e.ap(t),u_grid_matrix:new e.cN(t),u_tl_parent:new e.b$(t),u_scale_parent:new e.ar(t),u_fade_t:new e.ar(t),u_opacity:new e.ar(t),u_image0:new e.b_(t),u_image1:new e.b_(t),u_brightness_low:new e.ar(t),u_brightness_high:new e.ar(t),u_saturation_factor:new e.ar(t),u_contrast_factor:new e.ar(t),u_spin_weights:new e.aq(t),u_perspective_transform:new e.b$(t),u_raster_elevation:new e.ar(t),u_zoom_transition:new e.ar(t),u_merc_center:new e.b$(t),u_cutoff_params:new e.bZ(t),u_colorization_mix:new e.bZ(t),u_colorization_offset:new e.ar(t),u_color_ramp:new e.b_(t),u_texture_offset:new e.b$(t),u_texture_res:new e.b$(t),u_emissive_strength:new e.ar(t),u_zbias_factor:new e.ar(t)}),symbol:t=>({u_is_size_zoom_constant:new e.b_(t),u_is_size_feature_constant:new e.b_(t),u_size_t:new e.ar(t),u_size:new e.ar(t),u_camera_to_center_distance:new e.ar(t),u_rotate_symbol:new e.b_(t),u_aspect_ratio:new e.ar(t),u_fade_change:new e.ar(t),u_matrix:new e.ap(t),u_label_plane_matrix:new e.ap(t),u_coord_matrix:new e.ap(t),u_is_text:new e.b_(t),u_is_sdf:new e.b_(t),u_elevation_from_sea:new e.b_(t),u_pitch_with_map:new e.b_(t),u_texsize:new e.b$(t),u_texsize_icon:new e.b$(t),u_texture:new e.b_(t),u_texture_icon:new e.b_(t),u_gamma_scale:new e.ar(t),u_device_pixel_ratio:new e.ar(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.ar(t),u_inv_rot_matrix:new e.ap(t),u_merc_center:new e.b$(t),u_camera_forward:new e.aq(t),u_tile_matrix:new e.ap(t),u_up_vector:new e.aq(t),u_ecef_origin:new e.aq(t),u_is_halo:new e.b_(t),u_icon_transition:new e.ar(t),u_color_adj_mat:new e.ap(t),u_scale_factor:new e.ar(t),u_ground_shadow_factor:new e.aq(t),u_inv_matrix:new e.ap(t),u_normal_scale:new e.ar(t),u_lutTexture:new e.b_(t),u_spp_fill_np_color:new e.bZ(t),u_spp_halo_np_color:new e.bZ(t),u_spp_opacity:new e.ar(t),u_spp_halo_width:new e.ar(t),u_spp_halo_blur:new e.ar(t),u_spp_emissive_strength:new e.ar(t),u_spp_occlusion_opacity:new e.ar(t),u_spp_z_offset:new e.ar(t),u_spp_translate_rotation:new e.b$(t),u_spp_fill_color_zoom_factor:new e.ar(t),u_spp_halo_color_zoom_factor:new e.ar(t),u_spp_opacity_zoom_factor:new e.ar(t),u_spp_halo_width_zoom_factor:new e.ar(t),u_spp_halo_blur_zoom_factor:new e.ar(t),u_spp_emissive_strength_zoom_factor:new e.ar(t),u_spp_occlusion_opacity_zoom_factor:new e.ar(t),u_spp_z_offset_zoom_factor:new e.ar(t),u_spp_translate_zoom_factor:new e.ar(t),u_spp_zoom_fraction:new e.ar(t),u_opacity_multiplier:new e.ar(t)}),background:t=>({u_matrix:new e.ap(t),u_emissive_strength:new e.ar(t),u_opacity:new e.ar(t),u_color:new e.c9(t)}),backgroundPattern:t=>({u_matrix:new e.ap(t),u_emissive_strength:new e.ar(t),u_opacity:new e.ar(t),u_image:new e.b_(t),u_pattern_tl:new e.b$(t),u_pattern_br:new e.b$(t),u_texsize:new e.b$(t),u_pattern_size:new e.b$(t),u_pixel_coord_upper:new e.b$(t),u_pixel_coord_lower:new e.b$(t),u_pattern_units_to_pixels:new e.b$(t)}),terrainRaster:t=>({u_matrix:new e.ap(t),u_image0:new e.b_(t),u_image1:new e.b_(t),u_skirt_height:new e.ar(t),u_ground_shadow_factor:new e.aq(t),u_emissive_texture_available:new e.ar(t)}),skybox:t=>({u_matrix:new e.ap(t),u_sun_direction:new e.aq(t),u_cubemap:new e.b_(t),u_opacity:new e.ar(t),u_temporal_offset:new e.ar(t)}),skyboxGradient:t=>({u_matrix:new e.ap(t),u_color_ramp:new e.b_(t),u_center_direction:new e.aq(t),u_radius:new e.ar(t),u_opacity:new e.ar(t),u_temporal_offset:new e.ar(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cN(t),u_sun_direction:new e.aq(t),u_sun_intensity:new e.ar(t),u_color_tint_r:new e.bZ(t),u_color_tint_m:new e.bZ(t),u_luminance:new e.ar(t)}),globeRaster:t=>({u_proj_matrix:new e.ap(t),u_globe_matrix:new e.ap(t),u_normalize_matrix:new e.ap(t),u_merc_matrix:new e.ap(t),u_zoom_transition:new e.ar(t),u_merc_center:new e.b$(t),u_image0:new e.b_(t),u_image1:new e.b_(t),u_grid_matrix:new e.cN(t),u_skirt_height:new e.ar(t),u_far_z_cutoff:new e.ar(t),u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_globe_pos:new e.aq(t),u_globe_radius:new e.ar(t),u_viewport:new e.b$(t),u_emissive_texture_available:new e.ar(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_horizon:new e.ar(t),u_transition:new e.ar(t),u_fadeout_range:new e.ar(t),u_atmosphere_fog_color:new e.bZ(t),u_high_color:new e.bZ(t),u_space_color:new e.bZ(t),u_temporal_offset:new e.ar(t),u_horizon_angle:new e.ar(t)}),stars:t=>({u_matrix:new e.ap(t),u_up:new e.aq(t),u_right:new e.aq(t),u_intensity_multiplier:new e.ar(t)}),occlusion:t=>({u_matrix:new e.ap(t),u_anchorPos:new e.aq(t),u_screenSizePx:new e.b$(t),u_occluderSizePx:new e.b$(t),u_color:new e.bZ(t)})};class wc{constructor(e,t,i,o){this.id=wc.uniqueIdxCounter,wc.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||o||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=wc.uniqueIdxCounter,wc.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}wc.uniqueIdxCounter=0;const Tc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ec{constructor(e,t,i,o,r,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=n,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||r||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(const i of this.attributes){const o=t.getAttributeLocation(e,i.name);-1!==o&&e.enableVertexAttribArray(o);}}setVertexAttribPointers(e,t,i){for(const o of this.attributes){const r=t.getAttributeLocation(e,o.name);if(-1!==r){const t=o.offset+this.itemSize*(i||0);"Float32"===o.type?e.vertexAttribPointer(r,o.components,e.FLOAT,!1,this.itemSize,t):e.vertexAttribIPointer(r,o.components,e[Tc[o.type]],this.itemSize,t);}}}setVertexAttribDivisor(e,t,i){for(let o=0;o0&&e.vertexAttribDivisor(r,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class Sc{constructor(e,t,i,o,r){this.context=e,this.width=t,this.height=i;const n=this.framebuffer=e.gl.createFramebuffer();o>0&&(this.colorAttachment0=new Ul(e,n,0)),o>1&&(this.colorAttachment1=new Ul(e,n,1)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new jl(e,n):new Gl(e,n));}static createWithTexture(t,i,o,r,n){const s=t.gl;if(t.activeTexture.set(s.TEXTURE1),t.viewport.set([0,0,o,r]),i&&i.width===o&&i.height===r)return s.bindTexture(s.TEXTURE_2D,i.colorAttachment0.get()),t.bindFramebuffer.set(i.framebuffer),i;i&&i.destroy();const a=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,l=new e.T(t,{width:o,height:r,data:null},a);l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const c=t.createFramebuffer(o,r,1,null);if(c.format=a,c.colorAttachment0.set(l.texture),n){const e=t.createRenderbuffer(s.DEPTH24_STENCIL8,o,r);t.bindFramebuffer.set(c.framebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e),c._stencilRbo=e;}return c}createColorAttachment(e,t){0===t?this.colorAttachment0=new Ul(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new Ul(e,this.framebuffer,1));}removeColorAttachment(e,t){const i=this.context.gl;let o;0===t?(o=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(o=this.colorAttachment1.get(),this.colorAttachment1=void 0),o&&i.deleteTexture(o);}destroy(){const e=this.context.gl;if(this.colorAttachment0){const t=this.colorAttachment0.get();t&&e.deleteTexture(t);}if(this.colorAttachment1){const t=this.colorAttachment1.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}this._stencilRbo&&(e.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),e.deleteFramebuffer(this.framebuffer);}}class Ic{constructor(e,t){this.gl=e,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new ll(this),this.clearDepth=new cl(this),this.clearStencil=new hl(this),this.colorMask=new dl(this),this.depthMask=new ul(this),this.stencilMask=new _l(this),this.stencilFunc=new fl(this),this.stencilOp=new pl(this),this.stencilTest=new ml(this),this.depthRange=new gl(this),this.depthTest=new vl(this),this.depthFunc=new yl(this),this.blend=new xl(this),this.blendFunc=new bl(this),this.blendColor=new wl(this),this.blendEquation=new Tl(this),this.cullFace=new El(this),this.cullFaceSide=new Sl(this),this.frontFace=new Il(this),this.program=new Cl(this),this.activeTexture=new Rl(this),this.viewport=new Dl(this),this.bindFramebuffer=new Al(this),this.bindRenderbuffer=new Ll(this),this.bindTexture=new Pl(this),this.bindVertexBuffer=new Ol(this),this.bindElementBuffer=new Ml(this),this.bindVertexArrayOES=new Fl(this),this.pixelStoreUnpack=new zl(this),this.pixelStoreUnpackPremultiplyAlpha=new Bl(this),this.pixelStoreUnpackFlipY=new kl(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=e.getExtension("EXT_color_buffer_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=e.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=e.getExtension("KHR_parallel_shader_compile");}sweepPendingPrograms(){if(0!==this._pendingPrograms.size)for(const e of this._pendingPrograms)e.maybeFinalize();}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault();}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new wc(this,e,t,i)}createVertexBuffer(e,t,i,o,r){return new Ec(this,e,t,i,o,r)}createRenderbuffer(e,t,i){const o=this.gl,r=o.createRenderbuffer();return this.bindRenderbuffer.set(r),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,o){return new Sc(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(t){e.b7(t.blendFunction,Ji.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}let Cc;function Rc(t,i,o,r,n,s,a){const l=t.context,c=l.gl,h=t.transform,d=[e.a_(h.center.lng),e.a$(h.center.lat)],u=o.layout.get("symbol-placement"),_=o.layout.get("text-variable-anchor"),f="map"===o.layout.get("icon-rotation-alignment"),p="map"===o.layout.get("text-rotation-alignment"),m="point"!==u,g=[];let v=0,y=0;for(let l=0;l0){const t=e.aS(),i=O;e.bI(t,b.placementInvProjMatrix,h.glCoordMatrix),e.bI(t,t,b.placementViewportMatrix),g.push({circleArray:F,circleOffset:y,transform:i,invTransform:t,projection:b.getProjection()}),v+=F.length/4,y=v;}if(!M)continue;t.terrain&&t.terrain.setupElevationDraw(x,P);const z=A?[u.canonical.x,u.canonical.y,1<=0&&(f[y.associatedIconIndex]={x:I,y:C,z:R,angle:O});}else Gi(w,u);}if(h){_.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,o=t.style.ambientLight;e&&o&&(i=lo(t.style,e,o));}return i},H=e=>{const i=Math.floor(t.context.maxUniformBlockSize/4),o=Math.floor(i/4);e.push(`MAX_UBO_SIZE_VEC4 ${o}u`);},Z=e=>{I.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},W=i=>{o.lut&&!T&&(o.lut.texture||(o.lut.texture=new e.ct(t.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],E.gl.RGBA8)),E.activeTexture.set(E.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(E.gl.LINEAR,E.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"));},$=()=>{const i=C&&"point"!==o.layout.get("symbol-placement"),a=[];Z(a),W(a);const c=i||j,d="road"===s.elevationType,g=t.shadowRenderer,T=d&&D&&!!g&&g.enabled,E=q(T),R=d&&D&&!t.terrain?M:O,A=o.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&D&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),A>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||d&&t.terrain||a.push("Z_OFFSET"),0===v&&0===y&&0===x&&1===b||a.push("COLOR_ADJUSTMENT"),T&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),d&&D&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),H(a);const L=t.getOrCreateProgram("symbol",{defines:a}),P=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],z=s.iconSizeData,k=e.aZ(z,I.zoom),U=D||!I.isOrthographic,$=Ri(f,r.tileID.canonical,D,C,I,s.getProjection(),p),X=Ai(f,r.tileID.canonical,D,C,I,s.getProjection(),p),Y=s.icon.uboBinder&&s.icon.uboBinder.hasPerFeatureTranslate()?[0,0]:l,K=t.translatePosMatrix(X,r,Y,h,!0),Q=t.translatePosMatrix(f,r,Y,h),J=c?Dc:$,ee=C&&!D&&!i;let te=N;!B&&!I.mercatorFromTransition||C||(te=Ac(I));const ie=u?te:N,oe=o.getColorAdjustmentMatrix(v,y,x,b),re=vc(z.kind,k,ee,D,t,Q,J,K,w,!1,s.sdfIcons,P,[0,0],0,n,_,F,G,ie,s.getProjection(),E,V,oe,A,null),ne=r.imageAtlasTexture?r.imageAtlasTexture:null,se=1!==o.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,ae=s.sdfIcons||t.options.rotating||t.options.zooming||se||U?S.LINEAR:S.NEAREST,le=s.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),ce=t.terrain&&D&&i?e.aE(e.aS(),$):Dc;if(i&&s.icon){const i=e.e7.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,s.getProjection()),a=Di(f,r.tileID.canonical,D,C,I,s.getProjection(),p),l=o.layout.get("icon-size-scale-range"),c=e.as(t.scaleFactor,l[0],l[1]);Mi(s,f,t,!1,a,X,D,m,i,n,c);}return {program:L,buffers:s.icon,uniformValues:re,atlasTexture:ne,atlasTextureIcon:null,atlasInterpolation:ae,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:le,depthMode:R,tile:r,renderWithShadows:T,labelPlaneMatrixInv:ce}},X=()=>{const i=R&&"point"!==o.layout.get("symbol-placement"),a=[],l=i||z||j,h="road"===s.elevationType,m=t.shadowRenderer,v=h&&A&&!!m&&m.enabled,y=q(v),x=h&&A&&!t.terrain?M:O;t.terrainRenderModeElevated()&&A&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),v&&a.push("RENDER_SHADOWS","NORMAL_OFFSET"),h&&A&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Z(a),H(a);const b=t.getOrCreateProgram("symbol",{defines:a});let T,E=[0,0],C=null;const D=s.textSizeData;s.iconsInText&&(E=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],C=r.imageAtlasTexture?r.imageAtlasTexture:null,T=A||!I.isOrthographic||t.options.rotating||t.options.zooming||"composite"===D.kind||"camera"===D.kind?S.LINEAR:S.NEAREST);const L=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],P=o.layout.get("text-size-scale-range"),k=e.as(t.scaleFactor,P[0],P[1]),U=e.aZ(D,I.zoom,k),W=Ri(f,r.tileID.canonical,A,R,I,s.getProjection(),p),$=Ai(f,r.tileID.canonical,A,R,I,s.getProjection(),p),X=s.text.uboBinder&&s.text.uboBinder.hasPerFeatureTranslate()?[0,0]:c,Y=t.translatePosMatrix($,r,X,d,!0),K=t.translatePosMatrix(f,r,X,d),Q=l?Dc:W,J=R&&!A&&!i;let ee=N;!B&&!I.mercatorFromTransition||R||(ee=Ac(I));const te=vc(D.kind,U,J,A,t,K,Q,Y,w,!0,!0,L,E,0,n,_,F,G,u?ee:N,s.getProjection(),y,V,null,null,k),ie=r.glyphAtlasTexture?r.glyphAtlasTexture:null,oe=S.LINEAR,re=0!==o.paint.get("text-halo-width").constantOr(1),ne=t.terrain&&A&&i?e.aE(e.aS(),W):Dc;if(i&&s.text){const i=e.e7.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,s.getProjection()),o=Di(f,r.tileID.canonical,A,R,I,s.getProjection(),p);Mi(s,f,t,!0,o,$,A,g,i,n,k);}return {program:b,buffers:s.text,uniformValues:te,atlasTexture:ie,atlasTextureIcon:C,atlasInterpolation:oe,atlasInterpolationIcon:T,isSDF:!0,hasHalo:re,depthMode:x,tile:r,renderWithShadows:v,labelPlaneMatrixInv:ne}},Y=s.icon.segments.get().length,K=s.text.segments.get().length,Q=Y&&!a.onlyText?$():null,J=K&&!a.onlyIcons?X():null,ee=o.paint.get("icon-opacity").constantOr(1),te=o.paint.get("text-opacity").constantOr(1);if(L&&s.canOverlap){P=!0;const t=ee&&!a.onlyText?s.icon.segments.get():[],i=te&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)k.push({segments:new e.cr([i]),sortKey:i.sortKey,state:Q});for(const t of i)k.push({segments:new e.cr([t]),sortKey:t.sortKey,state:J});}else a.onlyText||k.push({segments:ee?s.icon.segments:new e.cr([]),sortKey:0,state:Q}),a.onlyIcons||k.push({segments:te?s.text.segments:new e.cr([]),sortKey:0,state:J});}P&&k.sort((e,t)=>e.sortKey-t.sortKey);for(const e of k){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:I.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(I.depthOcclusionForSymbolsAndCircles,i.program),E.activeTexture.set(S.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,S.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(S.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,Mc(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Mc(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,r,1)),r.u_is_halo=0;}Mc(i.buffers,e.segments,o,t,i.program,i.depthMode,n,s,i.uniformValues,1);}}}function Mc(e,t,i,o,r,n,s,a,l,c){const h=o.context,d=h.gl,u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];e.featureIdBuffer&&u.push(e.featureIdBuffer);const _=e.uboBinder?null:e.programConfigurations.get(i.id);if(e.uboBinder){e.uboBinder.layer=i;const t=o.transform.zoom,r=o.style.getBrightness?o.style.getBrightness():null,n=e.uboBinder.getConstantUniformValues(t,r);l.u_spp_fill_np_color=n.fill_np_color,l.u_spp_halo_np_color=n.halo_np_color,l.u_spp_opacity=n.opacity,l.u_spp_halo_width=n.halo_width,l.u_spp_halo_blur=n.halo_blur,l.u_spp_emissive_strength=n.emissive_strength,l.u_spp_occlusion_opacity=n.occlusion_opacity,l.u_spp_z_offset=n.z_offset;const s=n.zoomFactors;l.u_spp_fill_color_zoom_factor=s[0],l.u_spp_halo_color_zoom_factor=s[1],l.u_spp_opacity_zoom_factor=s[2],l.u_spp_halo_width_zoom_factor=s[3],l.u_spp_halo_blur_zoom_factor=s[4],l.u_spp_emissive_strength_zoom_factor=s[5],l.u_spp_occlusion_opacity_zoom_factor=s[6],l.u_spp_z_offset_zoom_factor=s[7],l.u_spp_translate_zoom_factor=s[8],l.u_spp_zoom_fraction=t-Math.floor(t);const a=i.paint.get(e.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),c=e.uboBinder.hasPerFeatureTranslate()&&"map"===a?o.transform.angle:0;l.u_spp_translate_rotation=[Math.cos(c),Math.sin(c)];}const{batchIndices:f,batchSegments:p}=e.getBatchGrouping(t);for(const t of f){const f=p.get(t);e.uboBinder&&e.uboBinder.bind(h,r.program,t),r.draw(o,d.TRIANGLES,n,s,a,yi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,f,i.paint,o.transform.zoom,_,u,c);}}function Fc(t,i,o,r,n,s){const a=o.paint.get("line-width"),l=o.paint.get("line-emissive-strength").isConstant(),c=o.paint.get("line-emissive-strength").constantOr(0),h=o.paint.get("line-occlusion-opacity"),d=o.layout.get("line-elevation-reference"),u="meters"===o.layout.get("line-width-unit"),_="sea"===d,f=!(!t.terrain||!t.terrain.enabled),p=t.context,m=p.gl;if(o.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const g=o.layout.get("line-cross-slope"),v=void 0!==g,y=g<1,x=n||t.colorModeForDrapableLayerRenderPass(l?c:null),b=t.terrain&&t.terrain.renderingToTexture||s,w=b?1:e.r.devicePixelRatio,T=o.paint.get("line-dasharray"),E=T.constantOr(1),S=o.layout.get("line-cap"),I=T.constantOr(null),C=S.constantOr(null),R=o.paint.get("line-pattern"),D=R.constantOr(1),A=o.paint.get("line-pattern-cross-fade"),L=R.constantOr(null),P=o.paint.get("line-opacity").constantOr(1);let O=!D&&1!==P||t.depthOcclusion&&h>0&&h<1;const M=o.paint.get("line-gradient"),F=D?"linePattern":"line",z=e.eM(o);let B;if(b&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(O=!1),0!==h&&t.depthOcclusion){const t=o.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?B=t.value:e.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}"constant"!==a.value.kind&&!1===a.value.isLineProgressConstant&&z.push("VARIABLE_LINE_WIDTH");const k=o.paint.get("line-emissive-strength");D||"constant"===k.value.kind||!1!==k.value.isLineProgressConstant||z.push("VARIABLE_LINE_EMISSIVE_STRENGTH"),t._debugParams.showElevationIdDebug&&z.push("DEBUG_ELEVATION_ID"),b&&("dual-source-blending"!==t.emissiveMode||l?"mrt-fallback"===t.emissiveMode&&z.push("USE_MRT1"):z.push("DUAL_SOURCE_BLENDING"));const N={},U=[],j=(r,n,s,a,l,c)=>{for(const d of r){const r=i.getTile(d);if(D&&!r.patternsLoaded())continue;const _=r.getBucket(o);if(!_)continue;if("none"!==_.elevationType&&!l||"none"===_.elevationType&&l)continue;t.prepareDrawTile();const f=[...n],g="road"===_.elevationType,v=t.shadowRenderer,y=g&&!!v&&v.enabled;let T=[0,0,0];if(y){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(T=lo(t.style,e,i)),f.push("RENDER_SHADOWS","NORMAL_OFFSET");}const S=_.programConfigurations.get(o.id);let R=!1;if(L&&r.imageAtlas){const t=e.cD.from(L),i=t.getPrimary().scaleSelf(w).toString(),o=r.imageAtlas.patternPositions.get(i),n=t.getSecondary(),s=n?r.imageAtlas.patternPositions.get(n.scaleSelf(w).toString()):null;R=!!o&&!!s,o&&S.setConstantPatternPositions(o,s);}A>0&&(R||S.getPatternTransitionVertexBuffer("line-pattern"))&&f.push("LINE_PATTERN_TRANSITION"),_.elevationGroundScaleVertexBuffer&&f.push("ELEVATION_GROUND_SCALE");const z=t.isTileAffectedByFog(d),k=t.getOrCreateProgram(F,{config:S,defines:f,overrideFog:z});if(!D&&I&&C&&r.lineAtlas){const e=r.lineAtlas.getDash(I,C);e&&S.setConstantPatternPositions(e);}y&&v.setupShadows(r.tileID.toUnwrapped(),k,"vector-tile");let[j,G]=o.paint.get("line-trim-offset");if("round"===C||"square"===C){const e=1;j!==G&&(0===j&&(j-=e),1===G&&(G+=e));}const V=b?d.projMatrix:null,q=u?1/_.tileToMeter/e.c1(r,1,t.transform.zoom):1,H=u?1/_.tileToMeter/e.c1(r,1,Math.floor(t.transform.zoom)):1,Z=E?o.paint._values["line-floorwidth"]:null;let W;if(Z&&"constant"===Z.value.kind){const e=_.zoom;e in N||(N[e]=Math.max(.01,o.widthExpression().evaluate({zoom:e}))),W=Z.value.value;const i=Math.floor(t.transform.zoom);Z.value.value=N[e]*Math.pow(2,i-r.tileID.overscaledZ);}const $=D?e.eN(t,r,o,V,w,q,H,[j,G],T,A):e.eO(t,r,o,V,_.lineClipsArray.length,w,q,H,[j,G],T);if(M){const r=_.gradients[o.id];let n=r.texture;if(o.gradientVersion!==r.version){let s=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,r=d.canonical.z===o?Math.ceil(1<{i&&0!==i.get().length&&(null!=B&&(B.value=P*h),void 0!==r&&($.u_opacity_multiplier=r),k.draw(t,m.TRIANGLES,s,e,x,yi.disabled,$,o.id,_.layoutVertexBuffer,_.indexBuffer,i,o.paint,t.transform.zoom,S,[_.layoutVertexBuffer2,_.patternVertexBuffer,_.zOffsetVertexBuffer,_.elevationIdColVertexBuffer,_.elevationGroundScaleVertexBuffer]),void 0!==r&&($.u_opacity_multiplier=1),null!=B&&(B.value=P));},K=e=>{X&&X.active&&Es.drawLineFrcRenderLine?Es.drawLineFrcRenderLine(_,X,e,Y):Y(e,_.segments);};if(O&&!l){const e=t.stencilModeForClipping(d).ref;0===e&&b&&p.clear({stencil:0});const i={func:m.EQUAL,mask:255};$.u_alpha_discard_threshold=.8,K(new $i(i,e,255,m.KEEP,m.KEEP,m.INVERT)),$.u_alpha_discard_threshold=0,K(new $i(i,e,255,m.KEEP,m.KEEP,m.KEEP));}else $.u_alpha_discard_threshold=O&&l&&c?.8:0,K(l?a:t.stencilModeForClipping(d));X&&Es.drawLineFrcFadePass&&Es.drawLineFrcFadePass(t,_,d,X,l,a,Y),void 0!==W&&(Z.value.value=W);}};let G=t.depthModeForSublayer(0,xi.ReadOnly);const V=new xi(t.depthOcclusion?m.GREATER:m.LEQUAL,xi.ReadOnly,t.depthRangeFor3D);if(o.hasNonElevatedBuckets){const i=!b&&t.terrain;0!==h&&i?e.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):j(r,z,G,$i.disabled,!1,!0);}if(o.hasElevatedBuckets){"hd-road-markup"===d?f||(G=V,z.push("ELEVATED_ROADS")):(z.push("ELEVATED"),G=V,v&&z.push(y?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),_&&z.push("ELEVATION_REFERENCE_SEA"));const e=O?t.stencilModeFor3D():$i.disabled;"hd-road-markup"!==d&&(t.forceTerrainMode=!0),j(r,z,G,e,!0,!0),O&&j(r,z,G,e,!0,!1),"hd-road-markup"!==d&&(t.forceTerrainMode=!1);}Es.drawLineFrcCoverageSecondPass&&Es.drawLineFrcCoverageSecondPass(t,o,U),O&&(t.resetStencilClippingMasks(),b&&p.clear({stencil:0})),0===h||t.depthOcclusion||b||t.layersWithOcclusionOpacity.push(t.currentLayer);}class zc{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null);}}class Bc{constructor(e){this.pbo=e.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0;}destroy(e){this.sync&&(e.deleteSync(this.sync),this.sync=null),e.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null);}}const kc={additive:{clearColor:new e.C(0,0,0,0),colorMode:Ji.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new e.C(1,1,1,1),colorMode:Ji.multiply,compositeUniformValue:0}};function Nc(e){return !(!e.extRenderToTextureHalfFloat&&!e.extColorBufferFloat)}function Uc(e,t){return "additive"===e&&Nc(t)?Ji.additiveAlphaWeightedUnboundedAlpha:kc[e].colorMode}function jc(e,t,i){const o=e.context,r=o.gl;let n=i.width,s=i.height,a=i.colorAttachment0.get();t.lineBlendDensityReadback||(t.lineBlendDensityReadback=new Bc(r));const l=t.lineBlendDensityReadback;let c=0,h=!0;for(;n>1||s>1;){const i=Math.max(1,Math.floor(n/2)),d=Math.max(1,Math.floor(s/2)),u=0===c?"fboA":"fboB";l[u]=Sc.createWithTexture(o,l[u],i,d,!1);const _=l[u];o.bindFramebuffer.set(_.framebuffer),o.viewport.set([0,0,i,d]),o.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a),e.getOrCreateProgram("lineBlendReduce").draw(e,r.TRIANGLES,xi.disabled,$i.disabled,Ji.unblended,yi.disabled,cc(0,[1/n,1/s],h),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom),n=i,s=d,a=_.colorAttachment0.get(),c=1-c,h=!1;}const d=Nc(o),u=d?16:4;l.sync&&(r.deleteSync(l.sync),l.sync=null),r.bindBuffer(r.PIXEL_PACK_BUFFER,l.pbo),r.bufferData(r.PIXEL_PACK_BUFFER,u,r.STREAM_READ),r.readPixels(0,0,1,1,r.RGBA,d?r.FLOAT:r.UNSIGNED_BYTE,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),l.sync=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0),o.viewport.set([0,0,e.width,e.height]);}function Gc(e,t,i){if(!Nc(e.context))return;const o=t.lineBlendDensityReadback;o&&o.sync?(function(e,t,i){if(e.sync&&t.getSyncParameter(e.sync,t.SYNC_STATUS)===t.SIGNALED){if(t.deleteSync(e.sync),e.sync=null,t.bindBuffer(t.PIXEL_PACK_BUFFER,e.pbo),Nc(i)){const i=new Float32Array(4);t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,i);const o=i[1];e.maxDensity=Math.max(2*(o>0?i[0]/o:0),1);}else e.maxDensity=1;t.bindBuffer(t.PIXEL_PACK_BUFFER,null);}}(o,e.context.gl,e.context),o.sync||(jc(e,t,i),e.style.map.triggerRepaint())):(jc(e,t,i),e.style.map.triggerRepaint());}function Vc(e,t,i,o,r,n){const s=e.context,a=s.gl,l="additive"===i?1:t.paint.get("line-opacity").constantOr(1),c="additive"===i?function(e,t){const i=t.paint.get("line-blend-additive-clamp");if(i>0)return i;const o=t.lineBlendDensityReadback;return o&&0!==o.maxDensity?o.maxDensity:null}(0,t):1;if(null===c)return;s.bindFramebuffer.set(r),n&&s.viewport.set([0,0,n[0],n[1]]),s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,o.colorAttachment0.get());const h=Uc(i,e.context);e.getOrCreateProgram("lineBlendComposite").draw(e,a.TRIANGLES,xi.disabled,$i.disabled,h,yi.disabled,((e,t,i,o)=>({u_image:0,u_opacity:t,u_blend_mode:i,u_max_density:o}))(0,l,kc[i].compositeUniformValue,c),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom);}function qc(t,i,o,r){const{painter:n,sourceCache:s,layer:a,coords:l,colorMode:c,elevationType:h,terrainEnabled:d,pass:u}=t,_=n.context.gl,f=a.paint.get("fill-pattern"),p=a.paint.get("fill-pattern-cross-fade"),m=f.constantOr(null);let g=h;"road"!==h||i&&!d||(g="none");const v="road"===g,y=t.painter.shadowRenderer,x=v&&!!y&&y.enabled,b=new xi(n.context.gl.LEQUAL,xi.ReadOnly,n.depthRangeFor3D);let w=[0,0,0];if(x){const e=n.style.directionalLight,t=n.style.ambientLight;e&&t&&(w=lo(n.style,e,t));}const T=f&&f.constantOr(1),E=n.terrain&&n.terrain.renderingToTexture,S=(t,u)=>{let f,g,S,I,C;u?(f=T&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",S=_.LINES):(f=T?"fillPattern":"fill",S=_.TRIANGLES);const R=[];for(const D of l){const l=s.getTile(D);if(T&&!l.patternsLoaded())continue;const A=l.getBucket(a);if(!A)continue;const L=i?A.hdExt&&A.hdExt.elevationBufferData:A.bufferData;if(!L||L.isEmpty())continue;n.prepareDrawTile();const P=L.programConfigurations.get(a.id),O=n.isTileAffectedByFog(D),M=[],F=[];v&&(M.push("ELEVATED_ROADS"),F.push(L.elevatedLayoutVertexBuffer)),x&&M.push("RENDER_SHADOWS","NORMAL_OFFSET"),E&&o&&M.push("USE_MRT1"),T&&(n.context.activeTexture.set(_.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),P.updatePaintBuffers());let z=!1;if(m&&l.imageAtlas){const t=l.imageAtlas,i=e.cD.from(m),o=i.getPrimary().scaleSelf(e.r.devicePixelRatio).toString(),r=i.getSecondary(),n=t.patternPositions.get(o),s=r?t.patternPositions.get(r.scaleSelf(e.r.devicePixelRatio).toString()):null;z=!!n&&!!s,n&&P.setConstantPatternPositions(n,s);}p>0&&(z||P.getPatternTransitionVertexBuffer("fill-pattern"))&&M.push("FILL_PATTERN_TRANSITION");const B=n.getOrCreateProgram(f,{config:P,overrideFog:O,defines:M}),k=n.translatePosMatrix(D.projMatrix,l,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));x&&y.setupShadows(l.tileID.toUnwrapped(),B,"vector-tile");const N=a.paint.get("fill-emissive-strength");if(u){I=L.lineIndexBuffer,C=L.lineSegments;const e=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[_.drawingBufferWidth,_.drawingBufferHeight];g="fillOutlinePattern"===f&&T?lc(k,N,n,l,e,w,p):ac(k,N,e,w);}else I=L.indexBuffer,C=L.triangleSegments,g=T?sc(k,N,n,l,w,p):nc(k,N,w);n.uploadCommonUniforms(n.context,B,D.toUnwrapped());let U=t;if(("road"===h&&!d||"offset"===h)&&(U=b),!C||C.get&&0===C.get().length)continue;const j=r||n.stencilModeForClipping(D);let G="fallthrough";!u&&Es.drawFillFrcCoverageFirstPass&&(G=Es.drawFillFrcCoverageFirstPass({painter:n,layer:a,bucket:A,coord:D,elevatedGeometry:i,program:B,programConfiguration:P,uniformValues:g,drawMode:S,depthMode:U,stencilMode:j,colorMode:c,bufferData:L,indexBuffer:I,segments:C,dynamicBuffers:F,polygonCoverageTiles:R})),"fallthrough"===G&&B.draw(n,S,U,j,c,yi.disabled,g,a.id,L.layoutVertexBuffer,I,C,a.paint,n.transform.zoom,P,F);}!u&&Es.drawFillFrcCoverageSecondPass&&Es.drawFillFrcCoverageSecondPass(n,a,R,S,c);};n.renderPass===u&&S(n.depthModeForSublayer(1,"opaque"===n.renderPass?xi.ReadWrite:xi.ReadOnly),!1),"none"===g&&"translucent"===n.renderPass&&a.paint.get("fill-antialias")&&S(n.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,xi.ReadOnly),!0);}function Hc(t){return [t[0]*e.eR,t[1]*e.eR,t[2]*e.eR,0]}function Zc(t,i,o,r,n,s,a,l,c){const h=r.getSource(),d=o.globeSharedBuffers;if(!d)return;let u,_,f;if(i&&(u=r.getTile(i)),h instanceof Ms?(_=h.texture,f=e.ew(0,0,o.transform)):u&&i&&(_=u.texture,f=e.ew(i.canonical.z,i.canonical.x,o.transform)),!_||!f)return;t||(f=e.bL(e.aS(),f,[1,-1,1]));const p=o.context,m=p.gl,g="nearest"===n.paint.get("raster-resampling")?m.NEAREST:m.LINEAR,v=o.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const x=new xi(m.LEQUAL,xi.ReadWrite,o.depthRangeFor3D),b=o.transform.expandedFarZProjMatrix,w=Float32Array.from(e.d3(e.dn(new e.bu(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),p.activeTexture.set(m.TEXTURE0),_.bind(g,m.CLAMP_TO_EDGE),p.activeTexture.set(m.TEXTURE1),_.bind(g,m.CLAMP_TO_EDGE),"useMipmap"in _&&p.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);const[T,E,S,I]=i?d.getPoleBuffers(i.canonical.z,!1):d.getPoleBuffers(0,!0),C=n.paint.get("raster-elevation");let R;t?(R=T,o.renderDefaultNorthPole=0!==C):(R=E,o.renderDefaultSouthPole=0!==C);const D=Hc(a.mix),A=((e,t,i,o,r,n,s,a,l,c,h,d,u,_)=>pc(e,t,i,o,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},s,[0,0]||[0,0],l,2,h,d,u,1,0,_))(o,b,w,f,e.ah(o.transform.zoom),0,n,0,C,0,D,a.offset,a.range,s),L=o.getOrCreateProgram("raster",{defines:y});o.uploadCommonUniforms(p,L,null),L.draw(o,m.TRIANGLES,x,c,v,l,A,n.id,R,S,I);}function Wc(e){if(e.isOrthographic)return [0,0,0,0];const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,n=t+r;return [t,i,(n-r-t)/o,(n-t)/o]}function $c(e,t,i,o){if(e)return t instanceof gn&&e instanceof un?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:Hc(o.mix),offset:o.offset,buffer:0,tileSize:1}}const Xc=e.aC(new Float32Array(16)),Yc=new e.C(1,0,0,1),Kc=new e.C(0,1,0,1),Qc=new e.C(0,0,1,1),Jc=new e.C(1,0,1,1),eh=new e.C(0,1,1,1);function th(t,i,o,r,n,s,a){const l=t.context,c=t.transform,h=l.gl,d="globe"===c.projection.name,u=d?["PROJECTION_GLOBE_VIEW"]:[];let _=e.aQ(o.projMatrix);if(d&&e.ah(c.zoom)>0){const t=e.d2(o.canonical,c),i=e.eS(t);_=e.aP(new Float32Array(16),c.globeMatrix,i),e.aP(_,c.projMatrix,_);}const f=e.aS();f[12]+=2*n/(e.r.devicePixelRatio*c.width),f[13]+=2*s/(e.r.devicePixelRatio*c.height),e.aP(_,f,_);const p=t.getOrCreateProgram("debug",{defines:u}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,p);const g=xi.disabled,v=$i.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),d?m._makeGlobeTileDebugBuffers(t.context,c):m._makeDebugTileBoundsBuffers(t.context,c.projection);const b=m._tileDebugBuffer||t.debugBuffer,w=m._tileDebugIndexBuffer||t.debugIndexBuffer,T=m._tileDebugSegments||t.debugSegments;if(p.draw(t,h.LINE_STRIP,g,v,y,yi.disabled,fo(_,r.toPremultipliedRenderColor(null)),x,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),a){const e=m.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(r+=` => ${o.overscaledZ}`),r+=` ${m.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}(t,r);}const E=i.getTile(o).tileSize,S=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,I=m._tileDebugTextBuffer||t.debugBuffer,C=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,R=m._tileDebugTextSegments||t.debugSegments;p.draw(t,h.TRIANGLES,g,v,Ji.alphaBlended,yi.disabled,fo(_,e.C.transparent.toPremultipliedRenderColor(null),S),x,I,C,R,null,null,null,[m._globeTileDebugTextBuffer]);}function ih(e,t,i,o){rh(e,0,t+i/2,e.transform.width,i,o);}function oh(e,t,i,o){rh(e,t-i/2,0,i,e.transform.height,o);}function rh(t,i,o,r,n,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.r.devicePixelRatio,o*e.r.devicePixelRatio,r*e.r.devicePixelRatio,n*e.r.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST);}const nh=e.cR([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:sh}=nh;function ah(e,t,i,o){e.emplaceBack(t,i,o);}class lh{constructor(t){this.vertexArray=new e.eT,this.indices=new e.cp,ah(this.vertexArray,-1,-1,1),ah(this.vertexArray,1,-1,1),ah(this.vertexArray,-1,1,1),ah(this.vertexArray,1,1,1),ah(this.vertexArray,-1,-1,-1),ah(this.vertexArray,1,-1,-1),ah(this.vertexArray,-1,1,-1),ah(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=t.createVertexBuffer(this.vertexArray,sh),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.cr.simpleSegment(0,0,36,12);}}function ch(t,i,o,r,n,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),d=((e,t,i,o,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.eW(e.c2(),r),n,h,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),o.draw(t,a.TRIANGLES,xi.disabled,$i.disabled,Ji.unblended,yi.frontCW,d,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const hh=e.cR([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class dh{constructor(t){const i=new e.eX;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 o=new e.cp;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,hh.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.cr.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const uh=e.cR([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class _h{constructor(){this.colorModeAlphaBlendedWriteRGB=new Ji([1,Qi,1,Qi],e.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Ji([1,0,1,0],e.C.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null;}update(t){this._painter=t;const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new dh(i);let t=this.params;const o=t.sizeRange,r=t.intensityRange,n=function(t){const i=e.dt(30),o=[];for(let r=0;r{const i="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,o,r,n,s,a,l,c,h,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:r,u_transition:n,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:h,u_horizon_angle:d}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,a,m,h,u,f,v,b);t.uploadCommonUniforms(o,l);const d=this.atmosphereBuffer;d&&l.draw(t,r.TRIANGLES,s,$i.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,yi.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",d.vertexBuffer,d.indexBuffer,d.segments);};w(!1),w(!0);}drawStars(t,i){const o=e.as(i.properties.get("star-intensity"),0,1);if(0===o)return;const r=t.context,n=r.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.az([]);e.aB(l,l,-s._pitch),e.aA(l,l,-s.angle),e.aB(l,l,e.al(s._center.lat)),e.e_(l,l,-e.al(s._center.lng));const c=e.aI(new Float32Array(16),l),h=e.aP([],s.starsProjMatrix,c),d=e.eW([],c),u=e.e$([],d);let _=this.params.sizeMultiplier;const f=[0,1,0];e.c4(f,f,u),e.av(f,f,_);const p=[1,0,0];e.c4(p,p,u),e.av(p,p,_);const m=(g=f,v=p,y=o,{u_matrix:Float32Array.from(h),u_up:g,u_right:v,u_intensity_multiplier:y});var g,v,y;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,n.TRIANGLES,xi.disabled,$i.disabled,this.colorModeAlphaBlendedWriteRGB,yi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}class fh{}class ph{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,o){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=o.gl,n=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),s=new ArrayBuffer(n),a=new Int16Array(s);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.f0;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class mh{constructor(){this.occluderSize=30,this.depthOffset=-1e-4;}}const gh={symbol:function(t,i,o,r,n){if("translucent"!==t.renderPass)return;const s=$i.disabled,a=t.colorModeForRenderPass(),l=o.layout.get("text-variable-anchor"),c=o.layout.get("text-size-scale-range"),h=e.as(t.scaleFactor,c[0],c[1]);l&&function(t,i,o,r,n,s,a,l){const c=i.transform,h="map"===n,d="map"===s;for(const i of t){const t=r.getTile(i),n=t.getBucket(o);if(!n||!n.text||!n.text.segments.get().length)continue;const s=e.aZ(n.textSizeData,c.zoom,l),u=na(i,n.getProjection(),c),_=c.calculatePixelsToTileUnitsMatrix(t),f=Ri(u,t.tileID.canonical,d,h,c,n.getProjection(),_),p=n.hasIconTextFit()&&n.hasIconData();s&&Pc(n,h,d,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,p);}}(r,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),n,h);const d=0!==o.paint.get("icon-opacity").constantOr(1),u=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(d||u)?Oc(t,i,o,r,s,a):(d&&Oc(t,i,o,r,s,a,{onlyIcons:!0}),u&&Oc(t,i,o,r,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Rc(t,i,o,r,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Rc(t,i,o,r,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,o,r){if("translucent"!==t.renderPass)return;const n=o.paint.get("circle-opacity"),s=o.paint.get("circle-stroke-width"),a=o.paint.get("circle-stroke-opacity"),l=void 0!==o.layout.get("circle-sort-key").constantOr(1),c=o.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,d=h.gl,u=t.transform,_=!(!t.terrain||!t.terrain.enabled),f=o.layout.get("circle-elevation-reference"),p=t.depthModeForSublayer(0,xi.ReadOnly),m=new xi(t.context.gl.LEQUAL,xi.ReadOnly,t.depthRangeFor3D),g="none"===f||_?p:m,v=$i.disabled,y=t.colorModeForDrapableLayerRenderPass(c),x="globe"===u.projection.name,b=[e.a_(u.center.lng),e.a$(u.center.lat)],w=[];for(let n=0;ne.sortKey-t.sortKey);const T={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const e of w){const{programConfiguration:i,program:r,layoutVertexBuffer:n,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,_=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,T),t.uploadCommonUniforms(h,r,c.tileID.toUnwrapped()),r.draw(t,d.TRIANGLES,g,v,y,yi.disabled,l,o.id,n,a,_,o.paint,u.zoom,i,s);}},heatmap:function(t,i,o,r){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const n=t.context,s=n.gl,a=$i.disabled,l=new Ji([s.ONE,s.ONE,s.ONE,s.ONE],e.C.transparent,[!0,!0,!0,!0]),c="globe"===t.transform.projection.name?.5:.25;o.heatmapFbo=Sc.createWithTexture(n,o.heatmapFbo,t.width*c,t.height*c),n.clear({color:e.C.transparent});const h=t.transform,d="globe"===h.projection.name,u=d?["PROJECTION_GLOBE_VIEW"]:[],_=d?yi.frontCCW:yi.disabled,f=[e.a_(h.center.lng),e.a$(h.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}(t,o));},line:function(e,t,i,o){const r=i.paint.get("line-opacity"),n=i.paint.get("line-width");if(0===r.constantOr(1)||0===n.constantOr(1))return;const s=i.paint.get("line-blend-mode"),a=e.terrain&&e.terrain.renderingToTexture;if("default"===s||"globe"===e.transform.projection.name)"translucent"===e.renderPass&&Fc(e,t,i,o);else {if(a)return void function(e,t,i,o,r){if("translucent"!==e.renderPass)return;const n=e.context,s=n.gl,a=e.terrain;if(!a)return;const l=n.bindFramebuffer.current,c="mrt-fallback"===e.emissiveMode,h=a.drapeBufferSize[0],d=a.drapeBufferSize[1];i.lineBlendFbos||(i.lineBlendFbos=new zc),i.lineBlendFbos.drapeFbo=Sc.createWithTexture(n,i.lineBlendFbos.drapeFbo,h,d,!0),c&&s.drawBuffers([s.COLOR_ATTACHMENT0]),n.clear({color:kc[r].clearColor,depth:1,stencil:0});const u=e.currentStencilSource,_=e._tileClippingMaskIDs,f=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1;const p=e._terrain;e._terrain=null,e._renderTileClippingMasks(i,t,o),Fc(e,t,i,o,Uc(r,e.context),!0),e._terrain=p,e.currentStencilSource=u,e._tileClippingMaskIDs=_,e.nextStencilID=f,c&&s.drawBuffers([s.COLOR_ATTACHMENT0,s.COLOR_ATTACHMENT1]);const m=a.drapeBufferSize,g=i.lineBlendFbos&&i.lineBlendFbos.drapeFbo;g&&("additive"===r&&Gc(e,i,g),Vc(e,i,r,g,l,m));}(e,t,i,o,s);if("offscreen"===e.renderPass)return void function(e,t,i,o,r){const n=e.context,s=Math.ceil(e.width),a=Math.ceil(e.height);i.lineBlendFbos||(i.lineBlendFbos=new zc),i.lineBlendFbos.fbo=Sc.createWithTexture(n,i.lineBlendFbos.fbo,s,a,!0),n.clear({color:kc[r].clearColor,depth:1,stencil:0});const l=e.currentStencilSource,c=e._tileClippingMaskIDs,h=e.nextStencilID;e.currentStencilSource=void 0,e._tileClippingMaskIDs={},e.nextStencilID=1,e._renderTileClippingMasks(i,t,o);const d=e.renderPass;e.renderPass="translucent",Fc(e,t,i,o,Uc(r,e.context)),e.renderPass=d,e.currentStencilSource=l,e._tileClippingMaskIDs=c,e.nextStencilID=h,n.viewport.set([0,0,e.width,e.height]),"additive"===r&&Gc(e,i,i.lineBlendFbos.fbo);}(e,t,i,o,s);if("translucent"===e.renderPass){const t=i.lineBlendFbos&&i.lineBlendFbos.fbo;return void(t&&Vc(e,i,s,t,null))}}},fill:function(t,i,o,r){const n=o.paint.get("fill-color"),s=o.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=o.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=o.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===n.constantOr(e.C.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let d="none";"none"!==o.layout.get("fill-elevation-reference")?d="road":0!==o.paint.get("fill-z-offset").constantOr(1)&&(d="offset");const u=!(!t.terrain||!t.terrain.enabled),_={painter:t,sourceCache:i,layer:o,coords:r,colorMode:l,elevationType:d,terrainEnabled:u,pass:h};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===d&&!u&&Es.drawElevatedFillShadows&&Es.drawElevatedFillShadows(_));const f="mrt-fallback"===t.emissiveMode;if("offset"!==d){if(qc(_,!1,f),"road"===d){const e=!u&&"translucent"===t.renderPass;e&&Es.drawDepthPrepass&&Es.drawDepthPrepass(t,i,o,r,"geometry"),qc(_,!0,f,$i.disabled),e&&Es.drawElevatedStructures&&Es.drawElevatedStructures(_);}}else qc(_,!1,f,t.stencilModeFor3D());},"fill-extrusion":function(t,i,o,r){const n=o.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===n)return;const h="mrt-fallback"===t.emissiveMode,d=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),u=t.style.order.indexOf(o.fqid);if(d&&function(e,t,i,o,r){for(const n of o){const o=t.getTile(n).getBucket(i);o&&(o.updateReplacement(n,e.replacementSource,r),o.uploadCentroid(e.context));}}(t,i,o,r,u),l||d)for(const e of r){const r=i.getTile(e).getBucket(o);r&&Br(t.context,i,e,r,o,l,d);}if("shadow"===t.renderPass&&t.shadowRenderer){if(l&&n<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ab)return;const s=t.shadowRenderer.getShadowPassDepthMode();Mr(t,i,o,r,s,$i.disabled,Ji.disabled,d);}else if("translucent"===t.renderPass){const u=!o.paint.get("fill-extrusion-pattern").constantOr(1),_=o.paint.get("fill-extrusion-color").constantOr(e.C.white);if(!c&&0!==_.a){const e=new xi(t.context.gl.LEQUAL,xi.ReadWrite,t.depthRangeFor3D);1===n&&u?Mr(t,i,o,r,e,$i.disabled,Ji.unblended,d):(Mr(t,i,o,r,e,$i.disabled,Ji.disabled,d),Mr(t,i,o,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),d),t.resetStencilClippingMasks());}const f=t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c);if(f&&!Pr.drawGroundEffect&&Or(),f&&Pr.drawGroundEffect){const n=o.paint.get("fill-extrusion-opacity"),u=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),_=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=o.paint.get("fill-extrusion-flood-light-intensity"),p="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(p?null:o.lut).toArray01().slice(0,3),g=u>0&&_>0,v=f>0,y=new Fr;y.translate=o.paint.get("fill-extrusion-translate"),y.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),y.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),y.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");const x=s=>{const l=t.depthModeForSublayer(1,xi.ReadOnly,a.LEQUAL,!0),c=o.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),h=e.ai(.1,3,c),p=t._showOverdrawInspector;if(!p){const c=new $i({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),p=new Ji([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);Pr.drawGroundEffect(y,t,i,o,r,l,c,p,yi.disabled,s,"sdf",n,u,_,f,m,h,d,!1);}{const c=p?$i.disabled:new $i({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=p?t.colorModeForRenderPass():new Ji([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.C.transparent,[!0,!0,!0,!0]);Pr.drawGroundEffect(y,t,i,o,r,l,c,g,yi.disabled,s,"color",n,u,_,f,m,h,d,!1);}};if(c){const c=()=>{const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];let o=l.framebufferCopyTexture;return o&&(!o||o.size[0]===t&&o.size[1]===i)||(o&&o.destroy(),o=l.framebufferCopyTexture=new e.T(s,new e.t({width:t,height:i}),a.RGBA8)),o.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,i),o},p=(s,l,p)=>{const g=t.depthModeForSublayer(1,xi.ReadOnly,a.LEQUAL,!1),v=o.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),x=e.ai(.1,3,v);{const c=new Ji([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0]);Pr.drawGroundEffect(y,t,i,o,r,g,$i.disabled,c,yi.disabled,s,"clear",n,u,_,f,m,x,d,l);}{const c=new $i({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),h=new Ji([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);Pr.drawGroundEffect(y,t,i,o,r,g,c,h,yi.disabled,s,"sdf",n,u,_,f,m,x,d,l);}h&&!s&&(p=c());{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,h=new $i({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),p=new Ji([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.C.transparent,[!0,!0,!0,!0]);Pr.drawGroundEffect(y,t,i,o,r,g,h,p,yi.disabled,s,"color",n,u,_,f,m,x,d,l);}if(!h||s){const c=new Ji([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.C.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);Pr.drawGroundEffect(y,t,i,o,r,g,$i.disabled,c,yi.disabled,s,"clear",n,u,_,f,m,x,d,l,p);}else {a.drawBuffers([a.NONE,a.COLOR_ATTACHMENT1]);const c=new $i({func:a.EQUAL,mask:255},254,255,a.KEEP,a.DECR,a.DECR),h=new Ji([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!0,!1,!1,!1],a.MAX);Pr.drawGroundEffect(y,t,i,o,r,g,c,h,yi.disabled,s,"emissive",n,u,_,f,m,x,d,l,p),a.drawBuffers([a.COLOR_ATTACHMENT0]);}};if(g||v){let e;t.prepareDrawTile(),h&&!g||(e=c()),g&&p(!0,!1,e),v&&p(!1,!0,e);}}else g&&x(!0),v&&x(!1),(g||v)&&t.resetStencilClippingMasks();}}},hillshade:function(e,t,i,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,n=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||n?[{},o]:e.stencilConfigForOverlap(o);for(const o of a){const r=t.getTile(o);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)sl(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,xi.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=n&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):s[o.overscaledZ];rl(e,o,r,i,t,c,l);}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(t,i,o,r,n,s){if("translucent"!==t.renderPass)return;const a=o.paint.get("raster-opacity");if(0===a)return;const l="globe"===t.transform.projection.name,c=0!==o.paint.get("raster-elevation"),h=c&&l,d=t.terrain&&t.terrain.exaggeration()>0&&c&&"ground"===o.paint.get("raster-elevation-reference"),u=!l&&d;if(t.renderElevatedRasterBackface&&!h)return;const _=t.context,f=_.gl,p=i.getSource(),m=function(t,i,o,r,n){const s=i.paint.get("raster-color"),a="raster-array"===t.type,l=[],c=i.paint.get("raster-resampling"),h=i.paint.get("raster-color-mix");let d=i.paint.get("raster-color-range");const u=[h[0],h[1],h[2],0],_=h[3];let f="nearest"===c?r.NEAREST:r.LINEAR;if(a&&(l.push("RASTER_ARRAY"),s||l.push("RASTER_COLOR"),"linear"===c&&l.push("RASTER_ARRAY_LINEAR"),f=r.NEAREST,!d&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(d=e.fields.range);}if(d=d||[0,1],s){l.push("RASTER_COLOR"),o.activeTexture.set(r.TEXTURE2),i.updateColorRamp(d);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,r.RGBA8)),t.bind(f,r.CLAMP_TO_EDGE);}return n&&l.push("USE_MRT1"),{mix:u,range:d,offset:_,defines:l,resampling:f}}(p,o,_,f,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(p instanceof Ms&&!r.length&&!l)return;const g=o.paint.get("raster-emissive-strength"),v=t.colorModeForDrapableLayerRenderPass(g),y=t.terrain&&t.terrain.renderingToTexture,x=!t.options.moving,b="nearest"===o.paint.get("raster-resampling")?f.NEAREST:f.LINEAR;if(p instanceof Ms&&!r.length&&(p.onNorthPole||p.onSouthPole)){const e=c?t.stencilModeFor3D():$i.disabled;return void Zc(!!p.onNorthPole,null,t,i,o,g,m,yi.disabled,e)}if(!r.length)return;const[w,T]=p instanceof Ms||y?[{},r]:t.stencilConfigForOverlap(r),E=T.at(-1).overscaledZ;h&&m.defines.push("PROJECTION_GLOBE_VIEW"),c&&m.defines.push("RENDER_CUTOFF","ELEVATED"),d&&m.defines.push("ELEVATION_REFERENCE_GROUND");const S=(r,n,T)=>{for(const S of r){const r=S.toUnwrapped(),I=i.getTile(S);if(y&&(!I||!I.hasData()))continue;_.activeTexture.set(f.TEXTURE0);const C=$c(I,p,o,m);if(!C||!C.texture)continue;const{texture:R,mix:D,offset:A,tileSize:L,buffer:P}=C;let O,M;y?(O=xi.disabled,M=S.projMatrix):c?(O=new xi(f.LEQUAL,xi.ReadWrite,t.depthRangeFor3D),M=l?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(r,x)):(O=t.depthModeForSublayer(S.overscaledZ-E,1===a?xi.ReadWrite:xi.ReadOnly,f.LESS),M=t.transform.calculateProjMatrix(r,x));const F=t.terrain&&y?t.terrain.stencilModeForRTTOverlap(S):w[S.overscaledZ],z=s?0:o.paint.get("raster-fade-duration");I.registerFadeDuration(z);const B=i.findLoadedParent(S,0),k=xn(I,B,i,t.transform,z);let N,U;!k.isFading&&I.refreshedUponExpiration&&(I.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),_.activeTexture.set(f.TEXTURE0),R.bind(b,f.CLAMP_TO_EDGE),_.activeTexture.set(f.TEXTURE1),B?(B.texture&&B.texture.bind(b,f.CLAMP_TO_EDGE),N=Math.pow(2,B.tileID.overscaledZ-I.tileID.overscaledZ),U=[I.tileID.canonical.x*N%1,I.tileID.canonical.y*N%1]):R.bind(b,f.CLAMP_TO_EDGE),"useMipmap"in R&&_.extTextureFilterAnisotropic&&t.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax);const j=t.transform;let G;const V=c?Wc(j):[0,0,0,0];let q,H,Z,W,$,X=0;if(h&&p instanceof Ms&&p.coordinates.length>3)q=Float32Array.from(e.d3(e.dn(new e.bu(0,0,0)))),H=Float32Array.from(j.globeMatrix),Z=Float32Array.from(e.dp(j)),W=[e.a_(j.center.lng),e.a$(j.center.lat)],G=p.elevatedGlobePerspectiveTransform,$=p.elevatedGlobeGridMatrix||new Float32Array(9);else if(h){const t=e.dl(S.canonical);X=e.dm(t.getCenter().lat),q=Float32Array.from(e.d3(e.dn(S.canonical))),H=Float32Array.from(j.globeMatrix),Z=Float32Array.from(e.dp(j)),W=[e.a_(j.center.lng),e.a$(j.center.lat)],G=[0,0],$=Float32Array.from(e.dq(S.canonical,t,X,j.worldSize/j._pixelsPerMercatorPixel));}else G=p instanceof Ms?p.perspectiveTransform:[0,0],q=new Float32Array(16),H=new Float32Array(9),Z=new Float32Array(16),W=[0,0],$=new Float32Array(9);const Y=pc(t,M,q,H,Z,$,U||[0,0],e.ah(t.transform.zoom),W,V,N||1,k,o,G,c?o.paint.get("raster-elevation"):0,2,D,A,m.range,L,P,g),K=t.isTileAffectedByFog(S),Q=t.getOrCreateProgram("raster",{defines:m.defines,overrideFog:K});if(t.uploadCommonUniforms(_,Q,r),p instanceof Ms){const i=p.elevatedGlobeVertexBuffer,r=p.elevatedGlobeIndexBuffer;if(y||!l)p.boundsBuffer&&p.boundsSegments&&Q.draw(t,f.TRIANGLES,O,$i.disabled,v,yi.disabled,Y,o.id,p.boundsBuffer,t.quadTriangleIndexBuffer,p.boundsSegments);else if(i&&r){const s=j.zoom<=e.bU?p.elevatedGlobeSegments:p.getSegmentsForLongitude(j.center.lng);s&&Q.draw(t,f.TRIANGLES,O,$i.disabled,v,n,Y,o.id,i,r,s);}}else if(h){O=new xi(f.LEQUAL,xi.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){d&&(t.terrain.setupElevationDraw(I,Q),t.uploadCommonUniforms(_,Q,I.tileID.toUnwrapped()));const[i,r,s]=e.getGridBuffers(X,!1),a=Q.getAttributeLocation(f,"a_texture_pos");-1!==a&&f.vertexAttribI4ui(a,0,0,0,0),Q.draw(t,f.TRIANGLES,O,T||F,t.colorModeForRenderPass(),n,Y,o.id,i,r,s);}}else if(u)O=new xi(f.LEQUAL,xi.ReadWrite,t.depthRangeFor3D),t.terrain.setupElevationDraw(I,Q),t.uploadCommonUniforms(_,Q,I.tileID.toUnwrapped()),j.pitch>20&&Q.draw(t,f.TRIANGLES,O,$i.disabled,Ji.disabled,yi.frontCCW,Y,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),Q.draw(t,f.TRIANGLES,O,F,v,yi.backCCW,Y,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(I);Q.draw(t,f.TRIANGLES,O,F,v,yi.disabled,Y,o.id,e,i,r);}}if(!(p instanceof Ms)&&h)for(const e of r){const r=e.canonical.y===(1<e.tileID)),f&&(h.activeTexture.set(d.TEXTURE0),t.imageManager.bind(t.context,o.scope));const T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),c){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0,defines:T}),r=Xc,h=new e.br(0,0,0,0,0),u=f?xc(r,l,a,t,0,o.scope,p,c,{tileID:h,tileSize:_}):yc(r,l,a,n.toPremultipliedRenderColor(s?null:o.lut));return void i.draw(t,d.TRIANGLES,v,g,y,yi.disabled,u,o.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(const e of w){const m=t.isTileAffectedByFog(e),w=t.getOrCreateProgram(x,{overrideFog:m,defines:T}),E=e.toUnwrapped(),S=r?e.projMatrix:t.transform.calculateProjMatrix(E);t.prepareDrawTile();const I=i?i.getTile(e):b?b[e.key]:new dn(e,_,u.zoom,t),C=f?xc(S,l,a,t,0,o.scope,p,c,{tileID:e,tileSize:_}):yc(S,l,a,n.toPremultipliedRenderColor(s?null:o.lut));t.uploadCommonUniforms(h,w,E);const{tileBoundsBuffer:R,tileBoundsIndexBuffer:D,tileBoundsSegments:A}=t.getTileBoundsBuffers(I);w.draw(t,d.TRIANGLES,v,g,y,yi.disabled,C,o.id,R,D,A);}},sky:function(t,i,o){const r=t._atmosphere?e.ah(t.transform.zoom):1,n=o.paint.get("sky-opacity")*r;if(0===n)return;const s=t.context,a=o.paint.get("sky-type"),l=new xi(s.gl.LEQUAL,xi.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i){const o=t.context,r=o.gl;let n=i.skyboxFbo;if(!n){n=i.skyboxFbo=o.createFramebuffer(32,32,1,null),i.skyboxGeometry=new lh(o),i.skyboxTexture=o.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null);}o.bindFramebuffer.set(n.framebuffer),o.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.eU(l,.5*-Math.PI),ch(t,i,a,l,s,0),e.eU(l,.5*Math.PI),ch(t,i,a,l,s,1),e.eV(l,.5*-Math.PI),ch(t,i,a,l,s,2),e.eV(l,.5*Math.PI),ch(t,i,a,l,s,3),e.aC(l),ch(t,i,a,l,s,4),e.eU(l,Math.PI),ch(t,i,a,l,s,5),o.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,o,r){const n=e.context,s=n.gl,a=e.transform,l=e.getOrCreateProgram("skybox");n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,o,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,o,r);e.uploadCommonUniforms(n,l),l.draw(e,s.TRIANGLES,i,$i.disabled,e.colorModeForRenderPass(),yi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,n,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,o,r,n){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new lh(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const d=((t,i,o,r,n)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.al(o),u_opacity:r,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,n);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,o,$i.disabled,t.colorModeForRenderPass(),yi.backCW,d,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,n,c);},custom:function(t,i,o,r){const n=t.context,s=o.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&o.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const o=t.transform.pointMerc;i.call(s,n.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.ah(t.transform.zoom),[o.x,o.y],t.transform.pixelsPerMeterRatio);}else i.call(s,n.gl,t.transform.customLayerMatrix());n.setDirty(),t.setBaseState();}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=r[0].canonical,o={x:i.x+r[0].wrap*(s.wrapTileId?0:1<t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,n)&&o.prepareTile(t,r,e.id,n);}};async function yh(e){if(await Or(),Object.assign(gh,{model:Pr.drawModels}),Object.assign(vh,{model:Pr.prepare}),e&&!e._shadowRenderer){const t=Pr.ShadowRenderer;t&&(e._shadowRenderer=new t(e));}}class xh{constructor(t,i,o,r,n){this.context=new Ic(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.frcCoverageSnapshot=null,this.elevationCoverageSnapshot=null,this.elevationProvidersReady=void 0,this.frcCoverageFadeRange=null,this.frcCoverageSourceLayers=[],this.frcCoverageRenderer=Es.FrcCoverageRenderer?new Es.FrcCoverageRenderer:null,this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParamsOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:-1,lodSwitchFadeDuration:.5},this.occlusionParams=new mh,this.setup(),this.numSublayers=Zn.maxUnderzooming+Zn.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this.frameTimeDelta=0,this.lastPaintStartTimeStamp=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.f1,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._wireframeDebugCache=new ph,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const s=new e.t({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,s,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.maxFrontCutoffRawStart=0,this.worldview=n,this._forceEmissiveMode=!1,this.emissiveMode="constant";}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new ec(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,o]=t.getRangeForProjection();if(i>o)return void(this.transform.fogCullDistSq=null);const r=i+.78*(o-i);this.transform.fogCullDistSq=r*r;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new ec(this,this.style)),this._forceTerrainMode=e;}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.r.devicePixelRatio,this.height=i*e.r.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const t=this.context,i=new e.co;i.emplaceBack(0,0),i.emplaceBack(e.aj,0),i.emplaceBack(0,e.aj),i.emplaceBack(e.aj,e.aj),this.tileExtentBuffer=t.createVertexBuffer(i,e.cq.members),this.tileExtentSegments=e.cr.simpleSegment(0,0,4,2);const o=new e.co;o.emplaceBack(0,0),o.emplaceBack(e.aj,0),o.emplaceBack(0,e.aj),o.emplaceBack(e.aj,e.aj),this.debugBuffer=t.createVertexBuffer(o,e.cq.members),this.debugSegments=e.cr.simpleSegment(0,0,4,5);const r=new e.co;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.cq.members),this.viewportSegments=e.cr.simpleSegment(0,0,4,2);const n=new e.cQ;n.emplaceBack(0,0,0,0),n.emplaceBack(e.aj,0,e.aj,0),n.emplaceBack(0,e.aj,0,e.aj),n.emplaceBack(e.aj,e.aj,e.aj,e.aj),this.mercatorBoundsBuffer=t.createVertexBuffer(n,ln.members),this.mercatorBoundsSegments=e.cr.simpleSegment(0,0,4,2);const s=new e.cp;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.d0;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.t({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.aS();const l=this.context.gl;this.stencilClearMode=new $i({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,xi.disabled,this.stencilClearMode,Ji.disabled,yi.disabled,fs(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const o=this.context,r=o.gl;this.nextStencilID+i.length>256&&this.clearStencil(),o.setColorMode(Ji.disabled),o.setDepthMode(xi.disabled);const n=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),o=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);n.draw(this,r.TRIANGLES,xi.disabled,new $i({func:r.ALWAYS,mask:0},o,255,r.KEEP,r.KEEP,r.REPLACE),Ji.disabled,yi.disabled,fs(e.projMatrix),"$clipping",s,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new $i({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new $i({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),o=i.at(-1).overscaledZ,r=i[0].overscaledZ-o+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new Ji([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.C(0,0,0,null!=t?t:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new Ji([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],e.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(this.depthOcclusion)return new xi(this.context.gl.GREATER,xi.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!o)return xi.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new xi(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayerthis.style._getOrder(r);let s=n(),a=!1,l=!1,c=null,h=0,d=!1;for(const e of s){const t=o[e];"none"!==t.visibility&&("circle"===t.type?a=!0:"building"===t.type?(c=t,++h):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?l=!0:a=!0));}this.updateEmissiveMode();let u=s.map(e=>o[e]);const _=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.r.now()),this.imageManager.beginFrame();for(const e in _){const t=_[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++h);}let f=!1;for(const e of u)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const p={},m={},g={},v={},y={};for(const e in _){const t=_[e];p[e]=t.getVisibleCoordinates(),m[e]=p[e].slice().reverse(),g[e]=t.getVisibleCoordinates(!0).reverse(),v[e]=t.getShadowCasterCoordinates(),y[e]=t.sortCoordinatesByDistance(p[e]);}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(h||f||this._clippingActiveLastFrame){const t=[],i=[];let o=0;for(const e of u)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(o)),o++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;const o=[];for(let r=0;r0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D(r)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(g),this.opaquePassCutoff=0,s=n(),u=s.map(e=>o[e])),this.style.enable3dLights()&&!this._shadowRenderer&&yh(this);const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in _)for(const t of p[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.f3(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new _h),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let T=!(!this.style||!this.style.snow),E=!(!this.style||!this.style.rain);if(T&&!this._snow&&Es.Snow&&(this._snow=new Es.Snow),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&Es.Rain&&(this._rain=new Es.Rain),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),c&&(!this.buildingTileBorderManager&&Es.BuildingTileBorderManager&&(this.buildingTileBorderManager=new Es.BuildingTileBorderManager),this.buildingTileBorderManager)){const e=this.style.getLayerSourceCache(c);this.buildingTileBorderManager.updateBorders(e,c);}if(!oe.has(this.context.gl))return;this.renderPass="offscreen";for(const e of u){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?m[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||o&&o.length)&&this.renderLayer(this,i,e,o);}this.depthRangeFor3D=[0,1-(u.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,v)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const S="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),I=(()=>{if(i.showOverdrawInspector)return e.C.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!S){const o="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.C(...r)}if(S){const o="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.C(...r)}}return e.C.transparent})();if(this.context.clear({color:I,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=u[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D(r)?y:m)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.ah(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=u[this.currentLayer],o=t.getLayerSourceCache(i),r=o?m[o.id]:void 0;this.terrain||this._renderTileClippingMasks(i,o,o?p[o.id]:void 0),this.renderLayer(this,o,i,r);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;u.forEach(e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&this.style.hasTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i,o,r){const n=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,s=void 0===o?this.terrainRenderModeElevated():o,a=void 0===r?"globe"===this.transform.projection.name:r,l=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(l.push("LIGHTING_3D_MODE"),l.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):n||l.push("LIGHTING_3D_MODE")),s&&(l.push("TERRAIN"),this.linearFloatFilteringSupported()&&l.push("TERRAIN_DEM_FLOAT_FORMAT")),a&&l.push("GLOBE"),!this._fogVisible||n||void 0!==t&&!t||l.push("FOG"),n&&l.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&l.push("OVERDRAW_INSPECTOR"),l}getOrCreateProgram(e,t){this.cache=this.cache||{};const{defines:i,config:o,overrideFog:r,overrideRtt:n,overrideTerrain:s,overrideGlobe:a,precompiled:l}=t||{},c=this.currentGlobalDefines(e,r,n,s,a).concat(i||[]),h=this.getShaderSource(e),d=Es.programUniforms,u=Pr.programUniforms,_=bc[e]||d&&d[e]||u&&u[e],f=rc.cacheKey(h,e,c,o);return this.cache[f]||(this.cache[f]=new rc(this.context,e,h,o,_,c,l)),this.cache[f]}getShaderSource(e){const t=Es.shaders,i=Pr.shaders;return mr[e]||t&&t[e]||i&&i[e]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i,o){if(this.style.enable3dLights()){const r=this.style.directionalLight,n=this.style.ambientLight;if(r&&n){const s=((t,i,o,r)=>{const n=t.properties.get("direction"),s="none"===t.properties.get("color-use-theme"),a=t.properties.get("color").toNonPremultipliedRenderColor(s?null:o.getLut(t.scope)).toArray01();let l=t.properties.get("intensity");const c="none"===i.properties.get("color-use-theme"),h=i.properties.get("color").toNonPremultipliedRenderColor(c?null:o.getLut(i.scope)).toArray01();let d=i.properties.get("intensity");const u=[n.x,n.y,n.z];r&&(void 0!==r.ambientIntensity&&(d=r.ambientIntensity),void 0!==r.directionalIntensity&&(l=r.directionalIntensity),void 0!==r.ambientColor&&(h[0]=r.ambientColor[0],h[1]=r.ambientColor[1],h[2]=r.ambientColor[2]),void 0!==r.directionalColor&&(a[0]=r.directionalColor[0],a[1]=r.directionalColor[1],a[2]=r.directionalColor[2]));const _=e.ez(h,d),f=e.ez(a,l);return {u_lighting_ambient_color:_,u_lighting_directional_dir:u,u_lighting_directional_color:f,u_ground_radiance:tc(u,f,_)}})(r,n,this.style,o);i.setLightsUniformValues(t,s);}}}uploadCommonUniforms(t,i,o,r,n,s){if(this.uploadCommonLightUniforms(t,i,s),this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const n=a.getOpacity(this.transform.pitch),s=((t,i,o,r,n,s,a,l,c,h,d,u)=>{const _=t.transform,f="none"===i.properties.get("color-use-theme"),p=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();p[3]=r;const m=t.frameCounter/1e3%1,[g,v]=i.properties.get("vertical-range");return {u_fog_matrix:o?_.calculateFogTileMatrix(o):u||t.identityMat,u_fog_range:i.getRangeForProjection(),u_fog_color:p,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,v),v],u_fog_temporal_offset:m,u_frustum_tl:n,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_globe_transition:e.ah(_.zoom),u_is_globe:+("globe"===_.projection.name)}})(this,a,o,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*e.r.devicePixelRatio,this.transform.height*e.r.devicePixelRatio],r);i.setFogUniformValues(t,s);}n&&i.setCutoffUniformValues(t,n.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const o of i)t[o.key]=e[o.key]||new dn(o,512,this.transform.tileZoom,this,void 0,this.worldview);return t}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==e.sourceLayer)&&(!t||"batched-model"!==t.type)))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=$t||t[1]>=$t}setupDepthForOcclusion(e,t,i){const o=this.context,r=o.gl,n=!!i;var s;i||(i={u_dem:2,u_dem_prev:4,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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),o.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),o.activeTexture.set(r.TEXTURE0),n||t.setTerrainUniformValues(o,i);}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant";}}function bh(e,t){let i=!1,o=null;const r=()=>{o=null,i&&(e(),o=setTimeout(r,t),i=!1);};return ()=>(i=!0,o||r(),o)}const wh=/(#.+)?$/;class Th{constructor(t){this._hashName=t&&encodeURIComponent(t),e.cL(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=bh(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const t=Eh(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split("&").map(o=>{const r=o.split("=")[0];return r===e?(i=!0,`${r}=${t}`):o}).filter(e=>e);return i||o.push(`${e}=${t}`),`#${o.join("&")}`}return `#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e);}),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(Number(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(wh,this.getHashString()));}}function Eh(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,r=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),s=Math.round(i.lng*n)/n,a=Math.round(i.lat*n)/n,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${o}`:`${o}/${a}/${s}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const Sh={linearity:.3,easing:e.f5(0,0,.3,1)},Ih={deceleration:2500,maxSpeed:1400,...Sh},Ch={deceleration:20,maxSpeed:1400,...Sh},Rh={deceleration:1e3,maxSpeed:360,...Sh},Dh={deceleration:1e3,maxSpeed:90,...Sh};class Ah{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.r.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.r.now();for(;t.length>0&&i-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const o=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=Ph(i.pan.mag(),o,{...Ih,...t||{}});r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,Lh(r,e);}if(i.zoom){const e=Ph(i.zoom,o,Ch);r.zoom=this._map.transform.zoom+e.amount,Lh(r,e);}if(i.bearing){const t=Ph(i.bearing,o,Rh);r.bearing=this._map.transform.bearing+e.as(t.amount,-179,179),Lh(r,t);}if(i.pitch){const e=Ph(i.pitch,o,Dh);r.pitch=this._map.transform.pitch+e.amount,Lh(r,e);}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function Lh(e,t){(!e.duration||e.durationi.unproject(e)),a=n.reduce((e,t,i,o)=>e.add(t.div(o.length)),new e.P(0,0));super(t,{points:n,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:o}),this._defaultPrevented=!1;}}class Fh extends e.B{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class zh{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new Fh(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Oh(e.type,this._map,e))}mouseup(e){this._map.fire(new Oh(e.type,this._map,e));}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Oh(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Oh(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new Oh(e.type,this._map,e))}mouseover(e){this._map.fire(new Oh(e.type,this._map,e));}mouseout(e){this._map.fire(new Oh(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Mh(e.type,this._map,e))}touchmove(e){this._map.fire(new Mh(e.type,this._map,e));}touchend(e){this._map.fire(new Mh(e.type,this._map,e));}touchcancel(e){this._map.fire(new Mh(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Bh{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new Oh(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oh("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Oh(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class kh{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(_(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,r=this._lastPos;if(!o||!r||r.equals(i)||!this._box&&i.dist(o){this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=s-n+"px",this._box.style.height=c-a+"px");});}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,r=i;if(o&&0===t.button){if(this.reset(),m(),o.x!==r.x||o.y!==r.y)return this._map.fire(new e.B("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),f(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.B(t,{originalEvent:i}))}}function Nh(e,t){const i={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Nh(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=Nh(i,t);for(const e in this.touches){const t=o[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class jh{constructor(e){this.singleTap=new Uh(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Gh{constructor(){this._zoomIn=new jh({numTouches:1,numTaps:2}),this._zoomOut=new jh({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const o=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(r)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const Vh=0,qh=2,Hh={[Vh]:1,[qh]:2},Zh={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class Wh{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=y(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=Hh[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=Nh(o,i),n=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),s._add(t.sub(i)),a++,r[e]=t);}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");},500);}}class Qh{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[r,n]=o,s=Jh(i,t,r),a=Jh(i,t,n);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,r]=this._firstTwoTouches,n=Jh(i,t,o),s=Jh(i,t,r);n&&s||(this._active&&m(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}function Jh(e,t,i){for(let o=0;oMath.abs(e.x)}class nd extends Qh{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,rd(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const r=this._lastPoints;if(!r)return;const n=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.f6()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(n,s,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,r=t.mag()>=2;if(!o&&!r)return;if(!o||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=e.y>0==t.y>0;return rd(e)&&rd(t)&&n}}const sd={panStep:100,bearingStep:15,pitchStep:10};class ad{constructor(){const e=sd;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1,this._panDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,o=0,r=0,n=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),n=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),this._panDisabled&&(r=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:ld,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+o*this._pitchStep,offset:[-r*this._panStep,-n*this._panStep],center:s.getCenter()},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}disablePan(){this._panDisabled=!0;}enablePan(){this._panDisabled=!1;}}function ld(e){return e*(2-e)}const cd=4.000244140625,hd=1/450,dd=/(Mac|iPad)/i;class ud{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=hd,e.cL(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.f6()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=e.r.now(),r=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%cd===0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=g(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,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 t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>cd?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const r=i(),n=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):n;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*o))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,n=this._easing;let s,a=!1;if("wheel"===this._type&&r&&n){const t=Math.min((e.r.now()-this._lastWheelEventTime)/200,1),i=n(t);s=e.ai(r,o,i),t<1?this._frameId||(this._frameId=!0):a=!0;}else s=o,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;},200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.f7;if(this._prevEase){const t=this._prevEase,o=(e.r.now()-t.start)/t.duration,r=t.easing(o+.01)-t.easing(o),n=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-n*n);i=e.f5(n,s,.25,1);}return this._prevEase={start:e.r.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=dd.test(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`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role");},200);}}class _d{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class fd{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class pd{constructor(){this._tap=new jh({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const o=t[0],r=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class md{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("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 gd{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i,this._pitchDisabled=!1;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&!this._pitchDisabled&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._pitchDisabled||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}disablePitch(){this._pitchDisabled=!0,this._mousePitch.disable();}enablePitch(){this._pitchDisabled=!1,this._pitchWithRotate&&this._mouseRotate.isEnabled()&&this._mousePitch.enable();}}class vd{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,this._rotationDisabled=!1,this._tapDragZoomDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoomDisabled||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._tapDragZoomDisabled||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();}disableTapDragZoom(){this._tapDragZoomDisabled=!0,this._tapDragZoom.disable();}enableTapDragZoom(){this._tapDragZoomDisabled=!1,this._touchZoom.isEnabled()&&this._tapDragZoom.enable();}}const yd=e=>e.zoom||e.drag||e.pitch||e.rotate;class xd extends e.B{}class bd{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.aW([],i,t);this.radius=e.ae(o[2]<0?e.f9([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.f9(t,t,this.constants),e.au(t,t),e.fa(t,t,this.constants);const i=e.av([],t,this.radius);if(i[2]>0){const t=e.av([],[0,0,1],e.aw(i,[0,0,1])),o=e.av([],e.au([],[i[0],i[1],0]),this.radius),r=e.cz([],i,e.av([],e.aW([],e.cz([],o,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function wd(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Td{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ah(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new bd,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.cL(["handleEvent","handleWindowEvent"],this);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new zh(t,e));const o=t.boxZoom=new kh(t,e);this._add("boxZoom",o);const r=new Gh,n=new fd;t.doubleClickZoom=new _d(n,r),this._add("tapZoom",r),this._add("clickZoom",n);const s=new pd;this._add("tapDragZoom",s);const a=t.touchPitch=new nd(t);this._add("touchPitch",a);const l=new Xh(e),c=new Yh(e);t.dragRotate=new gd(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new $h(e),d=new Kh(t,e);t.dragPan=new md(i,h,d),this._add("mousePan",h),this._add("touchPan",d,["touchZoom","touchRotate"]);const u=new od,_=new td;t.touchZoomRotate=new vd(i,_,u,s),this._add("touchRotate",u,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Bh(t));const f=t.scrollZoom=new ud(t,this);this._add("scrollZoom",f,["mousePan"]);const p=t.keyboard=new ad;this._add("keyboard",p);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0;}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return !!yd(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(!(o===i||t&&t.includes(o)))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,o=i?void 0:e,r={needsRenderFrame:!1},n={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?v(this._el,a):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let d;this._blockedByActive(s,h,i)?c.reset():c[t||e.type]&&(d=c[t||e.type](e,l,a),this.mergeHandlerResult(r,n,d,i,o),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||c.isActive())&&(s[i]=c);}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=o);this._previousActiveHandlers=s,(Object.keys(c).length||wd(r))&&(this._changes.push([r,n,c]),this._triggerRenderFrame()),(Object.keys(s).length||wd(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,o,r){if(!i)return;Object.assign(e,i);const n={handlerName:o,originalEvent:i.originalEvent||r};void 0!==i.zoomDelta&&(t.zoom=n),void 0!==i.panDelta&&(t.drag=n),void 0!==i.pitchDelta&&(t.pitch=n),void 0!==i.bearingDelta&&(t.rotate=n);}_applyChanges(){const t={},i={},o={};for(const[r,n,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,n),Object.assign(o,s);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const r=this._map,n=r.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!wd(t)){const e=n.zoom;n.cameraElevationReference="sea",null!=this._originalZoom&&n._orthographicProjectionAtLowPitch&&"globe"!==n.projection.name&&0===n.pitch?(n.cameraElevationReference="ground",n.zoom=this._originalZoom):(n.recenterOnTerrain(),n.cameraElevationReference="ground"),e!==n.zoom&&this._map._update(!0);}if(n._isCameraConstrained&&r._stop(!0),!wd(t))return void this._fireEvents(i,o,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:d,aroundCoord:u,pinchAround:_}=t;n._isCameraConstrained&&(l>0&&(l=0),n._isCameraConstrained=!1),void 0!==_&&(d=_),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&d&&(this._dragOrigin=s(n.pointCoordinate3D(d)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),d=d||r.transform.centerPoint,c&&(n.bearing+=c),h&&(n.pitch+=h),n._updateCameraState();const f=[0,0,0];if(a)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(d).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(d.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1];}else {const t=n.pointCoordinate(d);if("globe"===n.projection.name){a=a.rotate(-n.angle);const i=n._pixelsPerMercatorPixel/n.worldSize;f[0]=-a.x*e.f8(e.aM(t.y))*i,f[1]=-a.y*e.f8(n.center.lat)*i;}else {const e=n.pointCoordinate(d.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y);}}const p=n.zoom,m=[0,0,0];if(l){const t=s(u||n.pointCoordinate3D(d)),i={dir:e.au([],e.aW([],t,n._camera.position))};if(i.dir[2]<0){const o=n.zoomDeltaToMovement(t,l);e.av(m,i.dir,o);}}const g=e.cz(f,f,m);n._translateCameraConstrained(g),l&&Math.abs(n.zoom-p)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const r=yd(this._eventsInProgress),n=yd(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in s)this._fireEvent(e,s[e]);n&&this._fireEvent("move",n.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,a[`${e}end`]=l);}for(const e in a)this._fireEvent(e,a[e]);const c=yd(this._eventsInProgress);if(o&&(r||n)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new xd("renderFrame",{timeStamp:e})),this._applyChanges();})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Ed="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Sd extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.cL(["_renderFrameCallback"],this);}getCenter(){return new e.b4(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,{offset:t,...i},o)}panTo(e,t,i){return this.easeTo({center:e,...t},i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo({zoom:e,...t},i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo({bearing:e,...t},i)}resetNorth(e,t){return this.rotateTo(0,{duration:1e3,...e},t),this}resetNorthPitch(e,t){return this.easeTo({bearing:0,pitch:0,duration:1e3,...e},t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,r,n,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=n;const c=e.b4.convert(i),h=e.b4.convert(o),d=.5*(c.lat+h.lat),u=.5*(c.lng+h.lng),_=e.fb(d,u),f=e.au([],_),p=e.au([],e.ax([],f,[0,1,0])),m=e.ax([],p,f),g=[p[0],p[1],p[2],0,m[0],m[1],m[2],0,f[0],f[1],f[2],0,0,0,0,1],v=[_,e.fb(c.lat,c.lng),e.fb(h.lat,c.lng),e.fb(h.lat,h.lng),e.fb(c.lat,h.lng),e.fb(d,c.lng),e.fb(d,h.lng),e.fb(c.lat,u),e.fb(h.lat,u)];let y=e.ca.fromPoints(v.map(t=>[e.aw(p,t),e.aw(m,t),e.aw(f,t)]));const x=e.ad([],y.center,g);0===e.fc(x)&&e.fd(x,0,0,1),e.au(x,x),e.av(x,x,e.dK),a.center=e.fe(x);const b=a.getWorldToCameraMatrix(),w=e.aE(new Float64Array(16),b);y=e.ca.applyTransform(y,e.aP([],b,g));const T=this._extendAABB(y,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=T,e.ad(x,x,b);const E=.5*(y.max[2]-y.min[2]),S=this._minimumAABBFrustumDistance(a,y),I=e.av([],[0,0,1],E),C=e.cz(I,x,I),R=S+(0===a.pitch?0:e.aX(x,C)),D=a.globeCenterInViewSpace,A=e.aW([],x,[D[0],D[1],D[2]]);e.au(A,A),e.av(A,A,R);const L=e.cz([],x,A);e.ad(L,L,w);const P=e.du/e.dK,O=e.ae(L),M=e.aL(Math.max(O*P-e.du,Number.EPSILON),0),F=Math.min(a.zoomFromMercatorZAdjusted(M),l.maxZoom);return F>.5*(e.bU+e.bD)?(a.setProjection({name:"mercator"}),a.zoom=F,this._cameraForBounds(a,i,o,r,n,s)):{center:a.center,zoom:F,bearing:r,pitch:n}}_extendAABB(t,i,o,r){const n=.5*((o.padding.left||0)+(o.padding.right||0)),s=.5*((o.padding.top||0)+(o.padding.bottom||0)),a=s,l=n,c=n,h=s,d=i.width-(l+c),u=i.height-(a+h),_=e.aW([],t.max,t.min),f=Math.min(d/_[0],u/_[1]),p=Math.min(i.scaleZoom(i.scale*f),o.maxZoom);if(isNaN(p))return null;const m=i.scale/i.zoomScale(p),g=new e.ca([t.min[0]-l*m,t.min[1]-h*m,t.min[2]],[t.max[0]+c*m,t.max[1]+a*m,t.max[2]]),v=("number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.P(o.offset.x,o.offset.y):e.P.convert(o.offset)).rotate(-e.al(r));return g.center[0]-=v.x*m,g.center[1]+=v.y*m,g}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i={exaggerated:!0,...i},o.getAtPoint(e.ac.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,r,n,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,r,n,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=n;const c=e.b4.convert(i),h=e.b4.convert(o),d=new e.b4(c.lng,h.lat),u=new e.b4(h.lng,c.lat),_=a.project(c),f=a.project(h),p=this.queryTerrainElevation(c),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(d),v=this.queryTerrainElevation(u),y=[[_.x,_.y,Math.min(p||0,m||0,g||0,v||0)],[f.x,f.y,Math.max(p||0,m||0,g||0,v||0)]];let x=e.ca.fromPoints(y);const b=a.getWorldToCameraMatrix(),w=e.aE(new Float64Array(16),b);x=e.ca.applyTransform(x,b);const T=this._extendAABB(x,a,l,r);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T;const E=.5*e.aW([],x.max,x.min)[2],S=this._minimumAABBFrustumDistance(a,x),I=[0,0,1,0];e.aO(I,I,b),e.ff(I,I);const C=e.av([],I,S+E),R=e.cz([],x.center,C);e.ad(x.center,x.center,w),e.ad(R,R,w);const D=a.unproject(new e.P(x.center[0],x.center[1])),A=e.fg(a.projection,D),L=Math.pow(2,A),P=Math.min(a._zoomFromMercatorZ(R[2]*a.pixelsPerMeter*L/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&P<.5*(e.bU+e.bD)?(a.setProjection({name:"globe"}),a.zoom=P,this._cameraForBounds(a,i,o,r,n,s)):{center:D,zoom:P,bearing:r,pitch:n}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,r,n){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const h=this.transform.pointLocation3D(l),d=this.transform.pointLocation3D(c),u=this.transform.pointLocation3D(new e.P(l.x,c.y)),_=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(h.lng,d.lng,u.lng,_.lng),Math.min(h.lat,d.lat,u.lat,_.lat)],p=[Math.max(h.lng,d.lng,u.lng,_.lng),Math.max(h.lat,d.lat,u.lat,_.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,p,o,m,r);return this._fitInternal(g,r,n)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,s=!1;"zoom"in t&&o.zoom!==+t.zoom&&(r=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.b4.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(n=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(s=!0,o.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!o.isPaddingEqual(a))if(!1===t.retainPadding){const e=o.clone();e.padding=a,o.setLocationAtPoint(o.center,e.centerPoint);}else o.padding=a;return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.B("movestart",i)).fire(new e.B("move",i)),r&&this.fire(new e.B("zoomstart",i)).fire(new e.B("zoom",i)).fire(new e.B("zoomend",i)),n&&this.fire(new e.B("rotatestart",i)).fire(new e.B("rotate",i)).fire(new e.B("rotateend",i)),s&&this.fire(new e.B("pitchstart",i)).fire(new e.B("pitch",i)).fire(new e.B("pitchend",i)),this.fire(new e.B("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ed),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(Ed),this;this.stop();const r=o.zoom,n=o.pitch,s=o.bearing;o.setFreeCameraOptions(t);const a=r!==o.zoom,l=n!==o.pitch,c=s!==o.bearing;return this.fire(new e.B("movestart",i)).fire(new e.B("move",i)),a&&this.fire(new e.B("zoomstart",i)).fire(new e.B("zoom",i)).fire(new e.B("zoomend",i)),c&&this.fire(new e.B("rotatestart",i)).fire(new e.B("rotate",i)).fire(new e.B("rotateend",i)),l&&this.fire(new e.B("pitchstart",i)).fire(new e.B("pitch",i)).fire(new e.B("pitchend",i)),this.fire(new e.B("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t={offset:[0,0],duration:500,easing:e.f7,...t}).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,d=this._extendPadding(t.padding),u=e.P.convert(t.offset);let _,f,p;if("globe"===o.projection.name){const i=e.ac.fromLngLat(o.center),r=u.rotate(-o.angle);i.x+=r.x/o.worldSize,i.y+=r.y/o.worldSize;const n=i.toLngLat(),s=e.b4.convert(t.center||n);this._normalizeCenter(s),_=o.centerPoint.add(r),f=new e.P(i.x,i.y).mult(o.worldSize),p=new e.P(e.a_(s.lng),e.a$(s.lat)).mult(o.worldSize).sub(f);}else {_=o.centerPoint.add(u);const i=o.pointLocation(_),r=e.b4.convert(t.center||i);this._normalizeCenter(r),f=o.project(i),p=o.project(r).sub(f);}const m=o.zoomScale(l-r);let g,v;t.around&&(g=e.b4.convert(t.around),v=o.locationPoint(g));const y=this._zooming||l!==r,x=this._rotating||n!==c,b=this._pitching||h!==s,w=!o.isPaddingEqual(d),T=!1===t.retainPadding?o.clone():o,E=o=>E=>{if(y&&(o.zoom=e.ai(r,l,E)),x&&(o.bearing=e.ai(n,c,E)),b&&(o.pitch=e.ai(s,h,E)),w&&(T.interpolatePadding(a,d,E),_=T.centerPoint.add(u)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-r),t=l>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-E),n=o.unproject(f.add(p.mult(E*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?n.wrap():n,_);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(E,t.duration,o);return this._preloadTiles(e),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,S),this._ease(E(o),e=>{"sea"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);},t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||o.moving||this.fire(new e.B("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.B("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.B("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.B("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.B("move",t)),this._zooming&&this.fire(new e.B("zoom",t)),this._rotating&&this.fire(new e.B("rotate",t)),this._pitching&&this.fire(new e.B("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const o=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new e.B("zoomend",t)),r&&this.fire(new e.B("rotateend",t)),n&&this.fire(new e.B("pitchend",t)),this.fire(new e.B("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.b5(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(o,i)}this.stop(),t={offset:[0,0],speed:1.2,curve:1.42,easing:e.f7,...t};const o=this.transform,r=this.getZoom(),n=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.as(+t.zoom,o.minZoom,o.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,n):n,h="pitch"in t?+t.pitch:s,d=this._extendPadding(t.padding),u=o.zoomScale(l-r),_=e.P.convert(t.offset);let f=o.centerPoint.add(_);const p=o.pointLocation(f),m=e.b4.convert(t.center||p);this._normalizeCenter(m);const g=o.project(p),v=o.project(m).sub(g);let y=t.curve;const x=Math.max(o.width,o.height),b=x/u,w=v.mag();if("minZoom"in t){const i=e.as(Math.min(t.minZoom,r,l),o.minZoom,o.maxZoom),n=x/o.zoomScale(i-r);y=Math.sqrt(n/w*2);}const T=y*y;function E(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return (Math.exp(e)-Math.exp(-e))/2}function I(e){return (Math.exp(e)+Math.exp(-e))/2}const C=E(0);let R=function(e){return I(C)/I(C+y*e)},D=function(e){return x*((I(C)*(S(t=C+y*e)/I(t))-S(C))/T)/w;var t;},A=(E(1)-C)/y;if(Math.abs(w)<1e-6||!isFinite(A)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const L=n!==c,P=h!==s,O=!o.isPaddingEqual(d),M=!1===t.retainPadding?o.clone():o,F=o=>u=>{const p=u*A,y=1/R(p);o.zoom=1===u?l:r+o.scaleZoom(y),L&&(o.bearing=e.ai(n,c,u)),P&&(o.pitch=e.ai(s,h,u)),O&&(M.interpolatePadding(a,d,u),f=M.centerPoint.add(_));const x=1===u?m:o.unproject(g.add(v.mult(D(p))).mult(y));return o.setLocationAtPoint(o.renderWorldCopies?x.wrap():x,f),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(F,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=P,this._padding=O,this._prepareEase(i,!1),this._ease(F(o),()=>this._afterEase(i),t),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t);}if(!e){const e=this.handlers;e&&e.stop(!1);}return this}_ease(t,i,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.r.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.r.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(t,i){t=e.at(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.r.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),r=[],n=e(i.clone());for(let e=0;e<=o;e++){const t=n(e/o);r.push(t.clone());}return r}_preloadTiles(e,t){}}const Id=/^(https?:|mailto:)/i;class Cd{constructor(t={}){this.options=t,e.cL(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const o=l("span","mapboxgl-ctrl-icon",this._compactButton);return o.setAttribute("aria-hidden","true"),o.setAttribute("title",i),this._innerContainer=l("div","mapboxgl-ctrl-attrib-inner",this._container),t&&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===t&&(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;}_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 t=this._editLink;t||(t=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||e.g.ACCESS_TOKEN}];if(t){const o=i.reduce((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${oe.length-t.length),e=e.filter((t,i)=>{for(let o=i+1;ofunction(e){const t=(new DOMParser).parseFromString(e,"text/html");return Array.from(t.body.querySelectorAll("*")).reverse().forEach(e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(...e.childNodes);const o=e.getAttribute("href");if(!o||!Id.test(o))return void e.replaceWith(t.createTextNode(i));const r=t.createElement("a");r.href=o,r.textContent=i,r.rel="noopener nofollow";const n=e.getAttribute("class");n&&(r.className=n),e.replaceWith(r);}),t.body.innerHTML}(e)).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.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 Rd{constructor(){e.cL(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(Object.hasOwn(i,"mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class Dd{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}class Ad{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.eu((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const Ld={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","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"};class Pd extends e.B{constructor(e,t,i,o){const{point:r,lngLat:n,originalEvent:s,target:a}=e;super(e.type,{point:r,lngLat:n,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault();},this.id=t,this.interaction=i,this.feature=o;}}class Od{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map;}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const o=i.filter;let r=i.type;o&&this.filters.set(t,e.cV(o)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const n=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===n.size&&this.map.on(r,this.handleType),0===n.size&&this.interactionsByType.set(r,n),n.set(t,i),this.typeById.set(t,r);}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType));}queryTargets(e,t){const i=[];for(const[e,o]of t)o.target&&i.push({targetId:e,target:o.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())));}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear();}handleType(t,i){const o="mouseenter"===t.type;if(o&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),n=!!i;i=i||this.queryTargets(t.point,r);let s=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const h of r){if(Ns(h,l,a,i))continue;const r=new e.er(l,h),d=ks(h,l,i);n&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const u=o?this.prevHoveredFeatures.get(d):null,_=new Pd(t,i,c,r),f=u?u.stop:c.handler(_);if(o&&this.hoveredFeatures.set(d,{feature:l,stop:f}),!1!==f){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of r){const{handler:o,target:r}=i;if(!r&&!1!==o(new Pd(t,e,i,null)))break}}}function Md(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),o=new Set(i);return e.size===o.size&&t.every(e=>o.has(e))}return e.b7(t,i)}const Fd=/matrix.*\((.+)\)/,zd={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,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},Bd={showCompass:!0,showZoom:!0,visualizePitch:!1};class kd{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Xh({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new Yh({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.cL(["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(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),_();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),r=o&&o.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),r=o&&o.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down({...e,button:e.button,type:e.type,ctrlKey:!0,preventDefault:()=>e.preventDefault()},g(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,g(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=v(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=v(this.element,e.targetTouches)[0],this.move({buttons:1,preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)o.width||i.y>o.height;o.locationPoint3D(r).distSqr(i)180;){const e=o.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const Ud={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%)"},jd=/\s+/,Gd={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Vd extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t={element:t,...i}),e.cL(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:o="center",color:r="#3FB1CE",scale:n=1,draggable:s=!1,clickTolerance:a=0,rotation:l=Gd.rotation,rotationAlignment:c=Gd.rotationAlignment,pitchAlignment:h=Gd.pitchAlignment,occludedOpacity:d=Gd.occludedOpacity,altitude:u=Gd.altitude}=t||{};this._anchor=o,this._color=r,this._scale=n,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=h,this._occludedOpacity=d,this._altitude=u,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault();}),this._element.addEventListener("mousedown",e=>{e.preventDefault();});const _=this._element.classList;for(const e in Ud)_.remove(`mapboxgl-marker-anchor-${e}`);_.add(`mapboxgl-marker-anchor-${this._anchor}`),t&&t.className&&_.add(...t.className.trim().split(jd)),this._popup=null;}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);this._svgElement=t;const i=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},i),c("stop",{offset:"100%","stop-opacity":.05},i);const o=c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"});return this._shadowElement=o,0===this._altitude&&t.insertBefore(o,t.firstChild),c("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"},t),c("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"},t),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.b4.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){if(e===this._altitude)return this;const t=this._altitude;return this._altitude=e||Gd.altitude,this._defaultMarker&&0===t!=(0===this._altitude)&&(0===this._altitude?this._svgElement.insertBefore(this._shadowElement,this._svgElement.firstChild):this._shadowElement.remove()),this._update(),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,o=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,e._altitude=this._altitude,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(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t,this._altitude),o=e.getFreeCameraOptions();if(!o.position)return !1;const r=o.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const o=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.fi(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(o),t.transform._terrainEnabled()&&t.style&&t.style.hasTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${Ud[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||"map"!==o)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.bS(e.fj(i.transform,this._lngLat)),n=t.sub(e.fk(i.transform)),s=Math.abs(n.x)+Math.abs(n.y);if(0===s)return "";const a=r/s;return `rotateX(${-n.y*a}deg) rotateY(${n.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let o=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.b4(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.b4(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);o=e.bS(Math.atan2(r.y,r.x))-90;}else o=-i.getBearing();else if("horizon"===r){const r=e.af(4,6,i.getZoom()),n=e.fk(i.transform);n.y+=r*i.transform.height;const s=t.sub(n),a=e.bS(Math.atan2(s.y,s.x));o=(a>90?a-270:a+90)*(1-r);}return o+=this._rotation,o?`rotateZ(${o}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Nd(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.style&&t.style.hasTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)));}));}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const o=this._pointerdownPos,r=this._positionDelta;if(o&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)`mapboxgl-ctrl-geolocate-${e}`,Zd=["waiting","active","active-error","background","background-error"].map(Hd),Wd={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},$d={maxWidth:100,unit:"metric"},Xd={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},Yd=/\s+/,Kd={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},Qd=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Jd(t=new e.P(0,0),i="bottom"){if("number"==typeof t){const o=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case "top":return new e.P(0,t);case "top-left":return new e.P(o,o);case "top-right":return new e.P(-o,o);case "bottom":return new e.P(0,-t);case "bottom-left":return new e.P(o,-o);case "bottom-right":return new e.P(-o,-o);case "left":return new e.P(t,0);case "right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[i]||[0,0])}const eu="undefined"!=typeof document?document.currentScript:null;var tu;tu=eu&&eu.src&&e.a(eu.src)?"cdn":"other",U=tu;const iu={version:n,supported:function(e){return !function(e){return "undefined"!=typeof window&&"undefined"!=typeof document?Object.hasOwn?function(){const e=document.createElement("canvas");e.width=e.height=1;const t=e.getContext("2d");return !!t&&t.getImageData(0,0,1,1).width===e.width}()?function(e){return e?(void 0===o&&(o=r(!0)),o):(void 0===i&&(i=r(!1)),i)}(e)?"":"insufficient WebGL2 support":"insufficient Canvas/getImageData support":"Object.hasOwn not supported":"not a browser"}(e)},setRTLTextPlugin:e.fn,getRTLTextPluginStatus:e.fm,setSdkInfo:function(t){"string"!=typeof t||t.length>64||!N.test(t)?e.w(`Invalid SDK info "${t}"; expected a "Name/version" string. Ignoring.`):k=t;},addTileProvider:e.fl,Map:class extends Sd{constructor(t){T.mark(w.create);const i=t;if(null!=(t={...zd,...t}).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");super(new Hi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._placementAlgorithm=t.placementAlgorithm||"default",this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Dd,this._domRenderTaskQueue=new Dd,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.am(),this._locale={...Ld,...t.locale},this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Ad(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new L(t.transformRequest,t.accessToken,t.testMode);const o=z(t.accessToken||e.g.ACCESS_TOKEN);if(o&&"atlas"in o&&"number"==typeof o.atlas&&(this._tokenExpiration=o.atlas),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.w("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat="auto",e.cL(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Td(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,this._fontstackCompositing=t.fontstackCompositing,(t.style||!t.testMode)&&this.setStyle(t.style||e.g.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Th("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,{...t.fitBoundsOptions,duration:0}));}this.resize(),t.attributionControl&&this.addControl(new Cd({customAttribution:t.customAttribution})),this._logoControl=new Rd,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent();}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.B(`${t.dataType}data`,t));}),this.on("dataloading",t=>{this.fire(new e.B(`${t.dataType}dataloading`,t));}),this._interactions=new Od(this);}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.A(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return i.includes("bottom")?r.insertBefore(o,r.firstChild):r.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.A(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.includes(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 e.B("movestart",t)).fire(new e.B("move",t)),this.fire(new e.B("resize",t)),i&&this.fire(new e.B("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.bF.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.B("zoomstart")).fire(new e.B("zoom")).fire(new e.B("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.B("pitchstart")).fire(new e.B("pitch")).fire(new e.B("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?navigator.language:e):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this._styleDirty=!0,this.style.setWorldview(e),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let o;"globe"===i&&t.zoom>=e.bD?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom=e.bD?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&o!==this.transform.mercatorFromTransition;return (i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.b4.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}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}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){const o=e=>{let i=[];if(Array.isArray(t)){const o=t.filter(e=>this.getLayer(e));i=o.length?this.queryRenderedFeatures(e,{layers:o}):[];}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const n=t=>{const n=o(t.point);n.length?r||(r=!0,i.call(this,new Oh(e,this,t.originalEvent,{features:n}))):r=!1;};return {listener:i,targets:t,delegates:{mousemove:n,mouseout:()=>{r=!1;}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=t=>{o(t.point).length?r=!0:r&&(r=!1,i.call(this,new Oh(e,this,t.originalEvent)));},s=t=>{r&&(r=!1,i.call(this,new Oh(e,this,t.originalEvent)));};return {listener:i,targets:t,delegates:{mousemove:n,mouseout:s}}}{const r=e=>{const t=o(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features);};return {listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._delegatedListeners?this._delegatedListeners[e]:void 0;return o&&(e=>{for(let o=0;o{if(o){const r="string"==typeof o?o:o instanceof Error?o.message:o.error;e.w(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}else r&&this._update(!0);},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._fontstackCompositing=i.fontstackCompositing,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i={...t};t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new tl(this,i).load(e),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new tl(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.A(new Error("IDs can't be empty."))),!1):e.em(t)?(this.fire(new e.A(new Error(`IDs can't contain special symbols: "${t}".`))),!1):"__proto__"!==t&&"constructor"!==t&&"prototype"!==t||(this.fire(new e.A(new Error(`IDs can't be "${t}".`))),!1)}_isTargetValid(e){return "featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return !1;return !0}return this._isTargetValid(e)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:o=1,sdf:r=!1,stretchX:n,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:h}=e.r.getImageData(i);this.style.addImage(l,{data:new e.t({width:t,height:c},h),pixelRatio:o,stretchX:n,stretchY:s,content:a,sdf:r,version:0,usvg:!1});}else if(void 0===i.width||void 0===i.height)this.fire(new e.A(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:c,height:h}=i,d=i;this.style.addImage(l,{data:new e.t({width:c,height:h},new Uint8Array(d.data)),pixelRatio:o,stretchX:n,stretchY:s,content:a,sdf:r,usvg:!1,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=e.I.from(t),r=this.style.getImage(o);if(!r)return void this.fire(new e.A(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.r.getImageData(i):i,{width:s,height:a,data:l}=n;if(void 0===s||void 0===a)return void this.fire(new e.A(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(s!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.A(new Error(`The width and height of the updated image (${s}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let h=!1;r.usvg?(r.data=new e.t({width:s,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,h=!0):r.data.replace(l,c),this.style.updateImage(o,r,h);}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.A(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t));}loadImage(t,i){(async()=>{const i=await this._requestManager.transformRequest(t,e.R.Image),{data:o}=await e.q(i);return o})().then(e=>i(null,e)).catch(i);}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.A(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this._isValidId(t.id)?(this.style.addImport(t,i).catch(t=>this.fire(new e.A(new Error("Failed to add import",t)))),this):this}updateImport(e,t){return "string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getLayerProperty(e,t){return this._isValidId(e)?this.style.getLayerProperty(e,t):null}setLayerProperty(e,t,i,o={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,o),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(e){const t=this.transform.nearClipOffset!==e;return this.transform.nearClipOffset=e,this._update(t)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.b4.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.style.indoorManager&&this.style.indoorManager.selectFloor(e);}_setIndoorActiveFloorsVisibility(e){this.style.indoorManager&&this.style.indoorManager.setActiveFloorsVisibility(e);}getIndoorTileOptions(e,t){return this.style&&this.style.isIndoorEnabled()&&this.style.indoorManager?this.style.indoorManager.getIndoorTileOptions(e,t):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,r,n=this._container;for(;n&&(!o||!r);){const e=window.getComputedStyle(n).transform;e&&"none"!==e&&(i=e.match(Fd)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(o=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),n=n.parentElement;}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=r?Math.abs(t/r):t;}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),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=l("div","mapboxgl-control-container",e),o=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{o[e]=l("div",`mapboxgl-ctrl-${e}`,i);}),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.r.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const i={...t,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},o=this._canvas.getContext("webgl2",i);o?(re(o,!0),this.painter=new xh(o,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",e=>{if("source"===e.dataType){const t=this.transform.elevation?this.transform.elevation._source():null;t&&e.sourceCacheId===t.id&&this.style&&this.style._setLabelPlacementStale(),this.style&&e.sourceCacheId&&this.style._buildingIndex.hasLayerForSourceCache(e.sourceCacheId)&&this.style._requestFullLabelPlacement(),this.painter.setTileLoadedFlag(!0);}}),e.k.testSupport(o)):this.fire(new e.A(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new e.B("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.B("webglcontextrestored",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return !this.isMoving()&&this.loaded()}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(t){let i;this.fire(new e.B("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,r=e.r.now(),n=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=n.createQuery(),n.beginQuery(o.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,o=e.r.now(),r=new e.aa(t,{now:o,fadeDuration:s,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(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(r),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(r),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions,this.painter.replacementSource,this._placementAlgorithm)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,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,paintStartTimeStamp:t}),this.fire(new e.B("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,T.mark(w.load),this.fire(new e.B("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.r.now()-r;n.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const o=n.getQueryParameter(i,n.QUERY_RESULT)/1e6;n.deleteQuery(i),this.fire(new e.B("gpu-timing-frame",{cpuTime:t,gpuTime:o}));},50);}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.B("gpu-timing-layer",{layerTimes:i}));},50);}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.B("gpu-timing-deferred-render",{gpuTime:i}));},50);}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(a=this._updateAverageElevation(r,!0)),a)this.triggerRepaint();else {if(this._triggerFrame(!1),t&&(this.fire(new e.B("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.B("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}t&&this.style&&this.style.handleIdle();}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,T.mark(w.fullLoad),this._performanceMetricsCollection&&ee(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:this.painter.style.hasTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const n=Math.abs(t-r);if(n>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(n>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_isTokenExpired(){return null!=this._tokenExpiration&&Date.now()>this._tokenExpiration}_revokeAuth(){const t=this.painter.context.gl;re(t,!1),this._logoControl instanceof Rd&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.A(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/")));}_authenticate(){ie(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{e&&(e.message!==A&&401!==e.status||this._revokeAuth());}),this._isTokenExpired()&&this._revokeAuth(),Z(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{});}_postStyleLoadEvent(){this.style.globalId&&$(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Y(this._requestManager._customAccessToken);}_postAddingAppearancesToStyleEvent(){Q(this._requestManager._customAccessToken);}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,o=i.createFramebuffer();function r(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,o),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const r=e.length/4;for(let n=0;n{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);}));}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.dB(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint();}),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get showElevationIdDebug(){return !!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(e){this.painter&&this.painter._debugParams.showElevationIdDebug!==e&&(this.painter._debugParams.showElevationIdDebug=e,this.style&&e?this.style._reloadSources():this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this.style&&e?this.style._reloadSources():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(t,i){e.fh(t,i);}get version(){return n}},NavigationControl:class{constructor(t={}){this.options={...Bd,...t},this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.cL(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e});}),l("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e});}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.cL(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));}),this._compassIcon=l("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t);});}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new kd(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends e.E{constructor(t={}){super();const i=navigator.geolocation;this.options={geolocation:i,...Wd,...t},e.cL(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=bh(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),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){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t();}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return !!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setWatchState(e){this._watchState=e;const t=this._geolocateButton.classList;t.remove(...Zd);for(const i of qd[e])t.add(Hd(i));}_setButtonTitle(e){const t=this._map._getUIString(e);this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t);}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":this._setWatchState("ACTIVE_ERROR");break;case "BACKGROUND":this._setWatchState("BACKGROUND_ERROR");}}_onSuccess(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.B("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this._lastKnownPosition=t,this.options.trackUserLocation)switch(this._watchState){case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":this._setWatchState(this.options.followUserLocation?"ACTIVE_LOCK":"BACKGROUND");break;case "BACKGROUND":case "BACKGROUND_ERROR":this._setWatchState("BACKGROUND");}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.followUserLocation&&(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.B("geolocate",{coords:t.coords,timestamp:t.timestamp,...t.toJSON?{toJSON:t.toJSON.bind(t)}:{}})),this._finish();}}_updateCamera(t){const i=new e.b4(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,r={bearing:this._map.getBearing(),...this.options.fitBoundsOptions};this._map.fitBounds(i.toBounds(o),r,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.b4(t.coords.longitude,t.coords.latitude);this.options.showAccuracyCircle?this._accuracyCircleMarker.setLngLat(i).addTo(this._map):this._accuracyCircleMarker.remove(),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const t=this._map.transform,i=e.aL(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(t){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(1===t.code)this._setWatchState("OFF"),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable"),void 0!==this._geolocationWatchID&&this._clearWatch();else {if(3===t.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.B("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_startRequestTimeout(){this._clearRequestTimeout();const e=this.options.positionOptions.timeout;e&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"});},e));}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0);}_setupUI(t){void 0!==this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t?(e.w("Geolocation support is not available so the GeolocateControl will be disabled."),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable")):this._setButtonTitle("GeolocateControl.FindMyLocation"),this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._createUserLocationMarkers(),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.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._setWatchState("BACKGROUND"),this.fire(new e.B("trackuserlocationend")));}),this.fire(new e.B("ready")));}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case "OFF":this._setWatchState("WAITING_ACTIVE"),this.fire(new e.B("trackuserlocationstart"));break;case "WAITING_ACTIVE":case "ACTIVE_LOCK":case "ACTIVE_ERROR":case "BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._setWatchState("OFF"),this.fire(new e.B("trackuserlocationend"));break;case "BACKGROUND":this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.B("trackuserlocationstart"));}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add(Hd("waiting")),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return !0}setFollowUserLocation(t){return this.options.followUserLocation=null!=t?t:Wd.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.B("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._setWatchState("BACKGROUND"),this.fire(new e.B("trackuserlocationend")))),this}setShowAccuracyCircle(t){if(this.options.showAccuracyCircle=null!=t?t:Wd.showAccuracyCircle,!this._accuracyCircleMarker)return this;if(this.options.showAccuracyCircle){if(this.options.showUserLocation&&this._lastKnownPosition){const{longitude:t,latitude:i,accuracy:o}=this._lastKnownPosition.coords;this._accuracy=o,this._accuracyCircleMarker.setLngLat(new e.b4(t,i)).addTo(this._map),this._updateCircleRadius();}}else this._accuracyCircleMarker.remove();return this}setShowUserHeading(e){return this.options.showUserHeading=null!=e?e:Wd.showUserHeading,this._setup?(this.options.showUserHeading?void 0!==this._geolocationWatchID&&this._addDeviceOrientationListener():(this._removeDeviceOrientationListener(),this._heading=void 0,this._userLocationDotMarker&&this._updateMarkerRotation()),this):this}setFitBoundsOptions(e){return this.options.fitBoundsOptions=null!=e?e:Wd.fitBoundsOptions,this}setShowUserLocation(e){return this.options.showUserLocation=null!=e?e:Wd.showUserLocation,this._setup?(this.options.showUserLocation?(this._userLocationDotMarker||(this._createUserLocationMarkers(),this._map.on("zoom",this._onZoom)),!this._lastKnownPosition||void 0!==this._watchState&&"OFF"===this._watchState||this._updateMarker(this._lastKnownPosition)):(this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this._accuracyCircleMarker&&this._accuracyCircleMarker.remove()),this):this}_addDeviceOrientationListener(){const e=()=>{const e="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(e,this._onDeviceOrientation);};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e();}).catch(console.error):e();}_removeDeviceOrientationListener(){window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation);}_createUserLocationMarkers(){this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Vd({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Vd({element:this._circleElement,pitchAlignment:"map"});}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),this._removeDeviceOrientationListener(),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(Hd("waiting")),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:Cd,ScaleControl:class{constructor(t={}){this.options={...$d,...t},e.cL(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,r=t.unproject([o,i]),n=t.unproject([o+e,i]),s=r.distanceTo(n);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter");}_setScale(e,t,i){this._map._requestDomTask(()=>{const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),r=o/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o} ${Xd[i]}`,this._container.style.width=e*r+"px";});}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.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(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.cL(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},IndoorControl:class{constructor(){e.cL(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null;}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._map.on("idle",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection();}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const e=this._map.style.indoorManager;e.off("selector-update",this._onIndoorUpdate),e.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(e.getControlState()),this._map.off("idle",this._onStyleData);}}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){e.setAttribute("aria-label",t),e.textContent=t;}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.off("idle",this._onStyleData),this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null);}getDefaultPosition(){return "top-right"}_onIndoorUpdate(e){if(!e||!e.floors||0===e.floors.length)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block";const i=!t||t.floors.length!==e.floors.length||t.floors.some((t,i)=>t.id!==e.floors[i].id);if(i&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),e.selectedFloorId){if(e.selectedFloorId!==this._lastSelectedFloorId||i){const t=e.floors.findIndex(t=>t.id===e.selectedFloorId);if(-1!==t){const i=e.floors.length;let o,r;i<=5?(o=0,r=i-1):0===this._visibleFloorStart?(o=0,r=3):this._visibleFloorStart>=i-3?(o=i-3-1,r=i-1):(o=this._visibleFloorStart,r=this._visibleFloorStart+3-1),tr&&(this._visibleFloorStart=t-2);}}this._lastSelectedFloorId=e.selectedFloorId;}this._render();}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const e=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(e);const t=this._model.floors,i=t.length;if(i<=5)return void t.forEach(e=>this._createFloorButton(e));const o=0===this._visibleFloorStart,r=this._visibleFloorStart>=i-3;if(o)this._createFloorButton(t[0]);else {const e=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}let n=[];if(n=o?t.slice(1,4):r?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),n.forEach(e=>this._createFloorButton(e)),r)this._createFloorButton(t[i-1]);else {const e=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}}_createFloorButton(e){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const t=e.id;this._model&&this._model.selectedFloorId===t&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(t));}),i=(e.name||"").trim(),o=e.zIndex.toString(),r=i?Array.from(i).slice(0,3).join(""):o;this._setButtonTitle(t,r),this._model&&this._model.activeFloorsVisible&&e.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t);}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1);}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);const e=this._model&&this._model.floors||[];if(e.length>3){const t=e.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2);}this._render();}}_scrollDown(){if(this._model&&this._model.floors){const e=this._model.floors.length-3;this._visibleFloorStarte&&(this._visibleFloorStart=e),this._render());}}},Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(Kd),t),this._altitude=this.options.altitude,e.cL(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(Yd):[]);}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.B("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.B("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.b4.convert(t),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}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,o=this._pos;if(!t||!i||!o)return "bottom";const r=i.offsetWidth,n=i.offsetHeight,s=o.xt.transform.width-r/2;if(o.y+et.transform.height-n){if(s)return "bottom-left";if(a)return "bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(t){const i=this._map,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let r=this._container;if(r||(r=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",r),r.appendChild(o)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Nd(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=Jd(this.options.offset),n=this._anchor=this._getAnchor(r.y),s=Jd(this.options.offset,n),a=o.add(s).round();i._requestDomTask(()=>{this._container&&n&&(this._container.style.transform=`${Ud[n]} translate(${a.x}px,${a.y}px)`);});}if(!this._marker&&i._showingGlobe()){const t=e.fi(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Qd);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:Vd,Style:tl,LngLat:e.b4,LngLatBounds:e.bF,Point:e.P,MercatorCoordinate:e.ac,FreeCameraOptions:Si,Evented:e.E,config:e.g,prewarm:function(){Zs().acquire(si);},clearPrewarmedResources:function(){const e=Hs;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(si),Hs=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 e.g.ACCESS_TOKEN},set accessToken(t){e.fx(t);},get baseApiUrl(){return e.g.API_URL},set baseApiUrl(t){e.fw(t);},get workerCount(){return ai.workerCount},set workerCount(e){!function(e){ai.workerCount=e;}(e);},get maxParallelImageRequests(){return e.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.fv(t);},clearStorage(t){e.fu(t);},get workerUrl(){return ri.workerUrl},set workerUrl(e){ri.workerUrl=e;},get workerClass(){return ri.workerClass},set workerClass(e){ri.workerClass=e;},get dracoUrl(){return e.ft()},set dracoUrl(t){e.fs(t);},get meshoptUrl(){return e.fr()},set meshoptUrl(t){e.fq(t);},get buildingGenUrl(){return e.fp()},set buildingGenUrl(t){e.fo(t);},setNow:e.r.setNow,restoreNow:e.r.restoreNow};return iu}); var mapboxgl$1 = mapboxgl; diff --git a/librarybot.yml b/librarybot.yml index 1218a98d..2af9cbaa 100644 --- a/librarybot.yml +++ b/librarybot.yml @@ -126,7 +126,7 @@ libraries: baseDir: static/lib clean: true - npm: mapbox-gl - version: 3.25.0 + version: 3.27.0 local: items: - from: dist/mapbox-gl.css